+Expr getExpr(TocParser::NonOpExprContext * ctx) {\r
+ Expr result;\r
+ if (ctx->funcCall() != nullptr) {\r
+ result.type = ExprType::Call;\r
+ for (auto e : ctx->funcCall()->expr())\r
+ result._call.arguments.push_back(getExpr(e));\r
+ result._call.functionName = ctx->funcCall()->funcName()->NAME()->toString();\r
+ }\r
+ if (ctx->literal() != nullptr) {\r
+ result.type = ExprType::Literal;\r
+ result._literal.i = atoi(ctx->literal()->INTLIT()->toString().c_str());\r
+ }\r
+ if (ctx->identifier() != nullptr) {\r
+ result.type = ExprType::Variable;\r
+ result._variable.name = ctx->identifier()->varName()->NAME()->toString();\r
+ }\r
+ if (ctx->subscript() != nullptr) {\r
+ result.type = ExprType::Brackets;\r
+ result._brackets.lexpr = std::make_unique<Expr>(getExpr(ctx->subscript()->nonSubscriptExpr()));\r
+ result._brackets.rexpr = std::make_unique<Expr>(getExpr(ctx->subscript()->expr()));\r
+ }\r
+ if (ctx->memberAccess() != nullptr) {\r
+ result.type = ExprType::Dot;\r
+ Expr e; e.type = ExprType::Variable; e._variable.name = ctx->memberAccess()->identifier(0)->varName()->NAME()->toString();\r
+ result._dot.lexpr = std::make_unique<Expr>(e);\r
+ result._dot.name = ctx->memberAccess()->identifier(1)->varName()->NAME()->toString();\r
+ }\r
+ return result;\r
+}\r
+Expr getExpr(TocParser::NonSubscriptExprContext * ctx) {\r
+ Expr result;\r
+ if (ctx->funcCall() != nullptr) {\r
+ result.type = ExprType::Call;\r
+ for (auto e : ctx->funcCall()->expr())\r
+ result._call.arguments.push_back(getExpr(e));\r
+ result._call.functionName = ctx->funcCall()->funcName()->NAME()->toString();\r
+ }\r
+ if (ctx->literal() != nullptr) {\r
+ result.type = ExprType::Literal;\r
+ result._literal.i = atoi(ctx->literal()->INTLIT()->toString().c_str());\r
+ }\r
+ if (ctx->identifier() != nullptr) {\r
+ result.type = ExprType::Variable;\r
+ result._variable.name = ctx->identifier()->varName()->NAME()->toString();\r
+ }\r
+ if (ctx->memberAccess() != nullptr) {\r
+ result.type = ExprType::Dot;\r
+ Expr e; e.type = ExprType::Variable; e._variable.name = ctx->memberAccess()->identifier(0)->varName()->NAME()->toString();\r
+ result._dot.lexpr = std::make_unique<Expr>(e);\r
+ result._dot.name = ctx->memberAccess()->identifier(1)->varName()->NAME()->toString();\r
+ }\r
+ return result;\r
+}\r