From c68e11bc6d7631185749aaf0c8d89147b3ac9cc9 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Wed, 10 Feb 2021 14:34:08 +0800 Subject: update backcall operator syntax, fix issue #31. --- src/MoonP/moon_parser.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/MoonP/moon_parser.cpp') diff --git a/src/MoonP/moon_parser.cpp b/src/MoonP/moon_parser.cpp index 63ffec7..f15492f 100644 --- a/src/MoonP/moon_parser.cpp +++ b/src/MoonP/moon_parser.cpp @@ -319,7 +319,7 @@ MoonParser::MoonParser() { unary_exp = *(Space >> unary_operator) >> expo_exp; BackcallOperator = expr("|>"); - backcall_value = White >> BackcallOperator >> *SpaceBreak >> unary_exp; + backcall_value = Space >> BackcallOperator >> *SpaceBreak >> unary_exp; backcall_exp = unary_exp >> *backcall_value; BinaryOperator = @@ -522,6 +522,8 @@ MoonParser::MoonParser() { fn_arrow_back = expr('<') >> set("-="); Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; + BackcallBody = Seperator >> Space >> BackcallOperator >> unary_exp >> *(+SpaceBreak >> CheckIndent >> Space >> BackcallOperator >> unary_exp); + ExpList = Seperator >> Exp >> *(sym(',') >> Exp); ExpListLow = Seperator >> Exp >> *(Space >> set(",;") >> Exp); @@ -562,14 +564,14 @@ MoonParser::MoonParser() { Import | While | Repeat | For | ForEach | Return | Local | Global | Export | Macro | Space >> BreakLoop | Label | Goto | Backcall | - LocalAttrib | ExpListAssign + LocalAttrib | BackcallBody | ExpListAssign ) >> Space >> -statement_appendix >> -statement_sep; Body = Space >> Break >> *EmptyLine >> InBlock | Statement; empty_line_stop = Space >> and_(Stop); - Line = CheckIndent >> Statement | empty_line_stop; + Line = CheckIndent >> Statement | and_(Space >> BackcallOperator) >> Advance >> ensure(Statement, PopIndent) | empty_line_stop; Block = Seperator >> Line >> *(+Break >> Line); Shebang = expr("#!") >> *(not_(Stop) >> Any); -- cgit v1.2.3-55-g6feb