diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-04-26 16:07:18 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-04-26 16:07:18 +0800 |
| commit | 502af415a7d72bd8229613056e5c5e1dd8ce518d (patch) | |
| tree | e2416c5acd119132c40cd41b8f587851c7f9d33e /src/MoonP/moon_parser.cpp | |
| parent | feac3c1cba6ca95b911240217f74a494680cd057 (diff) | |
| download | yuescript-502af415a7d72bd8229613056e5c5e1dd8ce518d.tar.gz yuescript-502af415a7d72bd8229613056e5c5e1dd8ce518d.tar.bz2 yuescript-502af415a7d72bd8229613056e5c5e1dd8ce518d.zip | |
add existential op support for with statement, add repeat until statement.
Diffstat (limited to '')
| -rw-r--r-- | src/MoonP/moon_parser.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
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() { | |||
| 209 | 209 | ||
| 210 | WithExp = ExpList >> -Assign; | 210 | WithExp = ExpList >> -Assign; |
| 211 | 211 | ||
| 212 | With = key("with") >> DisableDo >> ensure(WithExp, PopDo) >> -key("do") >> Body; | 212 | With = key("with") >> -existential_op >> DisableDo >> ensure(WithExp, PopDo) >> -key("do") >> Body; |
| 213 | SwitchCase = key("when") >> ExpList >> -key("then") >> Body; | 213 | SwitchCase = key("when") >> ExpList >> -key("then") >> Body; |
| 214 | SwitchElse = key("else") >> Body; | 214 | SwitchElse = key("else") >> Body; |
| 215 | 215 | ||
| @@ -231,6 +231,7 @@ MoonParser::MoonParser() { | |||
| 231 | Unless = key("unless") >> Seperator >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; | 231 | Unless = key("unless") >> Seperator >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; |
| 232 | 232 | ||
| 233 | While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; | 233 | While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; |
| 234 | Repeat = key("repeat") >> Body >> Break >> *EmptyLine >> CheckIndent >> key("until") >> Exp; | ||
| 234 | 235 | ||
| 235 | for_step_value = sym(',') >> White >> Exp; | 236 | for_step_value = sym(',') >> White >> Exp; |
| 236 | for_args = Space >> Variable >> sym('=') >> Exp >> sym(',') >> White >> Exp >> -for_step_value; | 237 | for_args = Space >> Variable >> sym('=') >> Exp >> sym(',') >> White >> Exp >> -for_step_value; |
| @@ -538,10 +539,9 @@ MoonParser::MoonParser() { | |||
| 538 | 539 | ||
| 539 | statement_appendix = (if_line | unless_line | CompInner) >> Space; | 540 | statement_appendix = (if_line | unless_line | CompInner) >> Space; |
| 540 | Statement = ( | 541 | Statement = ( |
| 541 | Import | While | For | ForEach | | 542 | Import | While | Repeat | For | ForEach | |
| 542 | Return | Local | Global | Export | | 543 | Return | Local | Global | Export | Macro | |
| 543 | Macro | Space >> BreakLoop | Label | | 544 | Space >> BreakLoop | Label | Goto | Backcall | ExpListAssign |
| 544 | Goto | Backcall | ExpListAssign | ||
| 545 | ) >> Space >> | 545 | ) >> Space >> |
| 546 | -statement_appendix; | 546 | -statement_appendix; |
| 547 | 547 | ||
