From 140d77eda33db837fb24b568b00af7fb1e347d9d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 May 2024 18:53:56 +0800 Subject: [PATCH] check changes --- Grammar/python.gram | 2 +- Parser/parser.c | 42 +++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Grammar/python.gram b/Grammar/python.gram index daf67a0..a394b67 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -1492,9 +1492,9 @@ invalid_kwarg: # IMPORTANT: Note that the "_without_invalid" suffix causes the rule to not call invalid rules under it expression_without_invalid[expr_ty]: + | lambdef | a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, a, c, EXTRA) } | disjunction - | lambdef invalid_legacy_expression: | a=NAME !'(' b=star_expressions { _PyPegen_check_legacy_stmt(p, a) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, diff --git a/Parser/parser.c b/Parser/parser.c index 5ef1a97..c3b8928 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -27797,9 +27797,9 @@ invalid_kwarg_rule(Parser *p) } // expression_without_invalid: +// | lambdef // | disjunction 'if' disjunction 'else' expression // | disjunction -// | lambdef static expr_ty expression_without_invalid_rule(Parser *p) { @@ -27826,6 +27826,26 @@ expression_without_invalid_rule(Parser *p) UNUSED(_start_lineno); // Only used by EXTRA macro int _start_col_offset = p->tokens[_mark]->col_offset; UNUSED(_start_col_offset); // Only used by EXTRA macro + { // lambdef + if (p->error_indicator) { + p->call_invalid_rules = _prev_call_invalid; + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d L%d]: %s\n", p->level, ' ', _mark, p->mark, p->tok->lineno, "lambdef")); + expr_ty lambdef_var; + if ( + (lambdef_var = lambdef_rule(p)) // lambdef + ) + { + D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d L%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, p->tok->lineno, "lambdef")); + _res = lambdef_var; + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d L%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, p->tok->lineno, "lambdef")); + } { // disjunction 'if' disjunction 'else' expression if (p->error_indicator) { p->call_invalid_rules = _prev_call_invalid; @@ -27894,26 +27914,6 @@ expression_without_invalid_rule(Parser *p) D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d L%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, p->tok->lineno, "disjunction")); } - { // lambdef - if (p->error_indicator) { - p->call_invalid_rules = _prev_call_invalid; - p->level--; - return NULL; - } - D(fprintf(stderr, "%*c> expression_without_invalid[%d-%d L%d]: %s\n", p->level, ' ', _mark, p->mark, p->tok->lineno, "lambdef")); - expr_ty lambdef_var; - if ( - (lambdef_var = lambdef_rule(p)) // lambdef - ) - { - D(fprintf(stderr, "%*c+ expression_without_invalid[%d-%d L%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, p->tok->lineno, "lambdef")); - _res = lambdef_var; - goto done; - } - p->mark = _mark; - D(fprintf(stderr, "%*c%s expression_without_invalid[%d-%d L%d]: %s failed!\n", p->level, ' ', - p->error_indicator ? "ERROR!" : "-", _mark, p->mark, p->tok->lineno, "lambdef")); - } _res = NULL; done: p->call_invalid_rules = _prev_call_invalid;