aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/diceparser.cpp
diff options
context:
space:
mode:
authorobiwankennedy <renaud@rolisteam.org>2017-11-30 13:25:12 +0100
committerobiwankennedy <renaud@rolisteam.org>2017-11-30 13:25:12 +0100
commit6fe196cdf156e71c07e1908c2b6ebc5fe0e5faa6 (patch)
treeb09c0cc9c10ea05faf3ce8e5dc5b4a9894fdd9c5 /diceparser.cpp
parentc930587ff1fd23cf14c9c428d1756a02e10728d0 (diff)
downloadOneRoll-6fe196cdf156e71c07e1908c2b6ebc5fe0e5faa6.tar.gz
OneRoll-6fe196cdf156e71c07e1908c2b6ebc5fe0e5faa6.zip
-Fix reading dynamic variable
-Move function
Diffstat (limited to 'diceparser.cpp')
-rw-r--r--diceparser.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index 08f3110..fbf473a 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -123,15 +123,7 @@ DiceParser::~DiceParser()
m_start = nullptr;
}
}
-ExecutionNode* DiceParser::getLatestNode(ExecutionNode* node)
-{
- ExecutionNode* next = node;
- while(nullptr != next->getNextNode() )
- {
- next = next->getNextNode();
- }
- return next;
-}
+
QString DiceParser::convertAlias(QString str)
{
for(DiceAlias* cmd : *m_aliasList)
@@ -176,13 +168,13 @@ bool DiceParser::parseLine(QString str)
if(keepParsing)
{
m_current->setNextNode(newNode);
- m_current = getLatestNode(m_current);
+ m_current = ParsingToolBox::getLatestNode(m_current);
keepParsing =!str.isEmpty();
if(keepParsing)
{
// keepParsing =
readOperator(str,m_current);
- m_current = getLatestNode(m_current);
+ m_current = ParsingToolBox::getLatestNode(m_current);
}
}
@@ -232,10 +224,10 @@ bool DiceParser::readExpression(QString& str,ExecutionNode* & node)
}
node = operandNode;
- operandNode= getLatestNode(operandNode);
+ operandNode= ParsingToolBox::getLatestNode(operandNode);
while(readOperator(str,operandNode))
{
- operandNode= getLatestNode(operandNode);
+ operandNode= ParsingToolBox::getLatestNode(operandNode);
};
}
else if(readCommand(str,operandNode))
@@ -698,7 +690,7 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node)
ExecutionNode* current = drNode;
while(readOption(str,current))
{
- current = getLatestNode(current);
+ current = ParsingToolBox::getLatestNode(current);
}
return true;
}
@@ -717,7 +709,7 @@ bool DiceParser::readDice(QString& str,ExecutionNode* & node)
ExecutionNode* current = drNode;
while(readOption(str,current))
{
- current = getLatestNode(current);
+ current = ParsingToolBox::getLatestNode(current);
}
return true;
}
@@ -897,7 +889,7 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous)
{
while(readOption(str,previous))
{
- previous = getLatestNode(previous);
+ previous = ParsingToolBox::getLatestNode(previous);
}
}
return false;
@@ -1260,13 +1252,15 @@ bool DiceParser::readOperand(QString& str,ExecutionNode* & node)
if(m_parsingToolbox->readDynamicVariable(str,intValue))
{
VariableNode* variableNode = new VariableNode();
- variableNode->setIndex(intValue);
+ variableNode->setIndex(intValue-1);
+ variableNode->setData(&m_startNodes);
+ node = variableNode;
+ return true;
}
else if(m_parsingToolbox->readNumber(str,intValue))
{
NumberNode* numberNode = new NumberNode();
numberNode->setNumber(intValue);
-
node = numberNode;
return true;
}