diff --git a/Grammar/python.gram b/Grammar/python.gram index 3a91d426c36501..9ee350ae3d45b1 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -1264,6 +1264,8 @@ invalid_expression: # Soft keywords need to also be ignored because they can be parsed as NAME NAME | !(NAME STRING | SOFT_KEYWORD) a=disjunction b=expression_without_invalid { _PyPegen_raise_error_for_missing_comma(p, a, b) } + | disjunction 'if' a=disjunction ':=' b=disjunction { + RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "assignment expression must be parenthesized inside conditional expression" ) } | a=disjunction 'if' b=disjunction !('else'|':') { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") } | a=disjunction 'if' b=disjunction 'else' !expression { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("expected expression after 'else', but statement is given") } diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index a3d485c998ac91..7eea1879453db9 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -180,6 +180,10 @@ Traceback (most recent call last): SyntaxError: expected expression before 'if', but statement is given +>>> 1 if x := True else 2 +Traceback (most recent call last): +SyntaxError: assignment expression must be parenthesized inside conditional expression + >>> if True: ... print("Hello" ... diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-22-14-49-48.gh-issue-146260.s8PzJW.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-22-14-49-48.gh-issue-146260.s8PzJW.rst new file mode 100644 index 00000000000000..4b8641f3e7f142 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-22-14-49-48.gh-issue-146260.s8PzJW.rst @@ -0,0 +1,3 @@ +Improve :exc:`SyntaxError` message when an :ref:`assignment expression +` is used inside the ``if`` clause of a +:ref:`conditional expression `. Patch by Brian Schubert. diff --git a/Parser/parser.c b/Parser/parser.c index f853d309de9180..c59743cc9a0805 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -22,54 +22,54 @@ static KeywordToken *reserved_keywords[] = { (KeywordToken[]) {{NULL, -1}}, (KeywordToken[]) {{NULL, -1}}, (KeywordToken[]) { - {"if", 698}, - {"as", 696}, - {"in", 711}, + {"if", 699}, + {"as", 697}, + {"in", 712}, {"or", 589}, {"is", 597}, {NULL, -1}, }, (KeywordToken[]) { - {"del", 634}, - {"def", 715}, - {"for", 710}, - {"try", 672}, + {"del", 635}, + {"def", 716}, + {"for", 711}, + {"try", 673}, {"and", 590}, - {"not", 719}, + {"not", 720}, {NULL, -1}, }, (KeywordToken[]) { - {"from", 646}, + {"from", 647}, {"pass", 527}, - {"with", 663}, - {"elif", 703}, - {"else", 702}, - {"None", 628}, - {"True", 627}, + {"with", 664}, + {"elif", 704}, + {"else", 703}, + {"None", 629}, + {"True", 628}, {NULL, -1}, }, (KeywordToken[]) { - {"raise", 632}, + {"raise", 633}, {"yield", 588}, {"break", 528}, - {"async", 714}, - {"class", 717}, - {"while", 705}, - {"False", 629}, + {"async", 715}, + {"class", 718}, + {"while", 706}, + {"False", 630}, {"await", 598}, {NULL, -1}, }, (KeywordToken[]) { - {"import", 647}, + {"import", 648}, {"return", 522}, - {"assert", 638}, + {"assert", 639}, {"global", 530}, - {"except", 693}, - {"lambda", 622}, + {"except", 694}, + {"lambda", 623}, {NULL, -1}, }, (KeywordToken[]) { - {"finally", 689}, + {"finally", 690}, {NULL, -1}, }, (KeywordToken[]) { @@ -1726,7 +1726,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt")); stmt_ty raise_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 632) // token='raise' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 633) // token='raise' && (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt ) @@ -1768,7 +1768,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt")); stmt_ty del_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 634) // token='del' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 635) // token='del' && (del_stmt_var = del_stmt_rule(p)) // del_stmt ) @@ -1810,7 +1810,7 @@ simple_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt")); stmt_ty assert_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 638) // token='assert' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 639) // token='assert' && (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt ) @@ -1964,7 +1964,7 @@ compound_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt")); stmt_ty if_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 698) // token='if' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 699) // token='if' && (if_stmt_var = if_stmt_rule(p)) // if_stmt ) @@ -2048,7 +2048,7 @@ compound_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt")); stmt_ty try_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 672) // token='try' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 673) // token='try' && (try_stmt_var = try_stmt_rule(p)) // try_stmt ) @@ -2069,7 +2069,7 @@ compound_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt")); stmt_ty while_stmt_var; if ( - _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 705) // token='while' + _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 706) // token='while' && (while_stmt_var = while_stmt_rule(p)) // while_stmt ) @@ -2832,11 +2832,11 @@ raise_stmt_rule(Parser *p) expr_ty a; expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' + (_keyword = _PyPegen_expect_token(p, 633)) // token='raise' && (a = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 646)) // token='from' + (_keyword_1 = _PyPegen_expect_token(p, 647)) // token='from' && (b = expression_rule(p)) // expression ) @@ -2891,7 +2891,7 @@ raise_stmt_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' + (_keyword = _PyPegen_expect_token(p, 633)) // token='raise' && (a = expression_rule(p)) // expression ) @@ -2926,7 +2926,7 @@ raise_stmt_rule(Parser *p) D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' + (_keyword = _PyPegen_expect_token(p, 633)) // token='raise' ) { D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); @@ -3299,7 +3299,7 @@ del_stmt_rule(Parser *p) Token * _keyword; asdl_expr_seq* a; if ( - (_keyword = _PyPegen_expect_token(p, 634)) // token='del' + (_keyword = _PyPegen_expect_token(p, 635)) // token='del' && (a = del_targets_rule(p)) // del_targets && @@ -3465,7 +3465,7 @@ assert_stmt_rule(Parser *p) expr_ty a; void *b; if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' + (_keyword = _PyPegen_expect_token(p, 639)) // token='assert' && (a = expression_rule(p)) // expression && @@ -3615,7 +3615,7 @@ import_name_rule(Parser *p) if ( (lazy = _PyPegen_expect_soft_keyword(p, "lazy"), !p->error_indicator) // "lazy"? && - (_keyword = _PyPegen_expect_token(p, 647)) // token='import' + (_keyword = _PyPegen_expect_token(p, 648)) // token='import' && (a = dotted_as_names_rule(p)) // dotted_as_names ) @@ -3687,13 +3687,13 @@ import_from_rule(Parser *p) if ( (lazy = _PyPegen_expect_soft_keyword(p, "lazy"), !p->error_indicator) // "lazy"? && - (_keyword = _PyPegen_expect_token(p, 646)) // token='from' + (_keyword = _PyPegen_expect_token(p, 647)) // token='from' && (a = _loop0_17_rule(p)) // (('.' | '...'))* && (b = dotted_name_rule(p)) // dotted_name && - (_keyword_1 = _PyPegen_expect_token(p, 647)) // token='import' + (_keyword_1 = _PyPegen_expect_token(p, 648)) // token='import' && (c = import_from_targets_rule(p)) // import_from_targets ) @@ -3734,11 +3734,11 @@ import_from_rule(Parser *p) if ( (lazy = _PyPegen_expect_soft_keyword(p, "lazy"), !p->error_indicator) // "lazy"? && - (_keyword = _PyPegen_expect_token(p, 646)) // token='from' + (_keyword = _PyPegen_expect_token(p, 647)) // token='from' && (a = _loop1_18_rule(p)) // (('.' | '...'))+ && - (_keyword_1 = _PyPegen_expect_token(p, 647)) // token='import' + (_keyword_1 = _PyPegen_expect_token(p, 648)) // token='import' && (b = import_from_targets_rule(p)) // import_from_targets ) @@ -4525,7 +4525,7 @@ class_def_raw_rule(Parser *p) asdl_stmt_seq* c; void *t; if ( - (_keyword = _PyPegen_expect_token(p, 717)) // token='class' + (_keyword = _PyPegen_expect_token(p, 718)) // token='class' && (a = _PyPegen_name_token(p)) // NAME && @@ -4692,7 +4692,7 @@ function_def_raw_rule(Parser *p) void *t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 715)) // token='def' + (_keyword = _PyPegen_expect_token(p, 716)) // token='def' && (n = _PyPegen_name_token(p)) // NAME && @@ -4753,9 +4753,9 @@ function_def_raw_rule(Parser *p) void *t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 715)) // token='def' + (_keyword_1 = _PyPegen_expect_token(p, 716)) // token='def' && (n = _PyPegen_name_token(p)) // NAME && @@ -6093,7 +6093,7 @@ if_stmt_rule(Parser *p) asdl_stmt_seq* b; stmt_ty c; if ( - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (a = named_expression_rule(p)) // named_expression && @@ -6138,7 +6138,7 @@ if_stmt_rule(Parser *p) asdl_stmt_seq* b; void *c; if ( - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (a = named_expression_rule(p)) // named_expression && @@ -6233,7 +6233,7 @@ elif_stmt_rule(Parser *p) asdl_stmt_seq* b; stmt_ty c; if ( - (_keyword = _PyPegen_expect_token(p, 703)) // token='elif' + (_keyword = _PyPegen_expect_token(p, 704)) // token='elif' && (a = named_expression_rule(p)) // named_expression && @@ -6278,7 +6278,7 @@ elif_stmt_rule(Parser *p) asdl_stmt_seq* b; void *c; if ( - (_keyword = _PyPegen_expect_token(p, 703)) // token='elif' + (_keyword = _PyPegen_expect_token(p, 704)) // token='elif' && (a = named_expression_rule(p)) // named_expression && @@ -6359,7 +6359,7 @@ else_block_rule(Parser *p) Token * _literal; asdl_stmt_seq* b; if ( - (_keyword = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword = _PyPegen_expect_token(p, 703)) // token='else' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -6438,7 +6438,7 @@ while_stmt_rule(Parser *p) asdl_stmt_seq* b; void *c; if ( - (_keyword = _PyPegen_expect_token(p, 705)) // token='while' + (_keyword = _PyPegen_expect_token(p, 706)) // token='while' && (a = named_expression_rule(p)) // named_expression && @@ -6538,11 +6538,11 @@ for_stmt_rule(Parser *p) expr_ty t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword = _PyPegen_expect_token(p, 711)) // token='for' && (t = star_targets_rule(p)) // star_targets && - (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='in' && (_cut_var = 1) && @@ -6600,13 +6600,13 @@ for_stmt_rule(Parser *p) expr_ty t; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='for' && (t = star_targets_rule(p)) // star_targets && - (_keyword_2 = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword_2 = _PyPegen_expect_token(p, 712)) // token='in' && (_cut_var = 1) && @@ -6735,7 +6735,7 @@ with_stmt_rule(Parser *p) asdl_stmt_seq* b; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword = _PyPegen_expect_token(p, 664)) // token='with' && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -6786,7 +6786,7 @@ with_stmt_rule(Parser *p) asdl_stmt_seq* b; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword = _PyPegen_expect_token(p, 664)) // token='with' && (a = (asdl_withitem_seq*)_gather_34_rule(p)) // ','.with_item+ && @@ -6835,9 +6835,9 @@ with_stmt_rule(Parser *p) asdl_withitem_seq* a; asdl_stmt_seq* b; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword_1 = _PyPegen_expect_token(p, 664)) // token='with' && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -6887,9 +6887,9 @@ with_stmt_rule(Parser *p) asdl_stmt_seq* b; void *tc; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword_1 = _PyPegen_expect_token(p, 664)) // token='with' && (a = (asdl_withitem_seq*)_gather_34_rule(p)) // ','.with_item+ && @@ -6975,7 +6975,7 @@ with_item_rule(Parser *p) if ( (e = expression_rule(p)) // expression && - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && (t = star_target_rule(p)) // star_target && @@ -7100,7 +7100,7 @@ try_stmt_rule(Parser *p) asdl_stmt_seq* b; asdl_stmt_seq* f; if ( - (_keyword = _PyPegen_expect_token(p, 672)) // token='try' + (_keyword = _PyPegen_expect_token(p, 673)) // token='try' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -7144,7 +7144,7 @@ try_stmt_rule(Parser *p) asdl_excepthandler_seq* ex; void *f; if ( - (_keyword = _PyPegen_expect_token(p, 672)) // token='try' + (_keyword = _PyPegen_expect_token(p, 673)) // token='try' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -7192,7 +7192,7 @@ try_stmt_rule(Parser *p) asdl_excepthandler_seq* ex; void *f; if ( - (_keyword = _PyPegen_expect_token(p, 672)) // token='try' + (_keyword = _PyPegen_expect_token(p, 673)) // token='try' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -7291,7 +7291,7 @@ except_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (e = expression_rule(p)) // expression && @@ -7335,11 +7335,11 @@ except_block_rule(Parser *p) expr_ty e; expr_ty t; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (e = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 697)) // token='as' && (t = _PyPegen_name_token(p)) // NAME && @@ -7381,7 +7381,7 @@ except_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (e = expressions_rule(p)) // expressions && @@ -7422,7 +7422,7 @@ except_block_rule(Parser *p) Token * _literal; asdl_stmt_seq* b; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -7534,7 +7534,7 @@ except_star_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -7581,13 +7581,13 @@ except_star_block_rule(Parser *p) expr_ty e; expr_ty t; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && (e = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 697)) // token='as' && (t = _PyPegen_name_token(p)) // NAME && @@ -7630,7 +7630,7 @@ except_star_block_rule(Parser *p) asdl_stmt_seq* b; expr_ty e; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -7730,7 +7730,7 @@ finally_block_rule(Parser *p) Token * _literal; asdl_stmt_seq* a; if ( - (_keyword = _PyPegen_expect_token(p, 689)) // token='finally' + (_keyword = _PyPegen_expect_token(p, 690)) // token='finally' && (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' && @@ -8038,7 +8038,7 @@ guard_rule(Parser *p) Token * _keyword; expr_ty guard; if ( - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (guard = named_expression_rule(p)) // named_expression ) @@ -8233,7 +8233,7 @@ as_pattern_rule(Parser *p) if ( (pattern = or_pattern_rule(p)) // or_pattern && - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && (target = pattern_capture_target_rule(p)) // pattern_capture_target ) @@ -8667,7 +8667,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 629)) // token='None' ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -8700,7 +8700,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 628)) // token='True' ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -8733,7 +8733,7 @@ literal_pattern_rule(Parser *p) D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 630)) // token='False' ) { D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -8861,7 +8861,7 @@ literal_expr_rule(Parser *p) D(fprintf(stderr, "%*c> literal_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 629)) // token='None' ) { D(fprintf(stderr, "%*c+ literal_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -8894,7 +8894,7 @@ literal_expr_rule(Parser *p) D(fprintf(stderr, "%*c> literal_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 628)) // token='True' ) { D(fprintf(stderr, "%*c+ literal_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -8927,7 +8927,7 @@ literal_expr_rule(Parser *p) D(fprintf(stderr, "%*c> literal_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 630)) // token='False' ) { D(fprintf(stderr, "%*c+ literal_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -11647,11 +11647,11 @@ if_expression_rule(Parser *p) if ( (a = disjunction_rule(p)) // disjunction && - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (b = disjunction_rule(p)) // disjunction && - (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='else' && (c = expression_rule(p)) // expression ) @@ -11718,7 +11718,7 @@ yield_expr_rule(Parser *p) if ( (_keyword = _PyPegen_expect_token(p, 588)) // token='yield' && - (_keyword_1 = _PyPegen_expect_token(p, 646)) // token='from' + (_keyword_1 = _PyPegen_expect_token(p, 647)) // token='from' && (a = expression_rule(p)) // expression ) @@ -12600,7 +12600,7 @@ inversion_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 719)) // token='not' + (_keyword = _PyPegen_expect_token(p, 720)) // token='not' && (a = inversion_rule(p)) // inversion ) @@ -13254,9 +13254,9 @@ notin_bitwise_or_rule(Parser *p) Token * _keyword_1; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 719)) // token='not' + (_keyword = _PyPegen_expect_token(p, 720)) // token='not' && - (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='in' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -13302,7 +13302,7 @@ in_bitwise_or_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword = _PyPegen_expect_token(p, 712)) // token='in' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -13351,7 +13351,7 @@ isnot_bitwise_or_rule(Parser *p) if ( (_keyword = _PyPegen_expect_token(p, 597)) // token='is' && - (_keyword_1 = _PyPegen_expect_token(p, 719)) // token='not' + (_keyword_1 = _PyPegen_expect_token(p, 720)) // token='not' && (a = bitwise_or_rule(p)) // bitwise_or ) @@ -15257,7 +15257,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 628)) // token='True' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -15290,7 +15290,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 630)) // token='False' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -15323,7 +15323,7 @@ atom_rule(Parser *p) D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 629)) // token='None' ) { D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -15591,7 +15591,7 @@ lambdef_rule(Parser *p) void *a; expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 622)) // token='lambda' + (_keyword = _PyPegen_expect_token(p, 623)) // token='lambda' && (a = lambda_params_rule(p), !p->error_indicator) // lambda_params? && @@ -18010,13 +18010,13 @@ for_if_clause_rule(Parser *p) expr_ty b; asdl_expr_seq* c; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' && - (_keyword_1 = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='for' && (a = star_targets_rule(p)) // star_targets && - (_keyword_2 = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword_2 = _PyPegen_expect_token(p, 712)) // token='in' && (_cut_var = 1) && @@ -18055,11 +18055,11 @@ for_if_clause_rule(Parser *p) expr_ty b; asdl_expr_seq* c; if ( - (_keyword = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword = _PyPegen_expect_token(p, 711)) // token='for' && (a = star_targets_rule(p)) // star_targets && - (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='in' && (_cut_var = 1) && @@ -21386,11 +21386,11 @@ expression_without_invalid_rule(Parser *p) if ( (a = disjunction_rule(p)) // disjunction && - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (b = disjunction_rule(p)) // disjunction && - (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='else' && (c = expression_rule(p)) // expression ) @@ -21602,6 +21602,7 @@ invalid_type_param_rule(Parser *p) // invalid_expression: // | STRING ((!STRING expression_without_invalid))+ STRING // | !(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid +// | disjunction 'if' disjunction ':=' disjunction // | disjunction 'if' disjunction !('else' | ':') // | disjunction 'if' disjunction 'else' !expression // | (pass_stmt | break_stmt | continue_stmt) 'if' disjunction 'else' simple_stmt @@ -21678,6 +21679,42 @@ invalid_expression_rule(Parser *p) D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(NAME STRING | SOFT_KEYWORD) disjunction expression_without_invalid")); } + { // disjunction 'if' disjunction ':=' disjunction + if (p->error_indicator) { + p->level--; + return NULL; + } + D(fprintf(stderr, "%*c> invalid_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction ':=' disjunction")); + Token * _keyword; + Token * _literal; + expr_ty a; + expr_ty b; + expr_ty disjunction_var; + if ( + (disjunction_var = disjunction_rule(p)) // disjunction + && + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' + && + (a = disjunction_rule(p)) // disjunction + && + (_literal = _PyPegen_expect_token(p, 53)) // token=':=' + && + (b = disjunction_rule(p)) // disjunction + ) + { + D(fprintf(stderr, "%*c+ invalid_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction ':=' disjunction")); + _res = RAISE_SYNTAX_ERROR_KNOWN_RANGE ( a , b , "assignment expression must be parenthesized inside conditional expression" ); + if ((_res == NULL || p->error_indicator) && PyErr_Occurred()) { + p->error_indicator = 1; + p->level--; + return NULL; + } + goto done; + } + p->mark = _mark; + D(fprintf(stderr, "%*c%s invalid_expression[%d-%d]: %s failed!\n", p->level, ' ', + p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction ':=' disjunction")); + } { // disjunction 'if' disjunction !('else' | ':') if (p->error_indicator) { p->level--; @@ -21690,7 +21727,7 @@ invalid_expression_rule(Parser *p) if ( (a = disjunction_rule(p)) // disjunction && - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (b = disjunction_rule(p)) // disjunction && @@ -21723,11 +21760,11 @@ invalid_expression_rule(Parser *p) if ( (a = disjunction_rule(p)) // disjunction && - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (b = disjunction_rule(p)) // disjunction && - (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='else' && _PyPegen_lookahead_for_expr(0, expression_rule, p) ) @@ -21759,11 +21796,11 @@ invalid_expression_rule(Parser *p) if ( (a = (stmt_ty)_tmp_118_rule(p)) // pass_stmt | break_stmt | continue_stmt && - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (b = disjunction_rule(p)) // disjunction && - (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='else' && (c = simple_stmt_rule(p)) // simple_stmt ) @@ -21792,7 +21829,7 @@ invalid_expression_rule(Parser *p) Token * a; Token * b; if ( - (a = _PyPegen_expect_token(p, 622)) // token='lambda' + (a = _PyPegen_expect_token(p, 623)) // token='lambda' && (_opt_var = lambda_params_rule(p), !p->error_indicator) // lambda_params? && @@ -21825,7 +21862,7 @@ invalid_expression_rule(Parser *p) Token * a; Token * b; if ( - (a = _PyPegen_expect_token(p, 622)) // token='lambda' + (a = _PyPegen_expect_token(p, 623)) // token='lambda' && (_opt_var = lambda_params_rule(p), !p->error_indicator) // lambda_params? && @@ -21882,11 +21919,11 @@ invalid_if_expression_rule(Parser *p) if ( (disjunction_var = disjunction_rule(p)) // disjunction && - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (b = disjunction_rule(p)) // disjunction && - (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='else' && (a = _PyPegen_expect_token(p, 16)) // token='*' ) @@ -21918,11 +21955,11 @@ invalid_if_expression_rule(Parser *p) if ( (disjunction_var = disjunction_rule(p)) // disjunction && - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (b = disjunction_rule(p)) // disjunction && - (_keyword_1 = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='else' && (a = _PyPegen_expect_token(p, 35)) // token='**' ) @@ -22389,9 +22426,9 @@ invalid_raise_stmt_rule(Parser *p) Token * a; Token * b; if ( - (a = _PyPegen_expect_token(p, 632)) // token='raise' + (a = _PyPegen_expect_token(p, 633)) // token='raise' && - (b = _PyPegen_expect_token(p, 646)) // token='from' + (b = _PyPegen_expect_token(p, 647)) // token='from' ) { D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' 'from'")); @@ -22417,11 +22454,11 @@ invalid_raise_stmt_rule(Parser *p) Token * a; expr_ty expression_var; if ( - (_keyword = _PyPegen_expect_token(p, 632)) // token='raise' + (_keyword = _PyPegen_expect_token(p, 633)) // token='raise' && (expression_var = expression_rule(p)) // expression && - (a = _PyPegen_expect_token(p, 646)) // token='from' + (a = _PyPegen_expect_token(p, 647)) // token='from' ) { D(fprintf(stderr, "%*c+ invalid_raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression 'from'")); @@ -22465,7 +22502,7 @@ invalid_del_stmt_rule(Parser *p) Token * _keyword; expr_ty a; if ( - (_keyword = _PyPegen_expect_token(p, 634)) // token='del' + (_keyword = _PyPegen_expect_token(p, 635)) // token='del' && (a = star_expressions_rule(p)) // star_expressions ) @@ -22517,7 +22554,7 @@ invalid_assert_stmt_rule(Parser *p) expr_ty a; expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' + (_keyword = _PyPegen_expect_token(p, 639)) // token='assert' && (a = expression_rule(p)) // expression && @@ -22552,7 +22589,7 @@ invalid_assert_stmt_rule(Parser *p) expr_ty b; expr_ty expression_var; if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' + (_keyword = _PyPegen_expect_token(p, 639)) // token='assert' && (expression_var = expression_rule(p)) // expression && @@ -22589,7 +22626,7 @@ invalid_assert_stmt_rule(Parser *p) expr_ty a; expr_ty b; if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' + (_keyword = _PyPegen_expect_token(p, 639)) // token='assert' && (a = expression_rule(p)) // expression && @@ -22624,7 +22661,7 @@ invalid_assert_stmt_rule(Parser *p) expr_ty b; expr_ty expression_var; if ( - (_keyword = _PyPegen_expect_token(p, 638)) // token='assert' + (_keyword = _PyPegen_expect_token(p, 639)) // token='assert' && (expression_var = expression_rule(p)) // expression && @@ -24050,7 +24087,7 @@ invalid_with_item_rule(Parser *p) if ( (expression_var = expression_rule(p)) // expression && - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && (a = expression_rule(p)) // expression && @@ -24100,13 +24137,13 @@ invalid_for_if_clause_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings void *_tmp_136_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (_keyword = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword = _PyPegen_expect_token(p, 711)) // token='for' && (_tmp_136_var = _tmp_136_rule(p)) // bitwise_or ((',' bitwise_or))* ','? && - _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 711) // token='in' + _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 712) // token='in' ) { D(fprintf(stderr, "%*c+ invalid_for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'? 'for' (bitwise_or ((',' bitwise_or))* ','?) !'in'")); @@ -24152,9 +24189,9 @@ invalid_for_target_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings expr_ty a; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (_keyword = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword = _PyPegen_expect_token(p, 711)) // token='for' && (a = star_expressions_rule(p)) // star_expressions ) @@ -24284,11 +24321,11 @@ invalid_import_rule(Parser *p) Token * a; expr_ty dotted_name_var; if ( - (a = _PyPegen_expect_token(p, 647)) // token='import' + (a = _PyPegen_expect_token(p, 648)) // token='import' && (_gather_138_var = _gather_138_rule(p)) // ','.dotted_name+ && - (_keyword = _PyPegen_expect_token(p, 646)) // token='from' + (_keyword = _PyPegen_expect_token(p, 647)) // token='from' && (dotted_name_var = dotted_name_rule(p)) // dotted_name ) @@ -24315,7 +24352,7 @@ invalid_import_rule(Parser *p) Token * _keyword; Token * token; if ( - (_keyword = _PyPegen_expect_token(p, 647)) // token='import' + (_keyword = _PyPegen_expect_token(p, 648)) // token='import' && (token = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -24364,7 +24401,7 @@ invalid_dotted_as_name_rule(Parser *p) if ( (dotted_name_var = dotted_name_rule(p)) // dotted_name && - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && _PyPegen_lookahead(0, _tmp_139_rule, p) && @@ -24415,7 +24452,7 @@ invalid_import_from_as_name_rule(Parser *p) if ( (name_var = _PyPegen_name_token(p)) // NAME && - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && _PyPegen_lookahead(0, _tmp_139_rule, p) && @@ -24543,9 +24580,9 @@ invalid_with_stmt_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings Token * trailing; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (_keyword = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword = _PyPegen_expect_token(p, 664)) // token='with' && (_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as' star_target])+ && @@ -24579,9 +24616,9 @@ invalid_with_stmt_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings Token * newline_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (_keyword = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword = _PyPegen_expect_token(p, 664)) // token='with' && (_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as' star_target])+ && @@ -24617,9 +24654,9 @@ invalid_with_stmt_rule(Parser *p) UNUSED(_opt_var_1); // Silence compiler warnings Token * newline_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (_keyword = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword = _PyPegen_expect_token(p, 664)) // token='with' && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -24679,9 +24716,9 @@ invalid_with_stmt_indent_rule(Parser *p) Token * a; Token * newline_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (a = _PyPegen_expect_token(p, 663)) // token='with' + (a = _PyPegen_expect_token(p, 664)) // token='with' && (_gather_141_var = _gather_141_rule(p)) // ','.(expression ['as' star_target])+ && @@ -24722,9 +24759,9 @@ invalid_with_stmt_indent_rule(Parser *p) Token * a; Token * newline_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (a = _PyPegen_expect_token(p, 663)) // token='with' + (a = _PyPegen_expect_token(p, 664)) // token='with' && (_literal = _PyPegen_expect_token(p, 7)) // token='(' && @@ -24787,7 +24824,7 @@ invalid_try_stmt_rule(Parser *p) Token * a; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 672)) // token='try' + (a = _PyPegen_expect_token(p, 673)) // token='try' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -24819,7 +24856,7 @@ invalid_try_stmt_rule(Parser *p) Token * _literal; asdl_stmt_seq* block_var; if ( - (_keyword = _PyPegen_expect_token(p, 672)) // token='try' + (_keyword = _PyPegen_expect_token(p, 673)) // token='try' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -24858,7 +24895,7 @@ invalid_try_stmt_rule(Parser *p) Token * b; expr_ty expression_var; if ( - (_keyword = _PyPegen_expect_token(p, 672)) // token='try' + (_keyword = _PyPegen_expect_token(p, 673)) // token='try' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -24866,7 +24903,7 @@ invalid_try_stmt_rule(Parser *p) && (_loop1_36_var = _loop1_36_rule(p)) // except_block+ && - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (b = _PyPegen_expect_token(p, 16)) // token='*' && @@ -24905,7 +24942,7 @@ invalid_try_stmt_rule(Parser *p) UNUSED(_opt_var); // Silence compiler warnings Token * a; if ( - (_keyword = _PyPegen_expect_token(p, 672)) // token='try' + (_keyword = _PyPegen_expect_token(p, 673)) // token='try' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -24913,7 +24950,7 @@ invalid_try_stmt_rule(Parser *p) && (_loop1_37_var = _loop1_37_rule(p)) // except_star_block+ && - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (_opt_var = _tmp_146_rule(p), !p->error_indicator) // [expression ['as' NAME]] && @@ -24970,7 +25007,7 @@ invalid_except_stmt_rule(Parser *p) expr_ty expressions_var; expr_ty name_var; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (a = expression_rule(p)) // expression && @@ -24978,7 +25015,7 @@ invalid_except_stmt_rule(Parser *p) && (expressions_var = expressions_rule(p)) // expressions && - (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 697)) // token='as' && (name_var = _PyPegen_name_token(p)) // NAME && @@ -25010,7 +25047,7 @@ invalid_except_stmt_rule(Parser *p) expr_ty expression_var; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (expression_var = expression_rule(p)) // expression && @@ -25041,7 +25078,7 @@ invalid_except_stmt_rule(Parser *p) Token * a; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' ) @@ -25072,11 +25109,11 @@ invalid_except_stmt_rule(Parser *p) asdl_stmt_seq* block_var; expr_ty expression_var; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (expression_var = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 697)) // token='as' && (a = expression_rule(p)) // expression && @@ -25136,7 +25173,7 @@ invalid_except_star_stmt_rule(Parser *p) expr_ty expressions_var; expr_ty name_var; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -25146,7 +25183,7 @@ invalid_except_star_stmt_rule(Parser *p) && (expressions_var = expressions_rule(p)) // expressions && - (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 697)) // token='as' && (name_var = _PyPegen_name_token(p)) // NAME && @@ -25179,7 +25216,7 @@ invalid_except_star_stmt_rule(Parser *p) expr_ty expression_var; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -25213,7 +25250,7 @@ invalid_except_star_stmt_rule(Parser *p) void *_tmp_147_var; Token * a; if ( - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -25247,13 +25284,13 @@ invalid_except_star_stmt_rule(Parser *p) asdl_stmt_seq* block_var; expr_ty expression_var; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && (expression_var = expression_rule(p)) // expression && - (_keyword_1 = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword_1 = _PyPegen_expect_token(p, 697)) // token='as' && (a = expression_rule(p)) // expression && @@ -25304,7 +25341,7 @@ invalid_finally_stmt_rule(Parser *p) Token * a; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 689)) // token='finally' + (a = _PyPegen_expect_token(p, 690)) // token='finally' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -25360,7 +25397,7 @@ invalid_except_stmt_indent_rule(Parser *p) expr_ty expression_var; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (expression_var = expression_rule(p)) // expression && @@ -25396,7 +25433,7 @@ invalid_except_stmt_indent_rule(Parser *p) Token * a; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -25452,7 +25489,7 @@ invalid_except_star_stmt_indent_rule(Parser *p) expr_ty expression_var; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 693)) // token='except' + (a = _PyPegen_expect_token(p, 694)) // token='except' && (_literal = _PyPegen_expect_token(p, 16)) // token='*' && @@ -25729,7 +25766,7 @@ invalid_as_pattern_rule(Parser *p) if ( (or_pattern_var = or_pattern_rule(p)) // or_pattern && - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && (a = _PyPegen_expect_soft_keyword(p, "_")) // soft_keyword='"_"' ) @@ -25759,7 +25796,7 @@ invalid_as_pattern_rule(Parser *p) if ( (or_pattern_var = or_pattern_rule(p)) // or_pattern && - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && (a = expression_rule(p)) // expression ) @@ -25975,7 +26012,7 @@ invalid_if_stmt_rule(Parser *p) expr_ty named_expression_var; Token * newline_var; if ( - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (named_expression_var = named_expression_rule(p)) // named_expression && @@ -26006,7 +26043,7 @@ invalid_if_stmt_rule(Parser *p) expr_ty a_1; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 698)) // token='if' + (a = _PyPegen_expect_token(p, 699)) // token='if' && (a_1 = named_expression_rule(p)) // named_expression && @@ -26061,7 +26098,7 @@ invalid_elif_stmt_rule(Parser *p) expr_ty named_expression_var; Token * newline_var; if ( - (_keyword = _PyPegen_expect_token(p, 703)) // token='elif' + (_keyword = _PyPegen_expect_token(p, 704)) // token='elif' && (named_expression_var = named_expression_rule(p)) // named_expression && @@ -26092,7 +26129,7 @@ invalid_elif_stmt_rule(Parser *p) expr_ty named_expression_var; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 703)) // token='elif' + (a = _PyPegen_expect_token(p, 704)) // token='elif' && (named_expression_var = named_expression_rule(p)) // named_expression && @@ -26145,7 +26182,7 @@ invalid_else_stmt_rule(Parser *p) Token * a; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 702)) // token='else' + (a = _PyPegen_expect_token(p, 703)) // token='else' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && @@ -26178,13 +26215,13 @@ invalid_else_stmt_rule(Parser *p) Token * _literal; asdl_stmt_seq* block_var; if ( - (_keyword = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword = _PyPegen_expect_token(p, 703)) // token='else' && (_literal = _PyPegen_expect_token(p, 11)) // token=':' && (block_var = block_rule(p)) // block && - (_keyword_1 = _PyPegen_expect_token(p, 703)) // token='elif' + (_keyword_1 = _PyPegen_expect_token(p, 704)) // token='elif' ) { D(fprintf(stderr, "%*c+ invalid_else_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' block 'elif'")); @@ -26231,7 +26268,7 @@ invalid_while_stmt_rule(Parser *p) expr_ty named_expression_var; Token * newline_var; if ( - (_keyword = _PyPegen_expect_token(p, 705)) // token='while' + (_keyword = _PyPegen_expect_token(p, 706)) // token='while' && (named_expression_var = named_expression_rule(p)) // named_expression && @@ -26262,7 +26299,7 @@ invalid_while_stmt_rule(Parser *p) expr_ty named_expression_var; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 705)) // token='while' + (a = _PyPegen_expect_token(p, 706)) // token='while' && (named_expression_var = named_expression_rule(p)) // named_expression && @@ -26321,13 +26358,13 @@ invalid_for_stmt_rule(Parser *p) expr_ty star_expressions_var; expr_ty star_targets_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (_keyword = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword = _PyPegen_expect_token(p, 711)) // token='for' && (star_targets_var = star_targets_rule(p)) // star_targets && - (_keyword_1 = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword_1 = _PyPegen_expect_token(p, 712)) // token='in' && (star_expressions_var = star_expressions_rule(p)) // star_expressions && @@ -26362,13 +26399,13 @@ invalid_for_stmt_rule(Parser *p) expr_ty star_expressions_var; expr_ty star_targets_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (a = _PyPegen_expect_token(p, 710)) // token='for' + (a = _PyPegen_expect_token(p, 711)) // token='for' && (star_targets_var = star_targets_rule(p)) // star_targets && - (_keyword = _PyPegen_expect_token(p, 711)) // token='in' + (_keyword = _PyPegen_expect_token(p, 712)) // token='in' && (star_expressions_var = star_expressions_rule(p)) // star_expressions && @@ -26434,9 +26471,9 @@ invalid_def_raw_rule(Parser *p) expr_ty name_var; Token * newline_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (a = _PyPegen_expect_token(p, 715)) // token='def' + (a = _PyPegen_expect_token(p, 716)) // token='def' && (name_var = _PyPegen_name_token(p)) // NAME && @@ -26493,9 +26530,9 @@ invalid_def_raw_rule(Parser *p) asdl_stmt_seq* block_var; expr_ty name_var; if ( - (_opt_var = _PyPegen_expect_token(p, 714), !p->error_indicator) // 'async'? + (_opt_var = _PyPegen_expect_token(p, 715), !p->error_indicator) // 'async'? && - (_keyword = _PyPegen_expect_token(p, 715)) // token='def' + (_keyword = _PyPegen_expect_token(p, 716)) // token='def' && (name_var = _PyPegen_name_token(p)) // NAME && @@ -26559,7 +26596,7 @@ invalid_class_def_raw_rule(Parser *p) expr_ty name_var; Token * newline_var; if ( - (_keyword = _PyPegen_expect_token(p, 717)) // token='class' + (_keyword = _PyPegen_expect_token(p, 718)) // token='class' && (name_var = _PyPegen_name_token(p)) // NAME && @@ -26598,7 +26635,7 @@ invalid_class_def_raw_rule(Parser *p) expr_ty name_var; Token * newline_var; if ( - (a = _PyPegen_expect_token(p, 717)) // token='class' + (a = _PyPegen_expect_token(p, 718)) // token='class' && (name_var = _PyPegen_name_token(p)) // NAME && @@ -28234,7 +28271,7 @@ invalid_arithmetic_rule(Parser *p) && (_tmp_157_var = _tmp_157_rule(p)) // '+' | '-' | '*' | '/' | '%' | '//' | '@' && - (a = _PyPegen_expect_token(p, 719)) // token='not' + (a = _PyPegen_expect_token(p, 720)) // token='not' && (b = inversion_rule(p)) // inversion ) @@ -28283,7 +28320,7 @@ invalid_factor_rule(Parser *p) if ( (_tmp_158_var = _tmp_158_rule(p)) // '+' | '-' | '~' && - (a = _PyPegen_expect_token(p, 719)) // token='not' + (a = _PyPegen_expect_token(p, 720)) // token='not' && (b = factor_rule(p)) // factor ) @@ -28630,7 +28667,7 @@ _tmp_5_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 647)) // token='import' + (_keyword = _PyPegen_expect_token(p, 648)) // token='import' ) { D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'")); @@ -28649,7 +28686,7 @@ _tmp_5_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 646)) // token='from' + (_keyword = _PyPegen_expect_token(p, 647)) // token='from' ) { D(fprintf(stderr, "%*c+ _tmp_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'")); @@ -28706,7 +28743,7 @@ _tmp_6_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 715)) // token='def' + (_keyword = _PyPegen_expect_token(p, 716)) // token='def' ) { D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); @@ -28744,7 +28781,7 @@ _tmp_6_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' ) { D(fprintf(stderr, "%*c+ _tmp_6[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); @@ -28782,7 +28819,7 @@ _tmp_7_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 717)) // token='class' + (_keyword = _PyPegen_expect_token(p, 718)) // token='class' ) { D(fprintf(stderr, "%*c+ _tmp_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); @@ -28839,7 +28876,7 @@ _tmp_8_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 663)) // token='with' + (_keyword = _PyPegen_expect_token(p, 664)) // token='with' ) { D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'")); @@ -28858,7 +28895,7 @@ _tmp_8_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' ) { D(fprintf(stderr, "%*c+ _tmp_8[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); @@ -28896,7 +28933,7 @@ _tmp_9_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 710)) // token='for' + (_keyword = _PyPegen_expect_token(p, 711)) // token='for' ) { D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'")); @@ -28915,7 +28952,7 @@ _tmp_9_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'async'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 714)) // token='async' + (_keyword = _PyPegen_expect_token(p, 715)) // token='async' ) { D(fprintf(stderr, "%*c+ _tmp_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'async'")); @@ -29616,7 +29653,7 @@ _tmp_21_rule(Parser *p) Token * _keyword; expr_ty z; if ( - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && (z = _PyPegen_name_token(p)) // NAME ) @@ -35339,7 +35376,7 @@ _tmp_113_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 628)) // token='True' ) { D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -35358,7 +35395,7 @@ _tmp_113_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 630)) // token='False' ) { D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -35377,7 +35414,7 @@ _tmp_113_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 629)) // token='None' ) { D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -35588,7 +35625,7 @@ _tmp_117_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 702)) // token='else' + (_keyword = _PyPegen_expect_token(p, 703)) // token='else' ) { D(fprintf(stderr, "%*c+ _tmp_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else'")); @@ -35835,7 +35872,7 @@ _tmp_120_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 627)) // token='True' + (_keyword = _PyPegen_expect_token(p, 628)) // token='True' ) { D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); @@ -35854,7 +35891,7 @@ _tmp_120_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 628)) // token='None' + (_keyword = _PyPegen_expect_token(p, 629)) // token='None' ) { D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); @@ -35873,7 +35910,7 @@ _tmp_120_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 629)) // token='False' + (_keyword = _PyPegen_expect_token(p, 630)) // token='False' ) { D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); @@ -37251,7 +37288,7 @@ _tmp_144_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 693)) // token='except' + (_keyword = _PyPegen_expect_token(p, 694)) // token='except' ) { D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except'")); @@ -37270,7 +37307,7 @@ _tmp_144_rule(Parser *p) D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally'")); Token * _keyword; if ( - (_keyword = _PyPegen_expect_token(p, 689)) // token='finally' + (_keyword = _PyPegen_expect_token(p, 690)) // token='finally' ) { D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally'")); @@ -38572,7 +38609,7 @@ _tmp_166_rule(Parser *p) Token * _keyword; expr_ty z; if ( - (_keyword = _PyPegen_expect_token(p, 698)) // token='if' + (_keyword = _PyPegen_expect_token(p, 699)) // token='if' && (z = disjunction_rule(p)) // disjunction ) @@ -39308,7 +39345,7 @@ _tmp_180_rule(Parser *p) Token * _keyword; expr_ty star_target_var; if ( - (_keyword = _PyPegen_expect_token(p, 696)) // token='as' + (_keyword = _PyPegen_expect_token(p, 697)) // token='as' && (star_target_var = star_target_rule(p)) // star_target )