@@ -96,15 +96,15 @@ def run_test(self, grammar_source, test_source):
9696
9797 def test_c_parser (self ) -> None :
9898 grammar_source = """
99- start[mod_ty]: a[asdl_stmt_seq*]=stmt* $ { Module (a, NULL, p->arena) }
99+ start[mod_ty]: a[asdl_stmt_seq*]=stmt* $ { _PyAST_Module (a, NULL, p->arena) }
100100 stmt[stmt_ty]: a=expr_stmt { a }
101- expr_stmt[stmt_ty]: a=expression NEWLINE { _Py_Expr (a, EXTRA) }
102- expression[expr_ty]: ( l=expression '+' r=term { _Py_BinOp (l, Add, r, EXTRA) }
103- | l=expression '-' r=term { _Py_BinOp (l, Sub, r, EXTRA) }
101+ expr_stmt[stmt_ty]: a=expression NEWLINE { _PyAST_Expr (a, EXTRA) }
102+ expression[expr_ty]: ( l=expression '+' r=term { _PyAST_BinOp (l, Add, r, EXTRA) }
103+ | l=expression '-' r=term { _PyAST_BinOp (l, Sub, r, EXTRA) }
104104 | t=term { t }
105105 )
106- term[expr_ty]: ( l=term '*' r=factor { _Py_BinOp (l, Mult, r, EXTRA) }
107- | l=term '/' r=factor { _Py_BinOp (l, Div, r, EXTRA) }
106+ term[expr_ty]: ( l=term '*' r=factor { _PyAST_BinOp (l, Mult, r, EXTRA) }
107+ | l=term '/' r=factor { _PyAST_BinOp (l, Div, r, EXTRA) }
108108 | f=factor { f }
109109 )
110110 factor[expr_ty]: ('(' e=expression ')' { e }
@@ -237,12 +237,12 @@ def test_nasty_mutually_left_recursive(self) -> None:
237237
238238 def test_return_stmt_noexpr_action (self ) -> None :
239239 grammar_source = """
240- start[mod_ty]: a=[statements] ENDMARKER { Module (a, NULL, p->arena) }
240+ start[mod_ty]: a=[statements] ENDMARKER { _PyAST_Module (a, NULL, p->arena) }
241241 statements[asdl_stmt_seq*]: a[asdl_stmt_seq*]=statement+ { a }
242242 statement[stmt_ty]: simple_stmt
243243 simple_stmt[stmt_ty]: small_stmt
244244 small_stmt[stmt_ty]: return_stmt
245- return_stmt[stmt_ty]: a='return' NEWLINE { _Py_Return (NULL, EXTRA) }
245+ return_stmt[stmt_ty]: a='return' NEWLINE { _PyAST_Return (NULL, EXTRA) }
246246 """
247247 test_source = """
248248 stmt = "return"
@@ -252,8 +252,8 @@ def test_return_stmt_noexpr_action(self) -> None:
252252
253253 def test_gather_action_ast (self ) -> None :
254254 grammar_source = """
255- start[mod_ty]: a[asdl_stmt_seq*]=';'.pass_stmt+ NEWLINE ENDMARKER { Module (a, NULL, p->arena) }
256- pass_stmt[stmt_ty]: a='pass' { _Py_Pass (EXTRA)}
255+ start[mod_ty]: a[asdl_stmt_seq*]=';'.pass_stmt+ NEWLINE ENDMARKER { _PyAST_Module (a, NULL, p->arena) }
256+ pass_stmt[stmt_ty]: a='pass' { _PyAST_Pass (EXTRA)}
257257 """
258258 test_source = """
259259 stmt = "pass; pass"
@@ -263,12 +263,12 @@ def test_gather_action_ast(self) -> None:
263263
264264 def test_pass_stmt_action (self ) -> None :
265265 grammar_source = """
266- start[mod_ty]: a=[statements] ENDMARKER { Module (a, NULL, p->arena) }
266+ start[mod_ty]: a=[statements] ENDMARKER { _PyAST_Module (a, NULL, p->arena) }
267267 statements[asdl_stmt_seq*]: a[asdl_stmt_seq*]=statement+ { a }
268268 statement[stmt_ty]: simple_stmt
269269 simple_stmt[stmt_ty]: small_stmt
270270 small_stmt[stmt_ty]: pass_stmt
271- pass_stmt[stmt_ty]: a='pass' NEWLINE { _Py_Pass (EXTRA) }
271+ pass_stmt[stmt_ty]: a='pass' NEWLINE { _PyAST_Pass (EXTRA) }
272272 """
273273 test_source = """
274274 stmt = "pass"
@@ -278,7 +278,7 @@ def test_pass_stmt_action(self) -> None:
278278
279279 def test_if_stmt_action (self ) -> None :
280280 grammar_source = """
281- start[mod_ty]: a=[statements] ENDMARKER { Module (a, NULL, p->arena) }
281+ start[mod_ty]: a=[statements] ENDMARKER { _PyAST_Module (a, NULL, p->arena) }
282282 statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
283283 statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | simple_stmt
284284
@@ -290,11 +290,11 @@ def test_if_stmt_action(self) -> None:
290290
291291 compound_stmt: if_stmt
292292
293- if_stmt: 'if' a=full_expression ':' b=block { _Py_If (a, b, NULL, EXTRA) }
293+ if_stmt: 'if' a=full_expression ':' b=block { _PyAST_If (a, b, NULL, EXTRA) }
294294
295295 small_stmt[stmt_ty]: pass_stmt
296296
297- pass_stmt[stmt_ty]: a='pass' { _Py_Pass (EXTRA) }
297+ pass_stmt[stmt_ty]: a='pass' { _PyAST_Pass (EXTRA) }
298298
299299 full_expression: NAME
300300 """
@@ -306,15 +306,15 @@ def test_if_stmt_action(self) -> None:
306306
307307 def test_same_name_different_types (self ) -> None :
308308 grammar_source = """
309- start[mod_ty]: a[asdl_stmt_seq*]=import_from+ NEWLINE ENDMARKER { Module (a, NULL, p->arena)}
309+ start[mod_ty]: a[asdl_stmt_seq*]=import_from+ NEWLINE ENDMARKER { _PyAST_Module (a, NULL, p->arena)}
310310 import_from[stmt_ty]: ( a='from' !'import' c=simple_name 'import' d=import_as_names_from {
311- _Py_ImportFrom (c->v.Name.id, d, 0, EXTRA) }
311+ _PyAST_ImportFrom (c->v.Name.id, d, 0, EXTRA) }
312312 | a='from' '.' 'import' c=import_as_names_from {
313- _Py_ImportFrom (NULL, c, 1, EXTRA) }
313+ _PyAST_ImportFrom (NULL, c, 1, EXTRA) }
314314 )
315315 simple_name[expr_ty]: NAME
316316 import_as_names_from[asdl_alias_seq*]: a[asdl_alias_seq*]=','.import_as_name_from+ { a }
317- import_as_name_from[alias_ty]: a=NAME 'as' b=NAME { _Py_alias (((expr_ty) a)->v.Name.id, ((expr_ty) b)->v.Name.id, p->arena) }
317+ import_as_name_from[alias_ty]: a=NAME 'as' b=NAME { _PyAST_alias (((expr_ty) a)->v.Name.id, ((expr_ty) b)->v.Name.id, p->arena) }
318318 """
319319 test_source = """
320320 for stmt in ("from a import b as c", "from . import a as b"):
@@ -326,19 +326,19 @@ def test_same_name_different_types(self) -> None:
326326
327327 def test_with_stmt_with_paren (self ) -> None :
328328 grammar_source = """
329- start[mod_ty]: a=[statements] ENDMARKER { Module (a, NULL, p->arena) }
329+ start[mod_ty]: a=[statements] ENDMARKER { _PyAST_Module (a, NULL, p->arena) }
330330 statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
331331 statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
332332 compound_stmt[stmt_ty]: with_stmt
333333 with_stmt[stmt_ty]: (
334334 a='with' '(' b[asdl_withitem_seq*]=','.with_item+ ')' ':' c=block {
335- _Py_With (b, (asdl_stmt_seq*) _PyPegen_singleton_seq(p, c), NULL, EXTRA) }
335+ _PyAST_With (b, (asdl_stmt_seq*) _PyPegen_singleton_seq(p, c), NULL, EXTRA) }
336336 )
337337 with_item[withitem_ty]: (
338- e=NAME o=['as' t=NAME { t }] { _Py_withitem (e, _PyPegen_set_expr_context(p, o, Store), p->arena) }
338+ e=NAME o=['as' t=NAME { t }] { _PyAST_withitem (e, _PyPegen_set_expr_context(p, o, Store), p->arena) }
339339 )
340340 block[stmt_ty]: a=pass_stmt NEWLINE { a } | NEWLINE INDENT a=pass_stmt DEDENT { a }
341- pass_stmt[stmt_ty]: a='pass' { _Py_Pass (EXTRA) }
341+ pass_stmt[stmt_ty]: a='pass' { _PyAST_Pass (EXTRA) }
342342 """
343343 test_source = """
344344 stmt = "with (\\ n a as b,\\ n c as d\\ n): pass"
@@ -352,14 +352,14 @@ def test_with_stmt_with_paren(self) -> None:
352352
353353 def test_ternary_operator (self ) -> None :
354354 grammar_source = """
355- start[mod_ty]: a=expr ENDMARKER { Module (a, NULL, p->arena) }
356- expr[asdl_stmt_seq*]: a=listcomp NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, _Py_Expr (a, EXTRA)) }
355+ start[mod_ty]: a=expr ENDMARKER { _PyAST_Module (a, NULL, p->arena) }
356+ expr[asdl_stmt_seq*]: a=listcomp NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, _PyAST_Expr (a, EXTRA)) }
357357 listcomp[expr_ty]: (
358- a='[' b=NAME c=for_if_clauses d=']' { _Py_ListComp (b, c, EXTRA) }
358+ a='[' b=NAME c=for_if_clauses d=']' { _PyAST_ListComp (b, c, EXTRA) }
359359 )
360360 for_if_clauses[asdl_comprehension_seq*]: (
361361 a[asdl_comprehension_seq*]=(y=[ASYNC] 'for' a=NAME 'in' b=NAME c[asdl_expr_seq*]=('if' z=NAME { z })*
362- { _Py_comprehension(_Py_Name (((expr_ty) a)->v.Name.id, Store, EXTRA), b, c, (y == NULL) ? 0 : 1, p->arena) })+ { a }
362+ { _PyAST_comprehension(_PyAST_Name (((expr_ty) a)->v.Name.id, Store, EXTRA), b, c, (y == NULL) ? 0 : 1, p->arena) })+ { a }
363363 )
364364 """
365365 test_source = """
0 commit comments