diff options
Diffstat (limited to 'src/yuescript/yue_parser.cpp')
-rw-r--r-- | src/yuescript/yue_parser.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp index 4aeb79a..e4de0b5 100644 --- a/src/yuescript/yue_parser.cpp +++ b/src/yuescript/yue_parser.cpp | |||
@@ -71,7 +71,7 @@ YueParser::YueParser() { | |||
71 | Cut = false_(); | 71 | Cut = false_(); |
72 | Seperator = true_(); | 72 | Seperator = true_(); |
73 | 73 | ||
74 | invalid_empty_block = pl::user(true_(), [](const item_t& item) { | 74 | empty_block_error = pl::user(true_(), [](const item_t& item) { |
75 | throw ParserError("must be followed by a statement or an indented block", *item.begin, *item.end); | 75 | throw ParserError("must be followed by a statement or an indented block", *item.begin, *item.end); |
76 | return false; | 76 | return false; |
77 | }); | 77 | }); |
@@ -84,9 +84,9 @@ YueParser::YueParser() { | |||
84 | #define disable_chain(patt) (DisableChain >> ((patt) >> EnableChain | EnableChain >> Cut)) | 84 | #define disable_chain(patt) (DisableChain >> ((patt) >> EnableChain | EnableChain >> Cut)) |
85 | #define disable_do_chain_arg_table_block(patt) (DisableDoChainArgTableBlock >> ((patt) >> EnableDoChainArgTableBlock | EnableDoChainArgTableBlock >> Cut)) | 85 | #define disable_do_chain_arg_table_block(patt) (DisableDoChainArgTableBlock >> ((patt) >> EnableDoChainArgTableBlock | EnableDoChainArgTableBlock >> Cut)) |
86 | #define disable_arg_table_block(patt) (DisableArgTableBlock >> ((patt) >> EnableArgTableBlock | EnableArgTableBlock >> Cut)) | 86 | #define disable_arg_table_block(patt) (DisableArgTableBlock >> ((patt) >> EnableArgTableBlock | EnableArgTableBlock >> Cut)) |
87 | #define body_with(str) (Space >> (key(str) >> Space >> (InBlock | Statement) | InBlock | invalid_empty_block)) | 87 | #define body_with(str) (Space >> (key(str) >> Space >> (InBlock | Statement) | InBlock | empty_block_error)) |
88 | #define opt_body_with(str) (Space >> (key(str) >> Space >> (InBlock | Statement) | InBlock)) | 88 | #define opt_body_with(str) (Space >> (key(str) >> Space >> (InBlock | Statement) | InBlock)) |
89 | #define body (Space >> (InBlock | Statement | invalid_empty_block)) | 89 | #define body (Space >> (InBlock | Statement | empty_block_error)) |
90 | 90 | ||
91 | Variable = pl::user(Name, [](const item_t& item) { | 91 | Variable = pl::user(Name, [](const item_t& item) { |
92 | State* st = reinterpret_cast<State*>(item.user_data); | 92 | State* st = reinterpret_cast<State*>(item.user_data); |
@@ -630,15 +630,17 @@ YueParser::YueParser() { | |||
630 | SpaceBreak >> Advance >> ArgBlock >> -arg_table_block | 630 | SpaceBreak >> Advance >> ArgBlock >> -arg_table_block |
631 | ) | arg_table_block; | 631 | ) | arg_table_block; |
632 | 632 | ||
633 | leading_spaces_error = pl::user(+space_one >> expr('(') >> Exp >> +(sym(',') >> Exp) >> sym(')'), [](const item_t& item) { | ||
634 | throw ParserError("write invoke arguments in parentheses without leading spaces or leading spaces without parentheses", *item.begin, *item.end); | ||
635 | return false; | ||
636 | }); | ||
637 | |||
633 | InvokeArgs = | 638 | InvokeArgs = |
634 | not_(set("-~")) >> Seperator >> | 639 | not_(set("-~")) >> Seperator >> |
635 | ( | 640 | ( |
636 | (Exp >> *(sym(',') >> Exp) >> -invoke_args_with_table) | | 641 | (Exp >> *(sym(',') >> Exp) >> -invoke_args_with_table) | |
637 | arg_table_block | | 642 | arg_table_block | |
638 | pl::user(+space_one >> expr('(') >> Exp >> +(sym(',') >> Exp) >> sym(')'), [](const item_t& item) { | 643 | leading_spaces_error |
639 | throw ParserError("write invoke arguments in parentheses without spaces or space seperated without parentheses", *item.begin, *item.end); | ||
640 | return false; | ||
641 | }) | ||
642 | ); | 644 | ); |
643 | 645 | ||
644 | const_value = (expr("nil") | expr("true") | expr("false")) >> not_(AlphaNum); | 646 | const_value = (expr("nil") | expr("true") | expr("false")) >> not_(AlphaNum); |
@@ -666,7 +668,7 @@ YueParser::YueParser() { | |||
666 | Return | Local | Global | Export | Macro | | 668 | Return | Local | Global | Export | Macro | |
667 | MacroInPlace | BreakLoop | Label | Goto | ShortTabAppending | | 669 | MacroInPlace | BreakLoop | Label | Goto | ShortTabAppending | |
668 | LocalAttrib | Backcall | PipeBody | ExpListAssign | | 670 | LocalAttrib | Backcall | PipeBody | ExpListAssign | |
669 | statement_appendix >> invalid_empty_block | 671 | statement_appendix >> empty_block_error |
670 | ) >> Space >> | 672 | ) >> Space >> |
671 | -statement_appendix >> -statement_sep; | 673 | -statement_appendix >> -statement_sep; |
672 | 674 | ||