diff options
| author | 2018-12-15 12:04:21 +0100 | |
|---|---|---|
| committer | 2018-12-15 12:04:21 +0100 | |
| commit | 1575a8098416dbd3878505cd3eb81c4a3d43ce78 (patch) | |
| tree | 21333309d7f5f335bb28414b01d907e8077e918b /diceparser.cpp | |
| parent | a0f8bbc597ea0fe0f77979849685705a117faa7f (diff) | |
| download | OneRoll-1575a8098416dbd3878505cd3eb81c4a3d43ce78.tar.gz OneRoll-1575a8098416dbd3878505cd3eb81c4a3d43ce78.zip | |
Fix several issues.
Diffstat (limited to 'diceparser.cpp')
| -rw-r--r-- | diceparser.cpp | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index 58fe647..2beb414 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -225,10 +225,10 @@ node = operandNode; operandNode= ParsingToolBox::getLatestNode(operandNode); - ExecutionNode* operatorNode=nullptr; - while(readOperator(str,operatorNode)) + //ExecutionNode* operatorNode=nullptr; + while(readOperator(str,operandNode)) { - operandNode->setNextNode(operatorNode); + //operandNode->setNextNode(operatorNode); operandNode= ParsingToolBox::getLatestNode(operandNode); }; return true; @@ -248,7 +248,7 @@ node = operandNode; return true; } - else if(readOperator(str,operandNode)) + else if(readOperatorFromNull(str,operandNode)) { node = operandNode; return true; @@ -271,6 +271,7 @@ } return false; } + bool DiceParser::readOptionFromNull(QString& str,ExecutionNode* & node) { StartingNode nodePrevious; @@ -283,6 +284,20 @@ } return false; } + + bool DiceParser::readOperatorFromNull(QString& str,ExecutionNode* & node) + { + StartingNode nodePrevious; + if(readOperator(str,&nodePrevious)) + { + auto nodeNext = nodePrevious.getNextNode(); + nodePrevious.setNextNode(nullptr); + node = nodeNext; + return true; + } + return false; + } + bool DiceParser::readNode(QString& str,ExecutionNode* & node) { QString key= str.left(1); @@ -870,10 +885,8 @@ while(keepParsing) { auto before = str; - ExecutionNode* operatorNode = nullptr; - if(readOperator(str,operatorNode)) + if(readOperator(str,latest)) { - latest->setNextNode(operatorNode); latest = ParsingToolBox::getLatestNode(latest); } keepParsing = (!str.isEmpty() & (before!=str)); @@ -903,9 +916,9 @@ return hasInstruction; } - bool DiceParser::readOperator(QString& str,ExecutionNode*& nodeResult) + bool DiceParser::readOperator(QString& str,ExecutionNode* previous) { - if(str.isEmpty() /*|| nullptr == previous*/) + if(str.isEmpty() || nullptr == previous) { return false; } @@ -948,8 +961,8 @@ nodeExec->setNextNode(nullptr); } - nodeResult = node; - //previous->setNextNode(node); + //nodeResult = node; + previous->setNextNode(node); return true; } @@ -958,13 +971,13 @@ delete node; } } - /* else + else { while(readOption(str,previous)) { previous = ParsingToolBox::getLatestNode(previous); } - }*/ + } return false; } bool DiceParser::hasSeparator()const |