From 801288edbed7cee6b2c499d1f283a1c79e87632c Mon Sep 17 00:00:00 2001 From: hama Date: Sat, 16 Aug 2014 08:54:50 +0200 Subject: [PATCH] dayly work --- rplcore/rplwriter.cpp | 3 +- rplexpr/rplastree.cpp | 166 +++++++++++++++++++++++++++++++- rplexpr/rplastree.hpp | 14 ++- rplexpr/rplmfparser.cpp | 56 ++++++++++- rplexpr/rplmfparser.hpp | 3 + test/rplmfparser/baseTest.txt | 4 +- test/rplmfparser/forC1.txt | 4 +- test/rplmfparser/forC2.txt | 2 +- test/rplmfparser/forIt1.txt | 2 +- test/rplmfparser/ifTest1.txt | 14 +-- test/rplmfparser/ifTest2.txt | 4 +- test/rplmfparser/meth2.txt | 10 +- test/rplmfparser/meth4.txt | 4 +- test/rplmfparser/methc1.txt | 8 +- test/rplmfparser/opTest1.txt | 24 ++--- test/rplmfparser/repeatTest.txt | 6 +- test/rplmfparser/whileTest.txt | 4 +- 17 files changed, 271 insertions(+), 57 deletions(-) diff --git a/rplcore/rplwriter.cpp b/rplcore/rplwriter.cpp index 4ff58d1..3ec9ead 100644 --- a/rplcore/rplwriter.cpp +++ b/rplcore/rplwriter.cpp @@ -152,7 +152,8 @@ RplFileWriter::RplFileWriter(const char* filename, const char* mode, FILE* additionalStream, const char* eoln) : m_fp(fopen(filename, mode)), m_name(filename), - m_eoln(eoln) + m_eoln(eoln), + m_additionalStream(additionalStream) { } diff --git a/rplexpr/rplastree.cpp b/rplexpr/rplastree.cpp index 9838f7d..8341069 100644 --- a/rplexpr/rplastree.cpp +++ b/rplexpr/rplastree.cpp @@ -1443,7 +1443,7 @@ void RplASNode6::setChild6(RplASItem* child6) * @param op the operator id * @param type the node type */ -RplASUnaryOp::RplASUnaryOp(int op, RplASItemType type) : +RplASUnaryOp::RplASUnaryOp(UnaryOp op, RplASItemType type) : RplASNode1(type), m_operator(op) { @@ -1535,13 +1535,47 @@ void RplASUnaryOp::dump(RplWriter& writer, int indent) char buffer[256]; writer.formatIndented(indent, "Unary %d op: %s (%d) expr: %d %s", m_id, - RplLexer::m_active->nameOfOp(m_operator).constData(), + nameOfOp(m_operator), m_operator, m_child == NULL ? 0 : m_child->id(), positionStr(buffer, sizeof buffer) ); if (m_child != NULL) m_child->dump(writer, indent + 1); } +/** + * @brief Returns the name (a string) of an unary operator. + * + * @param op the op to convert + * @return the name of the operator + */ +const char*RplASUnaryOp::nameOfOp(RplASUnaryOp::UnaryOp op) +{ + const char* rc; + switch (op){ + case UOP_PLUS: + rc="+"; + break; + case UOP_MINUS: + rc="-"; + break; + case UOP_LOGICAL_NOT: + rc="!"; + break; + case UOP_BIT_NOT: + rc="~"; + break; + case UOP_INC: + rc="++"; + break; + case UOP_DEC: + rc="--"; + break; + default: + throw RplException("unknown unary operator: %d", (int) op); + break; + } + return rc; +} /** @class RplASStatement rplastree.hpp "rplexpr/rplastree.hpp" @@ -2393,7 +2427,7 @@ void RplASBinaryOp::setOperator(BinOperator op) void RplASBinaryOp::dump(RplWriter& writer, int indent) { - const QByteArray& opName = RplLexer::m_active->nameOfOp(m_operator); + const QByteArray& opName = nameOfOp(m_operator); char buffer[256]; writer.formatIndented(indent, "BinOp id: %d op: %s (%d) left: %d right: %d %s", m_id, @@ -2447,6 +2481,132 @@ void RplASBinaryOp::assign(RplVMThread& thread) rValue.copyValue(value); } } +/** + * @brief Returns the name (a string) of a binary operator. + * + * @param op operator to convert + * + * @return the name of the operator + */ +const char* RplASBinaryOp::nameOfOp(RplASBinaryOp::BinOperator op) +{ + const char* rc; + switch (op){ + case BOP_ASSIGN: + rc = "="; + break; + case BOP_PLUS_ASSIGN: + rc = "+="; + break; + case BOP_MINUS_ASSIGN: + rc = "-="; + break; + case BOP_TIMES_ASSIGN: + rc = "*="; + break; + case BOP_DIV_ASSIGN: + rc = "/="; + break; + case BOP_MOD_ASSIGN: + rc = "%="; + break; + case BOP_POWER_ASSIGN: + rc = "**="; + break; + case BOP_LOG_OR_ASSIGN: + rc = "||="; + break; + case BOP_LOG_AND_ASSIGN: + rc = "&&="; + break; + case BOP_LOG_XOR_ASSIGN: + rc = "^^="; + break; + case BOP_BIT_OR_ASSIGN: + rc = "|="; + break; + case BOP_BIT_AND_ASSIGN: + rc = "&="; + break; + case BOP_BIT_XOR_ASSIGN: + rc = "^="; + break; + case BOP_LSHIFT_ASSIGN: + rc = "<<="; + break; + case BOP_LOG_RSHIFT_ASSIGN: + rc = ">>="; + break; + case BOP_ARTITH_RSHIFT_ASSIGN: + rc = ">>>="; + break; + case BOP_PLUS: + rc = "+"; + break; + case BOP_MINUS: + rc = "-"; + break; + case BOP_TIMES: + rc = "*"; + break; + case BOP_DIV: + rc = "/"; + break; + case BOP_MOD: + rc = "%"; + break; + case BOP_POWER: + rc = "**"; + break; + case BOP_LOG_OR: + rc = "||"; + break; + case BOP_LOG_AND: + rc = "&&"; + break; + case BOP_LOG_XOR: + rc = "^^"; + break; + case BOP_BIT_OR: + rc = "|"; + break; + case BOP_BIT_AND: + rc = "&"; + break; + case BOP_BIT_XOR: + rc = "^"; + break; + case BOP_LSHIFT: + rc = ""; break; + case BOP_LOG_RSHIFT: + rc = ">>"; + break; + case BOP_ARTITH_RSHIFT: + rc = ">>>"; + break; + case BOP_EQ: + rc = "=="; + break; + case BOP_NE: + rc = "!="; + break; + case BOP_LE: + rc = "<="; + break; + case BOP_LT: + rc = "<"; + break; + case BOP_GE: + rc = ">="; + break; + case BOP_GT: + rc = ">"; + break; + default: + throw RplException("unknown binary op %d", (int) op); + } + return rc; +} /** @class RplASMethod rplastree.hpp "rplexpr/rplastree.hpp" * diff --git a/rplexpr/rplastree.hpp b/rplexpr/rplastree.hpp index 06e8e8b..1916875 100644 --- a/rplexpr/rplastree.hpp +++ b/rplexpr/rplastree.hpp @@ -371,22 +371,25 @@ public: class RplASUnaryOp : public RplASNode1, RplASCalculable { public: - enum { + enum UnaryOp { UOP_UNDEF, UOP_PLUS, UOP_MINUS, UOP_LOGICAL_NOT, - UOP_BIT_NOT + UOP_BIT_NOT, + UOP_INC, + UOP_DEC }; public: - RplASUnaryOp(int op, RplASItemType type); + RplASUnaryOp(UnaryOp op, RplASItemType type); public: virtual void calc(RplVMThread& thread); int getOperator() const; void dump(RplWriter& writer, int indent); - +public: + static const char* nameOfOp(UnaryOp op); private: - int m_operator; + UnaryOp m_operator; }; class RplASBinaryOp : public RplASNode2, public RplASCalculable { @@ -446,6 +449,7 @@ public: void dump(RplWriter& writer, int indent); private: void assign(RplVMThread& thread); + static const char* nameOfOp(BinOperator op); private: BinOperator m_operator; }; diff --git a/rplexpr/rplmfparser.cpp b/rplexpr/rplmfparser.cpp index 5fadeca..406533c 100644 --- a/rplexpr/rplmfparser.cpp +++ b/rplexpr/rplmfparser.cpp @@ -508,6 +508,42 @@ RplASItem* RplMFParser::buildVarOrField(const QString& name, } return rc; } +/** + * @brief Converts a MF specific unary operator into one of AST. + * + * @param op operator known by MF parser + * + * @return operator known by the abstract syntax tree + */ +RplASUnaryOp::UnaryOp RplMFParser::convertUnaryOp(int op) +{ + RplASUnaryOp::UnaryOp rc; + switch(op){ + case O_PLUS: + rc = RplASUnaryOp::UOP_PLUS; + break; + case O_MINUS: + rc = RplASUnaryOp::UOP_MINUS; + break; + case O_NOT: + rc = RplASUnaryOp::UOP_LOGICAL_NOT; + break; + case O_BIT_NOT: + rc = RplASUnaryOp::UOP_BIT_NOT; + break; + case O_INC: + rc = RplASUnaryOp::UOP_INC; + break; + case O_DEC: + rc = RplASUnaryOp::UOP_DEC; + break; + default: + throw RplException("unknown unary operator %d", op); + break; + } + return rc; +} + /** * @brief Parses an operand. * @@ -556,7 +592,8 @@ RplASItem* RplMFParser::parseOperand(int level, RplASItem* parent) "')' expected", "(", startPosition); } } else if (IS_UNARY_OP(opId)){ - RplASUnaryOp* op = new RplASUnaryOp(token->id(), AST_PRE_UNARY_OP); + RplASUnaryOp* op = new RplASUnaryOp(convertUnaryOp(token->id()), + AST_PRE_UNARY_OP); op->setPosition(m_lexer.currentPosition()); op->setChild(parseOperand(level)); readNext = false; @@ -621,7 +658,8 @@ RplASItem* RplMFParser::parseOperand(int level, RplASItem* parent) dynamic_cast(rc)->setChild(indexExpr); } else { if (token->id() == O_INC || token->id() == O_DEC){ - RplASUnaryOp* op = new RplASUnaryOp(token->id(), + RplASUnaryOp* op = new RplASUnaryOp(convertUnaryOp( + token->id()), AST_POST_UNARY_OP); op->setChild(rc); rc = op; @@ -651,8 +689,15 @@ RplASItem* RplMFParser::parseOperand(int level, RplASItem* parent) } return rc; } -RplASBinaryOp::BinOperator encodeBinOp(int op){ - RplASBinaryOp::BinOperator rc = RplASBinaryOp::BOP_UNDEF; +/** + * @brief Converts a MF specific binary operator into one of AST. + * + * @param op operator known by MF parser + * + * @return operator known by the abstract syntax tree + */ +RplASBinaryOp::BinOperator RplMFParser::convertBinaryOp(int op){ + RplASBinaryOp::BinOperator rc; switch(op){ case RplMFParser::O_ASSIGN: rc = RplASBinaryOp::BOP_ASSIGN; @@ -751,6 +796,7 @@ RplASBinaryOp::BinOperator encodeBinOp(int op){ rc = RplASBinaryOp::BOP_ARTITH_RSHIFT; break; default: + throw RplException("unknown binary operator %d", op); break; } return rc; @@ -788,7 +834,7 @@ RplASItem* RplMFParser::parseExpr(int depth){ if (IS_BINARY_OP(opId)){ RplASBinaryOp* op = new RplASBinaryOp(); op->setPosition(m_lexer.currentPosition()); - op->setOperator(encodeBinOp(opId)); + op->setOperator(convertBinaryOp(opId)); int prio = m_lexer.prioOfOp(token->id()); if (prio < lastPrio diff --git a/rplexpr/rplmfparser.hpp b/rplexpr/rplmfparser.hpp index 0530f47..3be8e31 100644 --- a/rplexpr/rplmfparser.hpp +++ b/rplexpr/rplmfparser.hpp @@ -94,6 +94,9 @@ protected: RplASItem* parent); RplASExprStatement*parseParameterList(); RplASItem* parseLocalVar(); +protected: + static RplASBinaryOp::BinOperator convertBinaryOp(int op); + static RplASUnaryOp::UnaryOp convertUnaryOp(int op); private: ///syntax token builder. /// Note: the super class contains a reference with the same name diff --git a/test/rplmfparser/baseTest.txt b/test/rplmfparser/baseTest.txt index 10ff423..5577d25 100644 --- a/test/rplmfparser/baseTest.txt +++ b/test/rplmfparser/baseTest.txt @@ -2,8 +2,8 @@ = (module) parent: $global == Body: Expr id: 6 expr: 2 succ: 0 :1:1 - BinOp id: 2 op: + (26) left: 1 right: 4 :1:1 + BinOp id: 2 op: + (17) left: 1 right: 4 :1:1 const id: 1 value: 2 :0:0 - BinOp id: 4 op: * (30) left: 3 right: 5 :1:3 + BinOp id: 4 op: * (19) left: 3 right: 5 :1:3 const id: 3 value: 3 :1:2 const id: 5 value: 4 :1:4 diff --git a/test/rplmfparser/forC1.txt b/test/rplmfparser/forC1.txt index 82ef81d..5a5517a 100644 --- a/test/rplmfparser/forC1.txt +++ b/test/rplmfparser/forC1.txt @@ -13,9 +13,9 @@ forC id: 4 var: 3 from: 5 to: 6 step: 7 body: 12 succ: 0 :1:7 namedValue b id: 3 attr: 0x0 :2:4 const id: 5 value: 10 :2:11 const id: 6 value: 1 :2:17 - Unary 7 op: - (27) expr: 8 :2:24 + Unary 7 op: - (2) expr: 8 :2:24 const id: 8 value: 2 :2:25 Expr id: 12 expr: 10 succ: 0 :3:2 - BinOp id: 10 op: += (6) left: 9 right: 11 :3:2 + BinOp id: 10 op: += (2) left: 9 right: 11 :3:2 namedValue a id: 9 attr: 0x0 :3:2 const id: 11 value: 1 :3:5 diff --git a/test/rplmfparser/forC2.txt b/test/rplmfparser/forC2.txt index 1ad1331..4db7cf7 100644 --- a/test/rplmfparser/forC2.txt +++ b/test/rplmfparser/forC2.txt @@ -9,6 +9,6 @@ varDef a id: 2 namedValue: 1 value: 0 succ: 3 :1:4 forC id: 3 var: 0 from: 0 to: 4 step: 0 body: 8 succ: 0 :1:7 const id: 4 value: 10 :1:14 Expr id: 8 expr: 6 succ: 0 :1:22 - BinOp id: 6 op: += (6) left: 5 right: 7 :1:22 + BinOp id: 6 op: += (2) left: 5 right: 7 :1:22 namedValue a id: 5 attr: 0x0 :1:22 const id: 7 value: 1 :1:25 diff --git a/test/rplmfparser/forIt1.txt b/test/rplmfparser/forIt1.txt index b3198fd..66071de 100644 --- a/test/rplmfparser/forIt1.txt +++ b/test/rplmfparser/forIt1.txt @@ -13,6 +13,6 @@ forIt id: 4 var: 3 set: 5 body: 9 succ: 0 :1:7 namedValue x id: 3 attr: 0x0 :2:4 namedValue a id: 5 attr: 0x0 :2:11 Expr id: 9 expr: 7 succ: 0 :3:2 - BinOp id: 7 op: += (6) left: 6 right: 8 :3:2 + BinOp id: 7 op: += (2) left: 6 right: 8 :3:2 namedValue a id: 6 attr: 0x0 :3:2 const id: 8 value: 1 :3:5 diff --git a/test/rplmfparser/ifTest1.txt b/test/rplmfparser/ifTest1.txt index 136e306..1a01773 100644 --- a/test/rplmfparser/ifTest1.txt +++ b/test/rplmfparser/ifTest1.txt @@ -17,24 +17,24 @@ varDef a id: 2 namedValue: 1 value: 0 succ: 4 :1:4 varDef b id: 4 namedValue: 3 value: 0 succ: 10 :2:4 namedValue b id: 3 attr: 0x0 :2:4 Expr id: 10 expr: 6 succ: 11 :3:2 - BinOp id: 6 op: = (5) left: 5 right: 8 :3:2 + BinOp id: 6 op: = (1) left: 5 right: 8 :3:2 namedValue a id: 5 attr: 0x0 :3:2 - BinOp id: 8 op: = (5) left: 7 right: 9 :3:6 + BinOp id: 8 op: = (1) left: 7 right: 9 :3:6 namedValue b id: 7 attr: 0x0 :3:6 const id: 9 value: 2 :3:8 If id: 11 condition: 13 then: 20 else: 26 succ: 0:3:11 - BinOp id: 13 op: < (21) left: 12 right: 14 :4:6 + BinOp id: 13 op: < (35) left: 12 right: 14 :4:6 const id: 12 value: 11 :4:3 const id: 14 value: 12 :4:8 Expr id: 20 expr: 16 succ: 0 :5:7 - BinOp id: 16 op: = (5) left: 15 right: 18 :5:7 + BinOp id: 16 op: = (1) left: 15 right: 18 :5:7 namedValue a id: 15 attr: 0x0 :5:7 - BinOp id: 18 op: * (30) left: 17 right: 19 :5:12 + BinOp id: 18 op: * (19) left: 17 right: 19 :5:12 const id: 17 value: 13 :5:9 const id: 19 value: 14 :5:14 Expr id: 26 expr: 22 succ: 0 :6:7 - BinOp id: 22 op: = (5) left: 21 right: 24 :6:7 + BinOp id: 22 op: = (1) left: 21 right: 24 :6:7 namedValue a id: 21 attr: 0x0 :6:7 - BinOp id: 24 op: / (28) left: 23 right: 25 :6:12 + BinOp id: 24 op: / (20) left: 23 right: 25 :6:12 const id: 23 value: 15 :6:9 const id: 25 value: 16 :6:14 diff --git a/test/rplmfparser/ifTest2.txt b/test/rplmfparser/ifTest2.txt index 26a5e66..67fa8f9 100644 --- a/test/rplmfparser/ifTest2.txt +++ b/test/rplmfparser/ifTest2.txt @@ -10,10 +10,10 @@ varDef x id: 2 namedValue: 1 value: 0 succ: 3 :1:4 varDef x id: 2 namedValue: 1 value: 0 succ: 3 :1:4 namedValue x id: 1 attr: 0x0 :1:4 If id: 3 condition: 5 then: 10 else: 0 succ: 0:1:7 - BinOp id: 5 op: < (21) left: 4 right: 6 :2:5 + BinOp id: 5 op: < (35) left: 4 right: 6 :2:5 const id: 4 value: 7 :2:3 const id: 6 value: 6 :2:7 Expr id: 10 expr: 8 succ: 0 :3:7 - BinOp id: 8 op: = (5) left: 7 right: 9 :3:7 + BinOp id: 8 op: = (1) left: 7 right: 9 :3:7 namedValue x id: 7 attr: 0x0 :3:7 const id: 9 value: '123' :3:9 diff --git a/test/rplmfparser/meth2.txt b/test/rplmfparser/meth2.txt index c29148d..cca30a2 100644 --- a/test/rplmfparser/meth2.txt +++ b/test/rplmfparser/meth2.txt @@ -10,21 +10,21 @@ Method fac() id: 1 parent: args: 4 body: 6 :0:55 varDef rc id: 6 namedValue: 5 value: 0 succ: 7 :2:4 namedValue rc id: 5 attr: 0x0 :2:4 If id: 7 condition: 9 then: 14 else: 24 succ: 26:2:8 - BinOp id: 9 op: <= (23) left: 8 right: 10 :2:14 + BinOp id: 9 op: <= (34) left: 8 right: 10 :2:14 namedValue rc id: 8 attr: 0x0 :2:14 const id: 10 value: 1 :2:17 Expr id: 14 expr: 12 succ: 0 :2:27 - BinOp id: 12 op: = (5) left: 11 right: 13 :2:27 + BinOp id: 12 op: = (1) left: 11 right: 13 :2:27 namedValue rc id: 11 attr: 0x0 :2:27 const id: 13 value: 1 :2:29 Expr id: 24 expr: 16 succ: 0 :2:39 - BinOp id: 16 op: = (5) left: 15 right: 18 :2:39 + BinOp id: 16 op: = (1) left: 15 right: 18 :2:39 namedValue rc id: 15 attr: 0x0 :2:39 - BinOp id: 18 op: * (30) left: 17 right: 19 :2:42 + BinOp id: 18 op: * (19) left: 17 right: 19 :2:42 namedValue n id: 17 attr: 0x0 :2:42 call fac Id: 19 args: 23 parent: 0 succ: 0 :2:46 arg 1 id: 23 expr: 21 succ: 0 - BinOp id: 21 op: - (27) left: 20 right: 22 :2:48 + BinOp id: 21 op: - (18) left: 20 right: 22 :2:48 namedValue n id: 20 attr: 0x0 :2:48 const id: 22 value: 1 :2:49 Expr id: 26 expr: 25 succ: 0 :3:3 diff --git a/test/rplmfparser/meth4.txt b/test/rplmfparser/meth4.txt index ac39b73..3414ab6 100644 --- a/test/rplmfparser/meth4.txt +++ b/test/rplmfparser/meth4.txt @@ -32,11 +32,11 @@ Method max() id: 1 parent: args: 4 body: 40 :0:4 namedValue rc id: 18 attr: 0x0 :3:5 namedValue a id: 20 attr: 0x0 :3:11 If id: 21 condition: 23 then: 28 else: 0 succ: 30:3:13 - BinOp id: 23 op: < (21) left: 22 right: 24 :4:5 + BinOp id: 23 op: < (35) left: 22 right: 24 :4:5 namedValue a id: 22 attr: 0x0 :4:5 namedValue b id: 24 attr: 0x0 :4:9 Expr id: 28 expr: 26 succ: 0 :4:17 - BinOp id: 26 op: = (5) left: 25 right: 27 :4:17 + BinOp id: 26 op: = (1) left: 25 right: 27 :4:17 namedValue rc id: 25 attr: 0x0 :4:17 namedValue b id: 27 attr: 0x0 :4:20 Expr id: 30 expr: 29 succ: 0 :5:3 diff --git a/test/rplmfparser/methc1.txt b/test/rplmfparser/methc1.txt index e418cbb..afb30ca 100644 --- a/test/rplmfparser/methc1.txt +++ b/test/rplmfparser/methc1.txt @@ -12,14 +12,14 @@ Expr id: 6 expr: 3 succ: 20 :2:3 Expr id: 20 expr: 7 succ: 0 :3:3 call max Id: 7 args: 13 parent: 0 succ: 0 :3:3 arg 1 id: 13 expr: 9 succ: 19 - BinOp id: 9 op: + (26) left: 8 right: 11 :3:5 + BinOp id: 9 op: + (17) left: 8 right: 11 :3:5 const id: 8 value: 1 :3:4 - BinOp id: 11 op: * (30) left: 10 right: 12 :3:7 + BinOp id: 11 op: * (19) left: 10 right: 12 :3:7 const id: 10 value: 2 :3:6 const id: 12 value: 3 :3:8 arg 2 id: 19 expr: 15 succ: 0 - BinOp id: 15 op: ** (31) left: 14 right: 17 :3:11 + BinOp id: 15 op: ** (22) left: 14 right: 17 :3:11 const id: 14 value: 4 :3:10 - BinOp id: 17 op: - (27) left: 16 right: 18 :3:15 + BinOp id: 17 op: - (18) left: 16 right: 18 :3:15 const id: 16 value: 5 :3:14 const id: 18 value: 4 :3:16 diff --git a/test/rplmfparser/opTest1.txt b/test/rplmfparser/opTest1.txt index b632366..91b1fc3 100644 --- a/test/rplmfparser/opTest1.txt +++ b/test/rplmfparser/opTest1.txt @@ -20,30 +20,30 @@ varDef b id: 5 namedValue: 4 value: 6 succ: 9 :2:4 namedValue b id: 4 attr: 0x0 :2:4 const id: 6 value: 100 :2:8 Expr id: 9 expr: 7 succ: 12 :2:13 - Unary 7 op: -- (41) expr: 8 :2:13 + Unary 7 op: -- (6) expr: 8 :2:13 namedValue a id: 8 attr: 0x0 :3:3 Expr id: 12 expr: 11 succ: 22 - Unary 11 op: ++ (40) expr: 10 + Unary 11 op: ++ (5) expr: 10 namedValue b id: 10 attr: 0x0 :4:1 Expr id: 22 expr: 15 succ: 34 :5:3 - BinOp id: 15 op: * (30) left: 14 right: 18 :5:3 - Unary 14 op: -- (41) expr: 13 + BinOp id: 15 op: * (19) left: 14 right: 18 :5:3 + Unary 14 op: -- (6) expr: 13 namedValue a id: 13 attr: 0x0 :5:1 - BinOp id: 18 op: ** (31) left: 16 right: 20 :5:7 - Unary 16 op: ++ (40) expr: 17 :5:4 + BinOp id: 18 op: ** (22) left: 16 right: 20 :5:7 + Unary 16 op: ++ (5) expr: 17 :5:4 namedValue b id: 17 attr: 0x0 :5:7 - BinOp id: 20 op: - (27) left: 19 right: 21 :5:11 + BinOp id: 20 op: - (18) left: 19 right: 21 :5:11 const id: 19 value: 8 :5:10 const id: 21 value: 3 :5:12 Expr id: 34 expr: 24 succ: 0 :6:1 - BinOp id: 24 op: = (5) left: 23 right: 26 :6:1 + BinOp id: 24 op: = (1) left: 23 right: 26 :6:1 namedValue a id: 23 attr: 0x0 :6:1 - BinOp id: 26 op: = (5) left: 25 right: 28 :6:3 + BinOp id: 26 op: = (1) left: 25 right: 28 :6:3 namedValue b id: 25 attr: 0x0 :6:3 - BinOp id: 28 op: + (26) left: 27 right: 32 :6:6 + BinOp id: 28 op: + (17) left: 27 right: 32 :6:6 namedValue a id: 27 attr: 0x0 :6:6 - BinOp id: 32 op: * (30) left: 30 right: 33 :6:12 - BinOp id: 30 op: - (27) left: 29 right: 31 :6:9 + BinOp id: 32 op: * (19) left: 30 right: 33 :6:12 + BinOp id: 30 op: - (18) left: 29 right: 31 :6:9 namedValue b id: 29 attr: 0x0 :6:9 const id: 31 value: 2 :6:10 const id: 33 value: 3 :6:13 diff --git a/test/rplmfparser/repeatTest.txt b/test/rplmfparser/repeatTest.txt index 1d1818e..cf15252 100644 --- a/test/rplmfparser/repeatTest.txt +++ b/test/rplmfparser/repeatTest.txt @@ -10,11 +10,11 @@ varDef a id: 2 namedValue: 1 value: 0 succ: 3 :1:4 varDef a id: 2 namedValue: 1 value: 0 succ: 3 :1:4 namedValue a id: 1 attr: 0x0 :1:4 repeat id: 3 condition: 8 body: 6 succ: 0 :1:7 - BinOp id: 8 op: != (20) left: 7 right: 10 :4:8 + BinOp id: 8 op: != (33) left: 7 right: 10 :4:8 namedValue a id: 7 attr: 0x0 :4:8 - BinOp id: 10 op: * (30) left: 9 right: 11 :4:13 + BinOp id: 10 op: * (19) left: 9 right: 11 :4:13 const id: 9 value: 2 :4:11 const id: 11 value: 3 :4:15 Expr id: 6 expr: 5 succ: 0 - Unary 5 op: ++ (40) expr: 4 + Unary 5 op: ++ (5) expr: 4 namedValue a id: 4 attr: 0x0 :3:1 diff --git a/test/rplmfparser/whileTest.txt b/test/rplmfparser/whileTest.txt index 44bccb1..64c22dc 100644 --- a/test/rplmfparser/whileTest.txt +++ b/test/rplmfparser/whileTest.txt @@ -12,10 +12,10 @@ varDef a id: 2 namedValue: 1 value: 3 succ: 4 :1:4 namedValue a id: 1 attr: 0x0 :1:4 const id: 3 value: 20 :1:8 while id: 4 condition: 6 body: 11 succ: 0 :1:12 - BinOp id: 6 op: < (21) left: 5 right: 7 :2:8 + BinOp id: 6 op: < (35) left: 5 right: 7 :2:8 const id: 5 value: 3 :2:6 const id: 7 value: 5 :2:10 Expr id: 11 expr: 9 succ: 0 :3:3 - BinOp id: 9 op: = (5) left: 8 right: 10 :3:3 + BinOp id: 9 op: = (1) left: 8 right: 10 :3:3 namedValue a id: 8 attr: 0x0 :3:3 const id: 10 value: 7 :3:5 -- 2.39.5