From 1ac32e671120d3b9db9e077ad4a2ac931ae3122f Mon Sep 17 00:00:00 2001 From: biver Date: Thu, 3 Mar 2022 22:58:39 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B2=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20IF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/classes/IoTScenario.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/classes/IoTScenario.cpp b/src/classes/IoTScenario.cpp index 970f07c5..a69bbe7e 100644 --- a/src/classes/IoTScenario.cpp +++ b/src/classes/IoTScenario.cpp @@ -260,8 +260,14 @@ class IfExprAST : public ExprAST { String _IDNames; public: - IfExprAST(ExprAST *cond, ExprAST *then, ExprAST *_else, String IDNames) - : Cond(cond), Then(then), Else(_else), _IDNames(IDNames) {} + IfExprAST(ExprAST *cond, ExprAST *then, ExprAST *_else, String *IDNames) + : Cond(cond), Then(then), Else(_else) { + if (IDNames) { + _IDNames = *IDNames; + //Serial.printf("eeeeeeeeeeeeee %s\n", _IDNames.c_str()); + } else _IDNames = ""; + Serial.printf("eeeeeeeeeeeeee\n"); + } bool hasEventIdName(String eventIdName) { Serial.printf("Call from BinaryExprAST _IDNames:%s\n", _IDNames.c_str()); @@ -579,7 +585,7 @@ public: getNextToken(); // Получаем then ExprAST *Then = ParseExpression(nullptr); - if (Then == 0) return 0; + if (!Then) return 0; //if (CurTok != tok_else) // return Error("expected else"); @@ -589,7 +595,7 @@ public: Else = ParseExpression(nullptr); } - return new IfExprAST(Cond, Then, Else, *IDNames); + return new IfExprAST(Cond, Then, Else, IDNames); } /// primary @@ -646,7 +652,7 @@ public: LHS = new BinaryExprAST(BinOp, LHS, RHS); } } - + /// expression /// ::= primary binoprhs @@ -682,7 +688,8 @@ public: //case ';': getNextToken(); break; // игнорируем верхнеуровневые точки с запятой. case tok_if: { String IDNames = ""; // накопитель встречающихся идентификаторов в условии - ScenarioElements.push_back(ParseExpression(&IDNames)); + ScenarioElements.push_back(ParseIfExpr(&IDNames)); + Serial.printf("vvvvvvvvvvvvvvvv %s", IDNames.c_str()); break; } default: getNextToken(); break;