diff options
| author | 2016-11-01 12:10:54 +0100 | |
|---|---|---|
| committer | 2016-11-01 12:10:54 +0100 | |
| commit | d5876d9b88c2f695592338335308a32e584d86a4 (patch) | |
| tree | bb0c3f757512fb913812902143b73b7380451502 /diceparser.cpp | |
| parent | d29b6d34b713d9241eb96cb99802ca8bc24cc3bd (diff) | |
| download | OneRoll-d5876d9b88c2f695592338335308a32e584d86a4.tar.gz OneRoll-d5876d9b88c2f695592338335308a32e584d86a4.zip | |
-add management of string node to display text in some condition.
Diffstat (limited to 'diceparser.cpp')
| -rw-r--r-- | diceparser.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index b6081a7..809a557 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -41,6 +41,8 @@ #include "node/mergenode.h" #include "node/ifnode.h" #include "node/paintnode.h" +#include "node/stringnode.h" + #define DEFAULT_FACES_NUMBER 10 @@ -171,9 +173,8 @@ bool DiceParser::parseLine(QString str) if(keepParsing) { // keepParsing = - readOperator(str,m_current); - - m_current = getLatestNode(m_current); + readOperator(str,m_current); + m_current = getLatestNode(m_current); } } @@ -990,6 +991,14 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, nodeif->setValidator(validator); previous->setNextNode(nodeif); } + else + { + delete nodeif; + } + } + else + { + delete nodeif; } } @@ -1073,7 +1082,7 @@ QString DiceParser::humanReadableError() bool DiceParser::readOperand(QString& str,ExecutionNode* & node) { qint64 myNumber=1; - + QString resultStr; if(m_parsingToolbox->readNumber(str,myNumber)) { NumberNode* numberNode = new NumberNode(); @@ -1082,6 +1091,15 @@ bool DiceParser::readOperand(QString& str,ExecutionNode* & node) node = numberNode; return true; } + else if(m_parsingToolbox->readString(str,resultStr)) + { + StringNode* strNode = new StringNode(); + strNode->setString(resultStr); + node = strNode; + return true; + } + ///! @todo Make this operator working + return false; } void DiceParser::writeDownDotTree(QString filepath) |