diff options
| author | 2016-01-26 15:35:18 +0100 | |
|---|---|---|
| committer | 2016-01-26 15:35:18 +0100 | |
| commit | 19bfac5d61c7e30a1e5bbe115d56908474546052 (patch) | |
| tree | 861b2810c38bdfb28140c621a68aa3ddeb0a4564 /diceparser.cpp | |
| parent | 821b47e5b13167bc89841762311296e1ed0bedba (diff) | |
| download | OneRoll-19bfac5d61c7e30a1e5bbe115d56908474546052.tar.gz OneRoll-19bfac5d61c7e30a1e5bbe115d56908474546052.zip | |
Implementation of the if node. Work with one if.
Diffstat (limited to 'diceparser.cpp')
| -rw-r--r-- | diceparser.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index 6e63eec..92cd2e1 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -954,7 +954,15 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous, bool hasDice)/ Validator* validator = m_parsingToolbox->readCompositeValidator(str); if(NULL!=validator) { - + ExecutionNode* trueNode; + ExecutionNode* falseNode; + if(readIfInstruction(str,trueNode,falseNode)) + { + nodeif->setInstructionTrue(trueNode); + nodeif->setInstructionFalse(falseNode); + nodeif->setValidator(validator); + previous->setNextNode(nodeif); + } } } @@ -963,6 +971,33 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous, bool hasDice)/ } return isFine; } +bool DiceParser::readIfInstruction(QString& str,ExecutionNode*& trueNode,ExecutionNode*& falseNode) +{ + if(str.startsWith('{')) + { + str=str.remove(0,1); + ExecutionNode* node; + readExpression(str,node); + if(str.startsWith('}')) + { + trueNode = node; + str=str.remove(0,1); + if(str.startsWith('{')) + { + str=str.remove(0,1); + ExecutionNode* node2; + readExpression(str,node2); + if(str.startsWith('}')) + { + falseNode=node2; + return true; + } + } + return true; + } + } + return false; +} QMap<ExecutionNode::ERROR_CODE,QString> DiceParser::getErrorMap() { |