aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.cpp
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2014-12-06 10:14:43 +0100
committerRenaud G <renaud@rolisteam.org>2014-12-06 10:14:43 +0100
commit3d7029f1b4254403374cb1d8f5cbf2814f2c9ec4 (patch)
tree64f477fc7f0a2473d78c88fc6fcd1e1d9ea448d4 /diceparser.cpp
parente535ea89b0eb4722c6a11de7015c6f4f0c436825 (diff)
downloadOneRoll-3d7029f1b4254403374cb1d8f5cbf2814f2c9ec4.tar.gz
OneRoll-3d7029f1b4254403374cb1d8f5cbf2814f2c9ec4.zip
-change API of displayResult to return QString
Diffstat (limited to 'diceparser.cpp')
-rw-r--r--diceparser.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index 4a259b2..c94c2b5 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -81,7 +81,6 @@ bool DiceParser::parseLine(QString str)
bool keepParsing = readExpression(str,newNode);
-
while(keepParsing)
{
m_current->setNextNode(newNode);
@@ -94,6 +93,7 @@ bool DiceParser::parseLine(QString str)
m_current = getLatestNode(m_current);
}
return true;
+
}
return false;
@@ -152,6 +152,10 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
numberNode->setNextNode(diceNode);
node = numberNode;
}
+ else
+ {
+ return false;
+ }
}
return true;
}
@@ -160,7 +164,8 @@ void DiceParser::Start()
{
m_start->run();
}
-void DiceParser::displayResult()
+
+QString DiceParser::displayResult()
{
ExecutionNode* next = m_start;
@@ -240,6 +245,9 @@ void DiceParser::displayResult()
out << str << "you rolled: " <<m_command << endl;
out << endl;
+
+ return QString("%1, you rolled:%3").arg(str.simplified()).arg(m_command) ;
+
// qDebug() << "result count:" << resulCount;
}
@@ -329,6 +337,10 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous)
if(readExpression(str,nodeExec))
{
node->setInternalNode(nodeExec);
+ if(NULL==nodeExec)
+ {
+ return false;
+ }
if(node->getPriority()>=nodeExec->getPriority())
{
node->setNextNode(nodeExec->getNextNode());