From de55ac4c76ef3f6dbdc6fd2d03e3484bcfccdb0e Mon Sep 17 00:00:00 2001 From: Renaud G Date: Sat, 13 Feb 2021 12:37:44 +0100 Subject: Add replace value node. Move definition of CaseInfo struct. Fix small things from switchcasenode. --- parsingtoolbox.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'parsingtoolbox.cpp') diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp index 2656fca..d371e9b 100644 --- a/parsingtoolbox.cpp +++ b/parsingtoolbox.cpp @@ -48,6 +48,7 @@ #include "node/paintnode.h" #include "node/parenthesesnode.h" #include "node/repeaternode.h" +#include "node/replacevaluenode.h" #include "node/rerolldicenode.h" #include "node/scalaroperatornode.h" #include "node/sortresult.h" @@ -111,6 +112,7 @@ ParsingToolBox::ParsingToolBox() m_OptionOp.insert(QStringLiteral("b"), Bind); m_OptionOp.insert(QStringLiteral("o"), Occurences); m_OptionOp.insert(QStringLiteral("S"), SwitchCaseOption); + m_OptionOp.insert(QStringLiteral("T"), TransformOption); m_functionMap.insert({QStringLiteral("repeat"), REPEAT}); @@ -1768,6 +1770,15 @@ bool ParsingToolBox::readOption(QString& str, ExecutionNode* previous) //, node= scNode; } break; + case TransformOption: + { + auto scNode= new ReplaceValueNode(); + found= readReplaceValueNode(str, scNode); + previous->setNextNode(scNode); + if(found) + node= scNode; + } + break; case Bind: { BindNode* bindNode= new BindNode(); @@ -1963,6 +1974,26 @@ bool ParsingToolBox::readSwitchCaseNode(QString& str, SwitchCaseNode* node) return res; } +bool ParsingToolBox::readReplaceValueNode(QString& str, ReplaceValueNode* node) +{ + bool res= false; + bool hasInstructionBloc= false; + do + { + auto validator= readValidatorList(str); + ExecutionNode* exeNode= nullptr; + hasInstructionBloc= readBlocInstruction(str, exeNode); + if(hasInstructionBloc) + { + node->insertCase(exeNode, validator); + res= true; + } + + } while(hasInstructionBloc); + + return res; +} + bool ParsingToolBox::readBlocInstruction(QString& str, ExecutionNode*& resultnode) { if(str.startsWith('{')) -- cgit v1.2.3-70-g09d2