aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'diceparser.cpp')
-rw-r--r--diceparser.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index 18be076..1f58948 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -271,6 +271,11 @@ bool DiceParser::readExpression(QString& str, ExecutionNode*& node)
node= operandNode;
return true;
}
+ else if(readValuesList(str, operandNode))
+ {
+ node= operandNode;
+ return true;
+ }
else
{
ExecutionNode* diceNode= nullptr;
@@ -316,6 +321,37 @@ bool DiceParser::readOperatorFromNull(QString& str, ExecutionNode*& node)
return false;
}
+bool DiceParser::readValuesList(QString& str, ExecutionNode*& node)
+{
+ if(str.startsWith("["))
+ {
+ str= str.remove(0, 1);
+ int pos= ParsingToolBox::findClosingCharacterIndexOf('[', ']', str, 1); // str.indexOf("]");
+ if(-1 != pos)
+ {
+ QString liststr= str.left(pos);
+ auto list= liststr.split(",");
+ str= str.remove(0, pos + 1);
+ auto values= new ValuesListNode();
+ for(auto var : list)
+ {
+ qint64 number= 1;
+ QString error;
+ if(ParsingToolBox::readDynamicVariable(var, number))
+ {
+ VariableNode* variableNode= new VariableNode();
+ variableNode->setIndex(number - 1);
+ variableNode->setData(&m_startNodes);
+ values->insertValue(variableNode);
+ }
+ }
+ node= values;
+ return true;
+ }
+ }
+ return false;
+}
+
bool DiceParser::readNode(QString& str, ExecutionNode*& node)
{
if(str.isEmpty())