diff options
| author | 2021-02-13 12:37:44 +0100 | |
|---|---|---|
| committer | 2021-02-13 12:37:44 +0100 | |
| commit | de55ac4c76ef3f6dbdc6fd2d03e3484bcfccdb0e (patch) | |
| tree | 137ae58be5ed6e351221288924ad530adeb3d8f7 /parsingtoolbox.cpp | |
| parent | 8a54eb609bd278e87b8a3d6a9be42301778df18d (diff) | |
| download | OneRoll-de55ac4c76ef3f6dbdc6fd2d03e3484bcfccdb0e.tar.gz OneRoll-de55ac4c76ef3f6dbdc6fd2d03e3484bcfccdb0e.zip | |
Add replace value node.
Move definition of CaseInfo struct.
Fix small things from switchcasenode.
Diffstat (limited to 'parsingtoolbox.cpp')
| -rw-r--r-- | parsingtoolbox.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
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('{')) |