diff options
| author | 2015-04-01 00:28:17 +0200 | |
|---|---|---|
| committer | 2015-04-01 00:28:17 +0200 | |
| commit | 60a0e524561ae86c9509c61b00a5d8ba40a1d7ee (patch) | |
| tree | cd60b92368403a806ee8e7bcb00b41e5000722f1 /diceparser.cpp | |
| parent | 5bd5a8a07a900c013c120b4e228c766a84a05b09 (diff) | |
| download | OneRoll-60a0e524561ae86c9509c61b00a5d8ba40a1d7ee.tar.gz OneRoll-60a0e524561ae86c9509c61b00a5d8ba40a1d7ee.zip | |
-Better understanding of validators toString method
-return error if error have been detected for endless loop.
-add listaliasnode.h/.cpp to the pri file
-protect the use of pointer
Diffstat (limited to 'diceparser.cpp')
| -rw-r--r-- | diceparser.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index 9404f08..91e4af0 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -100,6 +100,7 @@ QString DiceParser::convertAlias(QString str) bool DiceParser::parseLine(QString str) { + m_errorMap.clear(); m_command = str; m_start = new StartingNode(); ExecutionNode* newNode = NULL; @@ -108,7 +109,7 @@ bool DiceParser::parseLine(QString str) str = convertAlias(str); bool keepParsing = readExpression(str,newNode); - while(keepParsing) + if(keepParsing) { m_current->setNextNode(newNode); m_current = getLatestNode(m_current); @@ -119,10 +120,16 @@ bool DiceParser::parseLine(QString str) m_current = getLatestNode(m_current); } - return true; + } + if(m_errorMap.isEmpty()) + { + return true; + } + else + { + return false; } - return false; } @@ -785,9 +792,9 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous, bool hasDice) Validator* validator = m_parsingToolbox->readValidator(str); if(NULL!=validator) { - if(m_parsingToolbox->isValidValidator(previous,validator)) + if(!m_parsingToolbox->isValidValidator(previous,validator)) { - m_errorMap.insert(ExecutionNode::ENDLESS_LOOP_ERROR,tr("this condition introduce an endless loop: %1. Please, change it").arg(validator->toString())) + m_errorMap.insert(ExecutionNode::ENDLESS_LOOP_ERROR,QObject::tr("This condition %1 introduces an endless loop. Please, change it").arg(validator->toString())); } ExploseDiceNode* explosedNode = new ExploseDiceNode(); explosedNode->setValidator(validator); @@ -819,6 +826,7 @@ QString DiceParser::humanReadableError() str.append(i.value()); str.append("\n"); } + return str; } bool DiceParser::readOperand(QString& str,ExecutionNode* & node) |