From 502af415a7d72bd8229613056e5c5e1dd8ce518d Mon Sep 17 00:00:00 2001 From: Li Jin Date: Sun, 26 Apr 2020 16:07:18 +0800 Subject: add existential op support for with statement, add repeat until statement. --- src/MoonP/moon_parser.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/MoonP/moon_parser.cpp') diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 7de2a84..4f12a34 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp @@ -209,7 +209,7 @@ MoonParser::MoonParser() { WithExp = ExpList >> -Assign; - With = key("with") >> DisableDo >> ensure(WithExp, PopDo) >> -key("do") >> Body; + With = key("with") >> -existential_op >> DisableDo >> ensure(WithExp, PopDo) >> -key("do") >> Body; SwitchCase = key("when") >> ExpList >> -key("then") >> Body; SwitchElse = key("else") >> Body; @@ -231,6 +231,7 @@ MoonParser::MoonParser() { Unless = key("unless") >> Seperator >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; + Repeat = key("repeat") >> Body >> Break >> *EmptyLine >> CheckIndent >> key("until") >> Exp; for_step_value = sym(',') >> White >> Exp; for_args = Space >> Variable >> sym('=') >> Exp >> sym(',') >> White >> Exp >> -for_step_value; @@ -538,10 +539,9 @@ MoonParser::MoonParser() { statement_appendix = (if_line | unless_line | CompInner) >> Space; Statement = ( - Import | While | For | ForEach | - Return | Local | Global | Export | - Macro | Space >> BreakLoop | Label | - Goto | Backcall | ExpListAssign + Import | While | Repeat | For | ForEach | + Return | Local | Global | Export | Macro | + Space >> BreakLoop | Label | Goto | Backcall | ExpListAssign ) >> Space >> -statement_appendix; -- cgit v1.2.3-55-g6feb