aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--parsingtoolbox.cpp43
-rw-r--r--parsingtoolbox.h9
2 files changed, 51 insertions, 1 deletions
diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp
index 3e09bac..0052f07 100644
--- a/parsingtoolbox.cpp
+++ b/parsingtoolbox.cpp
@@ -141,7 +141,7 @@ bool ParsingToolBox::readNumber(QString& str, int& myNumber)
QString number;
int i=0;
- while(i<str.length() && str[i].isNumber())
+ while(i<str.length() && ((str[i].isNumber()) || ( (i==0) && (str[i]=='-'))))
{
number+=str[i];
++i;
@@ -234,3 +234,44 @@ DiceRollerNode* ParsingToolBox::getDiceRollerNode(ExecutionNode* previous)
previous = previous->getPreviousNode();
}
}
+bool ParsingToolBox::readDiceRange(QString& str,int& start, int& end)
+{
+ bool expectSquareBrasket=false;
+
+ qDebug()<<"readDiceRange"<<str;
+ if((str.startsWith("[")))
+ {
+ str=str.remove(0,1);
+ expectSquareBrasket = true;
+ }
+qDebug()<<"readDiceRange"<<str;
+ if(readNumber(str,start))
+ {
+ qDebug()<<"readDiceRange"<<str;
+ if(str.startsWith("-"))
+ {
+ str=str.remove(0,1);
+ if(readNumber(str,end))
+ {
+ if(expectSquareBrasket)
+ {
+ if(str.startsWith("]"))
+ {
+ str=str.remove(0,1);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ return false;
+ }
+ qDebug()<<"readDiceRange"<<str;
+ }
+ }
+
+}
diff --git a/parsingtoolbox.h b/parsingtoolbox.h
index 8958550..5d38919 100644
--- a/parsingtoolbox.h
+++ b/parsingtoolbox.h
@@ -115,6 +115,15 @@ public:
*/
DiceRollerNode* getDiceRollerNode(ExecutionNode* previous);
+ /**
+ * @brief readDiceRange
+ * @param str
+ * @param start
+ * @param end
+ * @return
+ */
+ bool readDiceRange(QString& str,int& start, int& end);
+
private:
QMap<QString,BooleanCondition::LogicOperator>* m_logicOp;
};