diff options
author | Li Jin <dragon-fly@qq.com> | 2021-02-10 14:34:08 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-02-10 20:50:03 +0800 |
commit | c68e11bc6d7631185749aaf0c8d89147b3ac9cc9 (patch) | |
tree | e91306fa43513f7a66022ba16abbc224a91c8bd5 /src/MoonP/moon_parser.cpp | |
parent | 9f622c5bbd9cfb7e66a9fd3c371461af4249d566 (diff) | |
download | yuescript-c68e11bc6d7631185749aaf0c8d89147b3ac9cc9.tar.gz yuescript-c68e11bc6d7631185749aaf0c8d89147b3ac9cc9.tar.bz2 yuescript-c68e11bc6d7631185749aaf0c8d89147b3ac9cc9.zip |
update backcall operator syntax, fix issue #31.
Diffstat (limited to 'src/MoonP/moon_parser.cpp')
-rw-r--r-- | src/MoonP/moon_parser.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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() { | |||
319 | unary_exp = *(Space >> unary_operator) >> expo_exp; | 319 | unary_exp = *(Space >> unary_operator) >> expo_exp; |
320 | 320 | ||
321 | BackcallOperator = expr("|>"); | 321 | BackcallOperator = expr("|>"); |
322 | backcall_value = White >> BackcallOperator >> *SpaceBreak >> unary_exp; | 322 | backcall_value = Space >> BackcallOperator >> *SpaceBreak >> unary_exp; |
323 | backcall_exp = unary_exp >> *backcall_value; | 323 | backcall_exp = unary_exp >> *backcall_value; |
324 | 324 | ||
325 | BinaryOperator = | 325 | BinaryOperator = |
@@ -522,6 +522,8 @@ MoonParser::MoonParser() { | |||
522 | fn_arrow_back = expr('<') >> set("-="); | 522 | fn_arrow_back = expr('<') >> set("-="); |
523 | Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; | 523 | Backcall = -FnArgsDef >> Space >> fn_arrow_back >> Space >> ChainValue; |
524 | 524 | ||
525 | BackcallBody = Seperator >> Space >> BackcallOperator >> unary_exp >> *(+SpaceBreak >> CheckIndent >> Space >> BackcallOperator >> unary_exp); | ||
526 | |||
525 | ExpList = Seperator >> Exp >> *(sym(',') >> Exp); | 527 | ExpList = Seperator >> Exp >> *(sym(',') >> Exp); |
526 | ExpListLow = Seperator >> Exp >> *(Space >> set(",;") >> Exp); | 528 | ExpListLow = Seperator >> Exp >> *(Space >> set(",;") >> Exp); |
527 | 529 | ||
@@ -562,14 +564,14 @@ MoonParser::MoonParser() { | |||
562 | Import | While | Repeat | For | ForEach | | 564 | Import | While | Repeat | For | ForEach | |
563 | Return | Local | Global | Export | Macro | | 565 | Return | Local | Global | Export | Macro | |
564 | Space >> BreakLoop | Label | Goto | Backcall | | 566 | Space >> BreakLoop | Label | Goto | Backcall | |
565 | LocalAttrib | ExpListAssign | 567 | LocalAttrib | BackcallBody | ExpListAssign |
566 | ) >> Space >> | 568 | ) >> Space >> |
567 | -statement_appendix >> -statement_sep; | 569 | -statement_appendix >> -statement_sep; |
568 | 570 | ||
569 | Body = Space >> Break >> *EmptyLine >> InBlock | Statement; | 571 | Body = Space >> Break >> *EmptyLine >> InBlock | Statement; |
570 | 572 | ||
571 | empty_line_stop = Space >> and_(Stop); | 573 | empty_line_stop = Space >> and_(Stop); |
572 | Line = CheckIndent >> Statement | empty_line_stop; | 574 | Line = CheckIndent >> Statement | and_(Space >> BackcallOperator) >> Advance >> ensure(Statement, PopIndent) | empty_line_stop; |
573 | Block = Seperator >> Line >> *(+Break >> Line); | 575 | Block = Seperator >> Line >> *(+Break >> Line); |
574 | 576 | ||
575 | Shebang = expr("#!") >> *(not_(Stop) >> Any); | 577 | Shebang = expr("#!") >> *(not_(Stop) >> Any); |