diff options
| author | 2015-09-07 08:35:31 +0200 | |
|---|---|---|
| committer | 2015-09-07 08:35:31 +0200 | |
| commit | 5f2226d1c4eb03a5b7cdfdd4f30a968e4b526b2a (patch) | |
| tree | 7dc5b5247e90c5c0a338ce4444a8fbb5d3637488 | |
| parent | c6449aebc9b16042672a2dffb5d1b3794584005b (diff) | |
| parent | 7ce5a4af6fb836432eb6ce7637ea09d6a5b4e0bd (diff) | |
| download | OneRoll-5f2226d1c4eb03a5b7cdfdd4f30a968e4b526b2a.tar.gz OneRoll-5f2226d1c4eb03a5b7cdfdd4f30a968e4b526b2a.zip | |
Merge branch 'master' of github.com:obiwankennedy/DiceParser
| -rw-r--r-- | diceparser.cpp | 45 | ||||
| -rw-r--r-- | diceparser.h | 9 | ||||
| -rw-r--r-- | node/helpnode.cpp | 19 | ||||
| -rw-r--r-- | node/helpnode.h | 19 | ||||
| -rw-r--r-- | node/startingnode.cpp | 21 | ||||
| -rw-r--r-- | node/startingnode.h | 20 |
6 files changed, 125 insertions, 8 deletions
diff --git a/diceparser.cpp b/diceparser.cpp index dcb5030..802b5f2 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -44,6 +44,7 @@ DiceParser::DiceParser() : m_start(NULL),m_current(NULL) { + m_currentTreeHasSeparator =false; m_parsingToolbox = new ParsingToolBox(); m_mapDiceOp = new QMap<QString,DiceOperator>(); @@ -145,6 +146,7 @@ void DiceParser::insertAlias(DiceAlias* dice, int i) bool DiceParser::parseLine(QString str) { + m_currentTreeHasSeparator = false; m_errorMap.clear(); if(NULL!=m_start) { @@ -412,7 +414,36 @@ QStringList DiceParser::getAllStringResult(bool& hasAlias) return stringListResult; } +QStringList DiceParser::getAllDiceResult(bool& hasAlias) +{ + ExecutionNode* next = getLeafNode(); + Result* result=next->getResult(); + QList<Die*> dieListResult; + QStringList stringListResult; + while(NULL!=result) + { + if(result->hasResultOfType(Result::DICE_LIST)) + { + DiceResult* stringResult = dynamic_cast<DiceResult*>(result); + if(NULL!=stringResult) + { + dieListResult << stringResult->getResultList(); + hasAlias = true; + } + } + result = result->getPrevious(); + } + foreach(Die* die, dieListResult) + { + foreach (qint64 value, die->getListValue()) + { + stringListResult << QString::number(value); + } + } + + return stringListResult; +} void DiceParser::getLastDiceResult(ExportedDiceResult& diceValues) { ExecutionNode* next = getLeafNode(); @@ -701,21 +732,19 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous) } else if(readInstructionOperator(str[0])) { - str=str.remove(0,1); - delete node; + str=str.remove(0,1); + delete node; ExecutionNode* nodeExec = NULL; if(readExpression(str,nodeExec)) { - - // nodeExec = getLatestNode(nodeExec); - if(NULL==nodeExec) { return false; } previous->setNextNode(nodeExec); - + m_currentTreeHasSeparator = true; return true; + } } else @@ -728,6 +757,10 @@ bool DiceParser::readOperator(QString& str,ExecutionNode* previous) } return false; } +bool DiceParser::hasSeparator()const +{ + return m_currentTreeHasSeparator; +} DiceRollerNode* DiceParser::addRollDiceNode(qint64 faces,ExecutionNode* previous) { DiceRollerNode* mydiceRoller= new DiceRollerNode(faces); diff --git a/diceparser.h b/diceparser.h index 487216f..6b9056f 100644 --- a/diceparser.h +++ b/diceparser.h @@ -196,6 +196,14 @@ public: * @return */ QStringList getAllStringResult(bool& hasAlias); + /** + * @brief getAllDiceResult + * @param hasAlias + * @return + */ + QStringList getAllDiceResult(bool& hasAlias); + + bool hasSeparator()const; private: /** @@ -302,6 +310,7 @@ private: QString m_command; ParsingToolBox* m_parsingToolbox; QString m_helpPath; + bool m_currentTreeHasSeparator; }; #endif // DICEPARSER_H diff --git a/node/helpnode.cpp b/node/helpnode.cpp index 62dc86e..dd5f087 100644 --- a/node/helpnode.cpp +++ b/node/helpnode.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #include "helpnode.h" HelpNode::HelpNode() diff --git a/node/helpnode.h b/node/helpnode.h index 88a0842..be21b67 100644 --- a/node/helpnode.h +++ b/node/helpnode.h @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #ifndef HELPNODE_H #define HELPNODE_H #include "executionnode.h" diff --git a/node/startingnode.cpp b/node/startingnode.cpp index b15101b..7e13f5d 100644 --- a/node/startingnode.cpp +++ b/node/startingnode.cpp @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #include "startingnode.h" #include <QDebug> @@ -24,7 +43,5 @@ qint64 StartingNode::getPriority() const { priority = m_nextNode->getPriority(); } - - return priority; } diff --git a/node/startingnode.h b/node/startingnode.h index ebe28c0..1edebc9 100644 --- a/node/startingnode.h +++ b/node/startingnode.h @@ -1,3 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2015 by Renaud Guezennec * + * http://renaudguezennec.homelinux.org/accueil,3.html * + * * + * rolisteam is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ #ifndef STARTINGNODE_H #define STARTINGNODE_H @@ -31,3 +50,4 @@ public: }; #endif // STARTINGNODE_H + |