From b18145b6e97714fc093a261984b4248acb370151 Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 15 Dec 2018 16:02:07 +0100 Subject: Small modification to validate tests. --- diceparser.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'diceparser.cpp') diff --git a/diceparser.cpp b/diceparser.cpp index c65ef74..04e9af6 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -181,6 +181,9 @@ bool DiceParser::parseLine(QString str, bool allowAlias) m_warningMap.insert(ExecutionNode::UNEXPECTED_CHARACTER,QObject::tr("Unexpected character at %1 - end of command was ignored \"%2\"").arg(i).arg(str)); } + if(!m_errorMap.isEmpty()) + value = false; + return value; } @@ -812,6 +815,7 @@ bool DiceParser::readCommand(QString& str,ExecutionNode* & node) { if(str== QLatin1String("help")) { + str=str.remove(0,QLatin1String("help").size()); HelpNode* help = new HelpNode(); if(!m_helpPath.isEmpty()) { @@ -822,6 +826,7 @@ bool DiceParser::readCommand(QString& str,ExecutionNode* & node) } else if(str== QLatin1String("la")) { + str=str.remove(0,QLatin1String("la").size()); node = new ListAliasNode(m_aliasList); } return true; -- cgit v1.2.3-70-g09d2 From 6cf27a39e9b8f8c5c463f431ae585381d8a7c25e Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sun, 16 Dec 2018 18:15:11 +0100 Subject: remove warning To be Fixed - Dice Gui won't compile anymore --- dicealias.cpp | 2 -- diceparser.cpp | 103 +++------------------------------------------------------ diceparser.h | 2 +- 3 files changed, 6 insertions(+), 101 deletions(-) (limited to 'diceparser.cpp') diff --git a/dicealias.cpp b/dicealias.cpp index 5730187..cc06510 100644 --- a/dicealias.cpp +++ b/dicealias.cpp @@ -26,8 +26,6 @@ QString makeReplament(const QString& pattern, const QString& replacement, QString cmd) { - - // FIXME try to do the same with RegularExpression auto hasPattern = cmd.contains(pattern); if(hasPattern) { diff --git a/diceparser.cpp b/diceparser.cpp index 04e9af6..79e31f5 100644 --- a/diceparser.cpp +++ b/diceparser.cpp @@ -323,99 +323,6 @@ void DiceParser::start() } } -QString DiceParser::displayResult() -{ - QStringList resultList; - for(auto start : m_startNodes) - { - ExecutionNode* next = start; - int nodeCount=0; - int resulCount=0; - while(nullptr != next->getNextNode() ) - { - next = next->getNextNode(); - ++nodeCount; - } - ////////////////////////////////// - // - // Display - // - ////////////////////////////////// - - QString str; - QTextStream stream(&str); - Result* result=next->getResult(); - - QString totalValue("you got %1 ;"); - QString dieValue("D%1 : {%2} "); - - bool scalarDone=false; - while(nullptr!=result) - { - ++resulCount; - if((result->hasResultOfType(Result::SCALAR))&&(!scalarDone)) - { - stream << totalValue.arg(result->getResult(Result::SCALAR).toReal()) << endl; //.arg(m_command) - scalarDone=true; - } - else if(result->hasResultOfType(Result::DICE_LIST)) - { - - DiceResult* myDiceResult = dynamic_cast(result); - if(nullptr!=myDiceResult) - { - - QString resulStr; - quint64 face=0; - for(Die* die : myDiceResult->getResultList()) - { - if(!die->hasBeenDisplayed()) - { - resulStr+=QStringLiteral("%1").arg(die->getValue()); - die->displayed(); - face = die->getFaces(); - - - if(die->hasChildrenValue()) - { - resulStr+=QStringLiteral(" ["); - for(qint64 i : die->getListValue()) - { - resulStr+=QStringLiteral("%1 ").arg(i); - } - resulStr.remove(resulStr.size()-1,1); - resulStr+=QStringLiteral("]"); - } - resulStr+=QStringLiteral(", "); - } - } - resulStr.remove(resulStr.size()-2,2); - - if(!resulStr.isEmpty()) - { - stream << dieValue.arg(face).arg(resulStr); - } - - } - } - else if(result->hasResultOfType(Result::STRING)) - { - stream << result->getResult(Result::STRING).toString(); - } - - result = result->getPrevious(); - } - - QTextStream out(stdout); - out << str << "you rolled: " < DiceParser::getLastIntegerResults() { QList resultValues; @@ -551,7 +458,7 @@ void DiceParser::getDiceResultFromAllInstruction(QList& resu HighLightDice hlDice(die->getListValue(),die->isHighlighted(),die->getColor(), die->hasBeenDisplayed(),die->getFaces()); list.append(hlDice); } - nodeResult.insert(static_cast(faces),list); + nodeResult.insert(faces,list); } result = result->getPrevious(); } @@ -663,7 +570,7 @@ bool DiceParser::hasResultOfType(Result::RESULT_TYPE type, ExecutionNode* node, Result* result=next->getResult(); while((result!=nullptr)&&(!scalarDone)) { - if(result->hasResultOfType(type) && ((!notthelast)||(notthelast && (nullptr!=result->getPrevious())))) + if(result->hasResultOfType(type) && ((!notthelast)||(nullptr!=result->getPrevious()))) { scalarDone=true; } @@ -702,7 +609,7 @@ QList DiceParser::getSumOfDiceResult() } int DiceParser::getStartNodeCount() const { - return m_startNodes.size(); + return static_cast(m_startNodes.size()); } ExecutionNode* DiceParser::getLeafNode(ExecutionNode* start) { @@ -894,7 +801,7 @@ bool DiceParser::readInstructionList(QString& str) { latest = ParsingToolBox::getLatestNode(latest); } - keepParsing = (!str.isEmpty() & (before!=str)); + keepParsing = (!str.isEmpty() && (before!=str)); } } if( !str.isEmpty() && readInstructionOperator(str[0])) @@ -1058,7 +965,7 @@ bool DiceParser::readOption(QString& str,ExecutionNode* previous)//, DiceRollerNode* nodeTmp = dynamic_cast(previous); if(nullptr!=nodeTmp) { - previous = addExplodeDiceNode(nodeTmp->getFaces(),previous); + previous = addExplodeDiceNode(static_cast(nodeTmp->getFaces()),previous); } node = m_parsingToolbox->addSort(previous,ascending); diff --git a/diceparser.h b/diceparser.h index 8d06b44..0305dc7 100644 --- a/diceparser.h +++ b/diceparser.h @@ -36,7 +36,7 @@ #include "highlightdice.h" typedef QList ListDiceResult; -typedef QMap ExportedDiceResult; +typedef QMap ExportedDiceResult; class ExplodeDiceNode; /** -- cgit v1.2.3-70-g09d2