diff options
| author | 2019-07-10 11:49:45 +0200 | |
|---|---|---|
| committer | 2019-07-12 22:06:35 +0200 | |
| commit | 9698a39a46f736cf37e31f8940e7c1a0a164185b (patch) | |
| tree | 2193ae89ae6cfb59d7b6eed443992bd0245ac5a4 /diceparser.cpp | |
| parent | 64ca7904fd36ad86826b5d5c72f47ffdf0ff365a (diff) | |
| download | OneRoll-9698a39a46f736cf37e31f8940e7c1a0a164185b.tar.gz OneRoll-9698a39a46f736cf37e31f8940e7c1a0a164185b.zip | |
Add valueslistnode
Diffstat (limited to 'diceparser.cpp')
| -rw-r--r-- | diceparser.cpp | 36 |
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()) |