aboutsummaryrefslogtreecommitdiff
path: root/src/yuescript/yue_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuescript/yue_parser.cpp')
-rw-r--r--src/yuescript/yue_parser.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/yuescript/yue_parser.cpp b/src/yuescript/yue_parser.cpp
index 2206686..5b97a25 100644
--- a/src/yuescript/yue_parser.cpp
+++ b/src/yuescript/yue_parser.cpp
@@ -114,6 +114,11 @@ YueParser::YueParser() {
114 return false; 114 return false;
115 }); 115 });
116 116
117 if_assignment_syntax_error = pl::user(true_(), [](const item_t& item) {
118 throw ParserError("use := for if-assignment expression"sv, item.begin);
119 return false;
120 });
121
117 #define ensure(patt, finally) ((patt) >> (finally) | (finally) >> cut) 122 #define ensure(patt, finally) ((patt) >> (finally) | (finally) >> cut)
118 123
119 #define key(str) (expr(str) >> not_alpha_num) 124 #define key(str) (expr(str) >> not_alpha_num)
@@ -369,8 +374,8 @@ YueParser::YueParser() {
369 +space_break >> advance_match >> space >> SwitchCase >> switch_block >> pop_indent 374 +space_break >> advance_match >> space >> SwitchCase >> switch_block >> pop_indent
370 ) >> switch_block; 375 ) >> switch_block;
371 376
372 Assignment = ExpList >> space >> Assign; 377 Assignment = -(',' >> space >> ExpList >> space) >> (':' >> Assign | and_('=') >> if_assignment_syntax_error);
373 IfCond = disable_chain_rule(disable_arg_table_block_rule(Assignment | Exp)); 378 IfCond = disable_chain_rule(disable_arg_table_block_rule(Exp >> -(space >> Assignment)));
374 if_else_if = -(line_break >> *space_break >> check_indent_match) >> space >> key("elseif") >> space >> IfCond >> space >> body_with("then"); 379 if_else_if = -(line_break >> *space_break >> check_indent_match) >> space >> key("elseif") >> space >> IfCond >> space >> body_with("then");
375 if_else = -(line_break >> *space_break >> check_indent_match) >> space >> key("else") >> space >> body; 380 if_else = -(line_break >> *space_break >> check_indent_match) >> space >> key("else") >> space >> body;
376 IfType = (expr("if") | "unless") >> not_alpha_num; 381 IfType = (expr("if") | "unless") >> not_alpha_num;