aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/MoonP/moon_ast.h3
-rw-r--r--src/MoonP/moon_compiler.cpp1
-rw-r--r--src/MoonP/moon_parser.cpp4
3 files changed, 5 insertions, 3 deletions
diff --git a/src/MoonP/moon_ast.h b/src/MoonP/moon_ast.h
index f8d2099..e71afe9 100644
--- a/src/MoonP/moon_ast.h
+++ b/src/MoonP/moon_ast.h
@@ -565,8 +565,9 @@ AST_END(ExpListAssign)
565 565
566AST_NODE(if_else_line, "if_else_line"_id) 566AST_NODE(if_else_line, "if_else_line"_id)
567 ast_ptr<true, Exp_t> condition; 567 ast_ptr<true, Exp_t> condition;
568 ast_ptr<false, Assign_t> assign;
568 ast_sel<false, Exp_t, default_value_t> elseExpr; 569 ast_sel<false, Exp_t, default_value_t> elseExpr;
569 AST_MEMBER(if_else_line, &condition, &elseExpr) 570 AST_MEMBER(if_else_line, &condition, &assign, &elseExpr)
570AST_END(if_else_line) 571AST_END(if_else_line)
571 572
572AST_NODE(unless_line, "unless_line"_id) 573AST_NODE(unless_line, "unless_line"_id)
diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp
index b1770fb..4723af4 100644
--- a/src/MoonP/moon_compiler.cpp
+++ b/src/MoonP/moon_compiler.cpp
@@ -601,6 +601,7 @@ private:
601 601
602 auto ifCond = x->new_ptr<IfCond_t>(); 602 auto ifCond = x->new_ptr<IfCond_t>();
603 ifCond->condition.set(if_else_line->condition); 603 ifCond->condition.set(if_else_line->condition);
604 ifCond->assign.set(if_else_line->assign);
604 ifNode->nodes.push_back(ifCond); 605 ifNode->nodes.push_back(ifCond);
605 606
606 auto stmt = x->new_ptr<Statement_t>(); 607 auto stmt = x->new_ptr<Statement_t>();
diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp
index d3c0ed2..6d1b86c 100644
--- a/src/MoonP/moon_parser.cpp
+++ b/src/MoonP/moon_parser.cpp
@@ -198,7 +198,7 @@ rule IfCond = Exp >> -Assign;
198rule IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> key("elseif") >> IfCond >> -key("then") >> Body; 198rule IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> key("elseif") >> IfCond >> -key("then") >> Body;
199rule IfElse = -(Break >> *EmptyLine >> CheckIndent) >> key("else") >> Body; 199rule IfElse = -(Break >> *EmptyLine >> CheckIndent) >> key("else") >> Body;
200rule If = key("if") >> Seperator >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; 200rule If = key("if") >> Seperator >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse;
201rule Unless = key("unless") >> Seperator >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; 201rule Unless = key("unless") >> Seperator >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse;
202 202
203rule While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; 203rule While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body;
204 204
@@ -510,7 +510,7 @@ rule SimpleValue =
510 510
511rule ExpListAssign = ExpList >> -(Update | Assign); 511rule ExpListAssign = ExpList >> -(Update | Assign);
512 512
513rule if_else_line = key("if") >> Exp >> (key("else") >> Exp | default_value); 513rule if_else_line = key("if") >> Exp >> -Assign >> (key("else") >> Exp | default_value);
514rule unless_line = key("unless") >> Exp; 514rule unless_line = key("unless") >> Exp;
515 515
516rule statement_appendix = (if_else_line | unless_line | CompInner) >> Space; 516rule statement_appendix = (if_else_line | unless_line | CompInner) >> Space;