diff --git a/0001-add-to-parser.patch b/0001-add-to-parser.patch index 28ade40..91b1b77 100644 --- a/0001-add-to-parser.patch +++ b/0001-add-to-parser.patch @@ -1,14 +1,14 @@ -From 074d19076df40ace10bc115f8154bfbb96526649 Mon Sep 17 00:00:00 2001 +From d947b1d3160d8a6990f9b7bed476184271fedd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= -Date: Mon, 5 Jan 2026 11:21:45 +0100 +Date: Mon, 5 Jan 2026 16:14:52 +0100 Subject: [PATCH] add to parser --- Grammar/Tokens | 1 + - Grammar/python.gram | 73 +++++++++++++++++++++++++++++------------ - Parser/action_helpers.c | 26 +++++++++++++++ + Grammar/python.gram | 77 ++++++++++++++++++++++++++++++----------- + Parser/action_helpers.c | 26 ++++++++++++++ Parser/pegen.h | 1 + - 4 files changed, 80 insertions(+), 21 deletions(-) + 4 files changed, 84 insertions(+), 21 deletions(-) diff --git a/Grammar/Tokens b/Grammar/Tokens index 0547e6ed08f..fd0ce412f6c 100644 @@ -23,7 +23,7 @@ index 0547e6ed08f..fd0ce412f6c 100644 OP TYPE_IGNORE diff --git a/Grammar/python.gram b/Grammar/python.gram -index 110136af81b..48cebe45d5b 100644 +index 110136af81b..7afaa1c140e 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -726,13 +726,13 @@ star_expressions[expr_ty]: @@ -58,7 +58,7 @@ index 110136af81b..48cebe45d5b 100644 compare_op_bitwise_or_pair[CmpopExprPair*]: | eq_bitwise_or -@@ -787,21 +787,47 @@ compare_op_bitwise_or_pair[CmpopExprPair*]: +@@ -787,21 +787,51 @@ compare_op_bitwise_or_pair[CmpopExprPair*]: | isnot_bitwise_or | is_bitwise_or @@ -87,6 +87,10 @@ index 110136af81b..48cebe45d5b 100644 # ----------------- +pipe[expr_ty]: ++ | lhs=pipe '|>' rhs=NAME !'(' { ++ CHECK_VERSION(expr_ty, 8, "Assignment expressions are", ++ _PyAST_NamedExpr(CHECK(expr_ty, _PyPegen_set_expr_context(p, rhs, Store)), lhs, EXTRA)) ++ } + | lhs=pipe '|>' rhs=primary_nocall b=genexp { + _PyAST_Call(rhs, + _PyPegen_desugar_pipe( @@ -115,7 +119,7 @@ index 110136af81b..48cebe45d5b 100644 bitwise_or[expr_ty]: | a=bitwise_or '|' b=bitwise_xor { _PyAST_BinOp(a, BitOr, b, EXTRA) } | bitwise_xor -@@ -856,6 +882,11 @@ await_primary[expr_ty] (memo): +@@ -856,6 +886,11 @@ await_primary[expr_ty] (memo): | 'await' a=primary { CHECK_VERSION(expr_ty, 5, "Await expressions are", _PyAST_Await(a, EXTRA)) } | primary @@ -127,7 +131,7 @@ index 110136af81b..48cebe45d5b 100644 primary[expr_ty]: | a=primary '.' b=NAME { _PyAST_Attribute(a, b->v.Name.id, Load, EXTRA) } | a=primary b=genexp { _PyAST_Call(a, CHECK(asdl_expr_seq*, (asdl_expr_seq*)_PyPegen_singleton_seq(p, b)), NULL, EXTRA) } -@@ -1020,7 +1051,7 @@ dict[expr_ty]: +@@ -1020,7 +1055,7 @@ dict[expr_ty]: double_starred_kvpairs[asdl_seq*]: a=','.double_starred_kvpair+ [','] { a } double_starred_kvpair[KeyValuePair*]: @@ -136,7 +140,7 @@ index 110136af81b..48cebe45d5b 100644 | kvpair kvpair[KeyValuePair*]: a=expression ':' b=expression { _PyPegen_key_value_pair(p, a, b) } -@@ -1098,7 +1129,7 @@ kwarg_or_double_starred[KeywordOrStarred*]: +@@ -1098,7 +1133,7 @@ kwarg_or_double_starred[KeywordOrStarred*]: # Generic targets # --------------- @@ -145,7 +149,7 @@ index 110136af81b..48cebe45d5b 100644 star_targets[expr_ty]: | a=star_target !',' { a } | a=star_target b=(',' c=star_target { c })* [','] { -@@ -1266,9 +1297,9 @@ invalid_named_expression(memo): +@@ -1266,9 +1301,9 @@ invalid_named_expression(memo): | a=expression ':=' expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION( a, "cannot use assignment expressions with %s", _PyPegen_get_expr_name(a)) } @@ -157,7 +161,7 @@ index 110136af81b..48cebe45d5b 100644 RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot assign to %s here. Maybe you meant '==' instead of '='?", _PyPegen_get_expr_name(a)) } -@@ -1334,7 +1365,7 @@ invalid_comprehension: +@@ -1334,7 +1369,7 @@ invalid_comprehension: | ('[' | '{') a=star_named_expression b=',' for_if_clauses { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "did you forget parentheses around the comprehension target?") } invalid_dict_comprehension: @@ -166,7 +170,7 @@ index 110136af81b..48cebe45d5b 100644 RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "dict unpacking cannot be used in dict comprehension") } invalid_parameters: | a="/" ',' { -@@ -1397,7 +1428,7 @@ invalid_with_item: +@@ -1397,7 +1432,7 @@ invalid_with_item: RAISE_SYNTAX_ERROR_INVALID_TARGET(STAR_TARGETS, a) } invalid_for_if_clause: @@ -175,7 +179,7 @@ index 110136af81b..48cebe45d5b 100644 RAISE_SYNTAX_ERROR("'in' expected after for-loop variables") } invalid_for_target: -@@ -1531,12 +1562,12 @@ invalid_class_def_raw: +@@ -1531,12 +1566,12 @@ invalid_class_def_raw: invalid_double_starred_kvpairs: | ','.double_starred_kvpair+ ',' invalid_kvpair @@ -191,7 +195,7 @@ index 110136af81b..48cebe45d5b 100644 invalid_starred_expression_unpacking: | a='*' expression '=' b=expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to iterable argument unpacking") } diff --git a/Parser/action_helpers.c b/Parser/action_helpers.c -index 50856686335..53887c4fb55 100644 +index 50856686335..44d617f48cc 100644 --- a/Parser/action_helpers.c +++ b/Parser/action_helpers.c @@ -1152,6 +1152,32 @@ _PyPegen_get_last_comprehension_item(comprehension_ty comprehension) {