summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-06-11 16:30:46 (GMT)
committerGitHub <noreply@github.com>2020-06-11 16:30:46 (GMT)
commit1ed83adb0e95305af858bd41af531e487f54fee7 (patch)
tree5b05876e1800975fd2f0b8021544423f9fd9822a
parent311110abcd8ab648dbf1803e36a8ba5d93fa019b (diff)
downloadcpython-1ed83adb0e95305af858bd41af531e487f54fee7.zip
cpython-1ed83adb0e95305af858bd41af531e487f54fee7.tar.gz
cpython-1ed83adb0e95305af858bd41af531e487f54fee7.tar.bz2
bpo-40939: Remove the old parser (GH-20768)
This commit removes the old parser, the deprecated parser module, the old parser compatibility flags and environment variables and all associated support code and documentation.
-rw-r--r--Doc/c-api/init_config.rst10
-rw-r--r--Doc/using/cmdline.rst11
-rw-r--r--Include/cpython/initconfig.h4
-rw-r--r--Lib/subprocess.py2
-rw-r--r--Lib/test/support/__init__.py10
-rw-r--r--Lib/test/test_embed.py4
-rw-r--r--Lib/test/test_exceptions.py6
-rw-r--r--Lib/test/test_flufl.py4
-rw-r--r--Lib/test/test_fstring.py3
-rw-r--r--Lib/test/test_grammar.py110
-rw-r--r--Lib/test/test_parser.py1046
-rw-r--r--Lib/test/test_peg_parser.py803
-rw-r--r--Lib/test/test_string_literals.py7
-rw-r--r--Lib/test/test_syntax.py1
-rw-r--r--Lib/test/test_traceback.py1
-rw-r--r--Makefile.pre.in46
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2020-06-10-11-27-15.bpo-40939.DO-wAI.rst1
-rw-r--r--Modules/Setup7
-rw-r--r--Modules/_peg_parser.c153
-rw-r--r--Modules/parsermodule.c1222
-rw-r--r--PC/config.c4
-rw-r--r--PCbuild/pythoncore.vcxproj21
-rw-r--r--PCbuild/pythoncore.vcxproj.filters21
-rw-r--r--PCbuild/regen.vcxproj17
-rw-r--r--Parser/acceler.c123
-rw-r--r--Parser/grammar1.c47
-rw-r--r--Parser/listnode.c71
-rw-r--r--Parser/parser.c24656
-rw-r--r--Parser/parser.h49
-rw-r--r--Parser/parsetok.c486
-rw-r--r--Parser/peg_api.c (renamed from Parser/pegen/peg_api.c)2
-rw-r--r--Parser/pegen.c (renamed from Parser/pegen/pegen.c)4
-rw-r--r--Parser/pegen.h (renamed from Parser/pegen/pegen.h)0
-rw-r--r--Parser/pegen/parse.c24415
-rw-r--r--Parser/pgen/__init__.py0
-rw-r--r--Parser/pgen/__main__.py43
-rw-r--r--Parser/pgen/automata.py400
-rw-r--r--Parser/pgen/grammar.py147
-rw-r--r--Parser/pgen/keywordgen.py59
-rw-r--r--Parser/pgen/metaparser.py152
-rw-r--r--Parser/pgen/pgen.py310
-rw-r--r--Parser/pgen/token.py38
-rw-r--r--Parser/string_parser.c (renamed from Parser/pegen/parse_string.c)4
-rw-r--r--Parser/string_parser.h (renamed from Parser/pegen/parse_string.h)0
-rw-r--r--Programs/_testembed.c1
-rw-r--r--Python/ast.c5289
-rw-r--r--Python/compile.c15
-rw-r--r--Python/initconfig.c10
-rw-r--r--Python/pylifecycle.c3
-rw-r--r--Python/pythonrun.c477
-rw-r--r--Tools/peg_generator/pegen/build.py5
-rw-r--r--configure.ac2
-rw-r--r--setup.py3
53 files changed, 24397 insertions, 35928 deletions
diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst
index b7298ba..9b0728d 100644
--- a/Doc/c-api/init_config.rst
+++ b/Doc/c-api/init_config.rst
@@ -695,16 +695,6 @@ PyConfig
:data:`sys._xoptions`.
- .. c:member:: int _use_peg_parser
-
- Enable PEG parser? Default: 1.
-
- Set to 0 by :option:`-X oldparser <-X>` and :envvar:`PYTHONOLDPARSER`.
-
- See also :pep:`617`.
-
- .. deprecated-removed:: 3.9 3.10
-
If ``parse_argv`` is non-zero, ``argv`` arguments are parsed the same
way the regular Python parses command line arguments, and Python
arguments are stripped from ``argv``: see :ref:`Command Line Arguments
diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
index f91ab02..7aacd8f 100644
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -426,8 +426,6 @@ Miscellaneous options
defines the following possible values:
* ``-X faulthandler`` to enable :mod:`faulthandler`;
- * ``-X oldparser``: enable the traditional LL(1) parser. See also
- :envvar:`PYTHONOLDPARSER` and :pep:`617`.
* ``-X showrefcount`` to output the total reference count and number of used
memory blocks when the program finishes or after each statement in the
interactive interpreter. This only works on debug builds.
@@ -587,15 +585,6 @@ conflict.
:option:`-d` multiple times.
-.. envvar:: PYTHONOLDPARSER
-
- If this is set to a non-empty string, enable the traditional LL(1) parser.
-
- See also the :option:`-X` ``oldparser`` option and :pep:`617`.
-
- .. deprecated-removed:: 3.9 3.10
-
-
.. envvar:: PYTHONINSPECT
If this is set to a non-empty string it is equivalent to specifying the
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index 5793321..5b05eab 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -144,10 +144,6 @@ typedef struct {
Set to 1 by -X faulthandler and PYTHONFAULTHANDLER. -1 means unset. */
int faulthandler;
- /* Enable PEG parser?
- 1 by default, set to 0 by -X oldparser and PYTHONOLDPARSER */
- int _use_peg_parser;
-
/* Enable tracemalloc?
Set by -X tracemalloc=N and PYTHONTRACEMALLOC. -1 means unset */
int tracemalloc;
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 13600c2..86fdf27 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -326,7 +326,7 @@ def _args_from_interpreter_flags():
if dev_mode:
args.extend(('-X', 'dev'))
for opt in ('faulthandler', 'tracemalloc', 'importtime',
- 'showrefcount', 'utf8', 'oldparser'):
+ 'showrefcount', 'utf8'):
if opt in xoptions:
value = xoptions[opt]
if value is True:
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index f078ad7..498da64 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1958,13 +1958,3 @@ def wait_process(pid, *, exitcode, timeout=None):
# sanity check: it should not fail in practice
if pid2 != pid:
raise AssertionError(f"pid {pid2} != pid {pid}")
-
-
-def use_old_parser():
- import _testinternalcapi
- config = _testinternalcapi.get_configs()
- return (config['config']['_use_peg_parser'] == 0)
-
-
-def skip_if_new_parser(msg):
- return unittest.skipIf(not use_old_parser(), msg)
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index b7b7058..fe47289 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -347,7 +347,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'isolated': 0,
'use_environment': 1,
'dev_mode': 0,
- '_use_peg_parser': 1,
'install_signal_handlers': 1,
'use_hash_seed': 0,
@@ -733,7 +732,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'import_time': 1,
'show_ref_count': 1,
'malloc_stats': 1,
- '_use_peg_parser': 0,
'stdio_encoding': 'iso8859-1',
'stdio_errors': 'replace',
@@ -807,7 +805,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'warnoptions': ['EnvVar'],
'platlibdir': 'env_platlibdir',
'module_search_paths': self.IGNORE_CONFIG,
- '_use_peg_parser': 0,
}
self.check_all_configs("test_init_compat_env", config, preconfig,
api=API_COMPAT)
@@ -837,7 +834,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'warnoptions': ['EnvVar'],
'platlibdir': 'env_platlibdir',
'module_search_paths': self.IGNORE_CONFIG,
- '_use_peg_parser': 0,
}
self.check_all_configs("test_init_python_env", config, preconfig,
api=API_PYTHON)
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 196f31e..feae31b 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -251,9 +251,9 @@ class ExceptionTests(unittest.TestCase):
check('def f():\n x, y: int', 2, 3)
check('[*x for x in xs]', 1, 2)
check('foo(x for x in range(10), 100)', 1, 5)
- check('(yield i) = 2', 1, 1 if support.use_old_parser() else 2)
- check('def f(*):\n pass', 1, 7 if support.use_old_parser() else 8)
- check('for 1 in []: pass', 1, 5 if support.use_old_parser() else 7)
+ check('(yield i) = 2', 1, 2)
+ check('def f(*):\n pass', 1, 8)
+ check('for 1 in []: pass', 1, 7)
@cpython_only
def testSettingException(self):
diff --git a/Lib/test/test_flufl.py b/Lib/test/test_flufl.py
index 2228585..0ff54aa 100644
--- a/Lib/test/test_flufl.py
+++ b/Lib/test/test_flufl.py
@@ -20,7 +20,7 @@ class FLUFLTests(unittest.TestCase):
self.assertTrue(cm.exception.lineno, 2)
# The old parser reports the end of the token and the new
# parser reports the start of the token
- self.assertEqual(cm.exception.offset, 4 if support.use_old_parser() else 3)
+ self.assertEqual(cm.exception.offset, 3)
def test_guido_as_bdfl(self):
code = '2 {0} 3'
@@ -33,7 +33,7 @@ class FLUFLTests(unittest.TestCase):
self.assertEqual(cm.exception.lineno, 1)
# The old parser reports the end of the token and the new
# parser reports the start of the token
- self.assertEqual(cm.exception.offset, 4 if support.use_old_parser() else 3)
+ self.assertEqual(cm.exception.offset, 3)
if __name__ == '__main__':
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index 9048e89..9eb7ebe 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -12,7 +12,7 @@ import os
import types
import decimal
import unittest
-from test.support import temp_cwd, use_old_parser
+from test.support import temp_cwd
from test.support.script_helper import assert_python_failure
a_global = 'global variable'
@@ -1049,7 +1049,6 @@ non-important content
r"f'{1000:j}'",
])
- @unittest.skipIf(use_old_parser(), "The old parser only supports <fstring> as the filename")
def test_filename_in_syntaxerror(self):
# see issue 38964
with temp_cwd() as cwd:
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index e1a402e..ef7d1a1 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -1,7 +1,7 @@
# Python test set -- part 1, grammar.
# This just tests whether the parser accepts them all.
-from test.support import check_syntax_error, check_syntax_warning, use_old_parser
+from test.support import check_syntax_error, check_syntax_warning
import inspect
import unittest
import sys
@@ -1714,69 +1714,53 @@ class GrammarTests(unittest.TestCase):
with manager() as x, manager():
pass
- if not use_old_parser():
- test_cases = [
- """if 1:
- with (
- manager()
- ):
- pass
- """,
- """if 1:
- with (
- manager() as x
- ):
- pass
- """,
- """if 1:
- with (
- manager() as (x, y),
- manager() as z,
- ):
- pass
- """,
- """if 1:
- with (
- manager(),
- manager()
- ):
- pass
- """,
- """if 1:
- with (
- manager() as x,
- manager() as y
- ):
- pass
- """,
- """if 1:
- with (
- manager() as x,
- manager()
- ):
- pass
- """,
- """if 1:
- with (
- manager() as x,
- manager() as y,
- manager() as z,
- ):
- pass
- """,
- """if 1:
- with (
- manager() as x,
- manager() as y,
- manager(),
- ):
- pass
- """,
- ]
- for case in test_cases:
- with self.subTest(case=case):
- compile(case, "<string>", "exec")
+ with (
+ manager()
+ ):
+ pass
+
+ with (
+ manager() as x
+ ):
+ pass
+
+ with (
+ manager() as (x, y),
+ manager() as z,
+ ):
+ pass
+
+ with (
+ manager(),
+ manager()
+ ):
+ pass
+ with (
+ manager() as x,
+ manager() as y
+ ):
+ pass
+
+ with (
+ manager() as x,
+ manager()
+ ):
+ pass
+
+ with (
+ manager() as x,
+ manager() as y,
+ manager() as z,
+ ):
+ pass
+
+ with (
+ manager() as x,
+ manager() as y,
+ manager(),
+ ):
+ pass
def test_if_else_expr(self):
# Test ifelse expressions in various cases
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
deleted file mode 100644
index a4d2cdc..0000000
--- a/Lib/test/test_parser.py
+++ /dev/null
@@ -1,1046 +0,0 @@
-import copy
-import warnings
-with warnings.catch_warnings():
- warnings.filterwarnings('ignore', 'The parser module is deprecated',
- DeprecationWarning)
- import parser
-import pickle
-import unittest
-import operator
-import struct
-from test import support
-from test.support.script_helper import assert_python_failure
-from test.support.script_helper import assert_python_ok
-
-#
-# First, we test that we can generate trees from valid source fragments,
-# and that these valid trees are indeed allowed by the tree-loading side
-# of the parser module.
-#
-
-class RoundtripLegalSyntaxTestCase(unittest.TestCase):
-
- def roundtrip(self, f, s):
- st1 = f(s)
- t = st1.totuple()
- try:
- st2 = parser.sequence2st(t)
- except parser.ParserError as why:
- self.fail("could not roundtrip %r: %s" % (s, why))
-
- self.assertEqual(t, st2.totuple(),
- "could not re-generate syntax tree")
-
- def check_expr(self, s):
- self.roundtrip(parser.expr, s)
-
- def test_flags_passed(self):
- # The unicode literals flags has to be passed from the parser to AST
- # generation.
- suite = parser.suite("from __future__ import unicode_literals; x = ''")
- code = suite.compile()
- scope = {}
- exec(code, {}, scope)
- self.assertIsInstance(scope["x"], str)
-
- def check_suite(self, s):
- self.roundtrip(parser.suite, s)
-
- def test_yield_statement(self):
- self.check_suite("def f(): yield 1")
- self.check_suite("def f(): yield")
- self.check_suite("def f(): x += yield")
- self.check_suite("def f(): x = yield 1")
- self.check_suite("def f(): x = y = yield 1")
- self.check_suite("def f(): x = yield")
- self.check_suite("def f(): x = y = yield")
- self.check_suite("def f(): 1 + (yield)*2")
- self.check_suite("def f(): (yield 1)*2")
- self.check_suite("def f(): return; yield 1")
- self.check_suite("def f(): yield 1; return")
- self.check_suite("def f(): yield from 1")
- self.check_suite("def f(): x = yield from 1")
- self.check_suite("def f(): f((yield from 1))")
- self.check_suite("def f(): yield 1; return 1")
- self.check_suite("def f():\n"
- " for x in range(30):\n"
- " yield x\n")
- self.check_suite("def f():\n"
- " if (yield):\n"
- " yield x\n")
-
- def test_await_statement(self):
- self.check_suite("async def f():\n await smth()")
- self.check_suite("async def f():\n foo = await smth()")
- self.check_suite("async def f():\n foo, bar = await smth()")
- self.check_suite("async def f():\n (await smth())")
- self.check_suite("async def f():\n foo((await smth()))")
- self.check_suite("async def f():\n await foo(); return 42")
-
- def test_async_with_statement(self):
- self.check_suite("async def f():\n async with 1: pass")
- self.check_suite("async def f():\n async with a as b, c as d: pass")
-
- def test_async_for_statement(self):
- self.check_suite("async def f():\n async for i in (): pass")
- self.check_suite("async def f():\n async for i, b in (): pass")
-
- def test_nonlocal_statement(self):
- self.check_suite("def f():\n"
- " x = 0\n"
- " def g():\n"
- " nonlocal x\n")
- self.check_suite("def f():\n"
- " x = y = 0\n"
- " def g():\n"
- " nonlocal x, y\n")
-
- def test_expressions(self):
- self.check_expr("foo(1)")
- self.check_expr("[1, 2, 3]")
- self.check_expr("[x**3 for x in range(20)]")
- self.check_expr("[x**3 for x in range(20) if x % 3]")
- self.check_expr("[x**3 for x in range(20) if x % 2 if x % 3]")
- self.check_expr("list(x**3 for x in range(20))")
- self.check_expr("list(x**3 for x in range(20) if x % 3)")
- self.check_expr("list(x**3 for x in range(20) if x % 2 if x % 3)")
- self.check_expr("foo(*args)")
- self.check_expr("foo(*args, **kw)")
- self.check_expr("foo(**kw)")
- self.check_expr("foo(key=value)")
- self.check_expr("foo(key=value, *args)")
- self.check_expr("foo(key=value, *args, **kw)")
- self.check_expr("foo(key=value, **kw)")
- self.check_expr("foo(a, b, c, *args)")
- self.check_expr("foo(a, b, c, *args, **kw)")
- self.check_expr("foo(a, b, c, **kw)")
- self.check_expr("foo(a, *args, keyword=23)")
- self.check_expr("foo + bar")
- self.check_expr("foo - bar")
- self.check_expr("foo * bar")
- self.check_expr("foo / bar")
- self.check_expr("foo // bar")
- self.check_expr("(foo := 1)")
- self.check_expr("lambda: 0")
- self.check_expr("lambda x: 0")
- self.check_expr("lambda *y: 0")
- self.check_expr("lambda *y, **z: 0")
- self.check_expr("lambda **z: 0")
- self.check_expr("lambda x, y: 0")
- self.check_expr("lambda foo=bar: 0")
- self.check_expr("lambda foo=bar, spaz=nifty+spit: 0")
- self.check_expr("lambda foo=bar, **z: 0")
- self.check_expr("lambda foo=bar, blaz=blat+2, **z: 0")
- self.check_expr("lambda foo=bar, blaz=blat+2, *y, **z: 0")
- self.check_expr("lambda x, *y, **z: 0")
- self.check_expr("(x for x in range(10))")
- self.check_expr("foo(x for x in range(10))")
- self.check_expr("...")
- self.check_expr("a[...]")
-
- def test_simple_expression(self):
- # expr_stmt
- self.check_suite("a")
-
- def test_simple_assignments(self):
- self.check_suite("a = b")
- self.check_suite("a = b = c = d = e")
-
- def test_var_annot(self):
- self.check_suite("x: int = 5")
- self.check_suite("y: List[T] = []; z: [list] = fun()")
- self.check_suite("x: tuple = (1, 2)")
- self.check_suite("d[f()]: int = 42")
- self.check_suite("f(d[x]): str = 'abc'")
- self.check_suite("x.y.z.w: complex = 42j")
- self.check_suite("x: int")
- self.check_suite("def f():\n"
- " x: str\n"
- " y: int = 5\n")
- self.check_suite("class C:\n"
- " x: str\n"
- " y: int = 5\n")
- self.check_suite("class C:\n"
- " def __init__(self, x: int) -> None:\n"
- " self.x: int = x\n")
- # double check for nonsense
- with self.assertRaises(SyntaxError):
- exec("2+2: int", {}, {})
- with self.assertRaises(SyntaxError):
- exec("[]: int = 5", {}, {})
- with self.assertRaises(SyntaxError):
- exec("x, *y, z: int = range(5)", {}, {})
- with self.assertRaises(SyntaxError):
- exec("x: int = 1, y = 2", {}, {})
- with self.assertRaises(SyntaxError):
- exec("u = v: int", {}, {})
- with self.assertRaises(SyntaxError):
- exec("False: int", {}, {})
- with self.assertRaises(SyntaxError):
- exec("x.False: int", {}, {})
- with self.assertRaises(SyntaxError):
- exec("x.y,: int", {}, {})
- with self.assertRaises(SyntaxError):
- exec("[0]: int", {}, {})
- with self.assertRaises(SyntaxError):
- exec("f(): int", {}, {})
-
- def test_simple_augmented_assignments(self):
- self.check_suite("a += b")
- self.check_suite("a -= b")
- self.check_suite("a *= b")
- self.check_suite("a /= b")
- self.check_suite("a //= b")
- self.check_suite("a %= b")
- self.check_suite("a &= b")
- self.check_suite("a |= b")
- self.check_suite("a ^= b")
- self.check_suite("a <<= b")
- self.check_suite("a >>= b")
- self.check_suite("a **= b")
-
- def test_function_defs(self):
- self.check_suite("def f(): pass")
- self.check_suite("def f(*args): pass")
- self.check_suite("def f(*args, **kw): pass")
- self.check_suite("def f(**kw): pass")
- self.check_suite("def f(foo=bar): pass")
- self.check_suite("def f(foo=bar, *args): pass")
- self.check_suite("def f(foo=bar, *args, **kw): pass")
- self.check_suite("def f(foo=bar, **kw): pass")
-
- self.check_suite("def f(a, b): pass")
- self.check_suite("def f(a, b, *args): pass")
- self.check_suite("def f(a, b, *args, **kw): pass")
- self.check_suite("def f(a, b, **kw): pass")
- self.check_suite("def f(a, b, foo=bar): pass")
- self.check_suite("def f(a, b, foo=bar, *args): pass")
- self.check_suite("def f(a, b, foo=bar, *args, **kw): pass")
- self.check_suite("def f(a, b, foo=bar, **kw): pass")
-
- self.check_suite("@staticmethod\n"
- "def f(): pass")
- self.check_suite("@staticmethod\n"
- "@funcattrs(x, y)\n"
- "def f(): pass")
- self.check_suite("@funcattrs()\n"
- "def f(): pass")
-
- self.check_suite("@False or x\n"
- "def f(): pass")
- self.check_suite("@d := x\n"
- "def f(): pass")
- self.check_suite("@lambda f: x(f)\n"
- "def f(): pass")
- self.check_suite("@[..., x, ...][1]\n"
- "def f(): pass")
- self.check_suite("@x(x)(x)\n"
- "def f(): pass")
- self.check_suite("@(x, x)\n"
- "def f(): pass")
- self.check_suite("@...\n"
- "def f(): pass")
- self.check_suite("@None\n"
- "def f(): pass")
- self.check_suite("@w @(x @y) @(z)\n"
- "def f(): pass")
- self.check_suite("@w[x].y.z\n"
- "def f(): pass")
-
- # keyword-only arguments
- self.check_suite("def f(*, a): pass")
- self.check_suite("def f(*, a = 5): pass")
- self.check_suite("def f(*, a = 5, b): pass")
- self.check_suite("def f(*, a, b = 5): pass")
- self.check_suite("def f(*, a, b = 5, **kwds): pass")
- self.check_suite("def f(*args, a): pass")
- self.check_suite("def f(*args, a = 5): pass")
- self.check_suite("def f(*args, a = 5, b): pass")
- self.check_suite("def f(*args, a, b = 5): pass")
- self.check_suite("def f(*args, a, b = 5, **kwds): pass")
-
- # positional-only arguments
- self.check_suite("def f(a, /): pass")
- self.check_suite("def f(a, /,): pass")
- self.check_suite("def f(a, b, /): pass")
- self.check_suite("def f(a, b, /, c): pass")
- self.check_suite("def f(a, b, /, c = 6): pass")
- self.check_suite("def f(a, b, /, c, *, d): pass")
- self.check_suite("def f(a, b, /, c = 1, *, d): pass")
- self.check_suite("def f(a, b, /, c, *, d = 1): pass")
- self.check_suite("def f(a, b=1, /, c=2, *, d = 3): pass")
- self.check_suite("def f(a=0, b=1, /, c=2, *, d = 3): pass")
-
- # function annotations
- self.check_suite("def f(a: int): pass")
- self.check_suite("def f(a: int = 5): pass")
- self.check_suite("def f(*args: list): pass")
- self.check_suite("def f(**kwds: dict): pass")
- self.check_suite("def f(*, a: int): pass")
- self.check_suite("def f(*, a: int = 5): pass")
- self.check_suite("def f() -> int: pass")
-
- def test_class_defs(self):
- self.check_suite("class foo():pass")
- self.check_suite("class foo(object):pass")
- self.check_suite("@class_decorator\n"
- "class foo():pass")
- self.check_suite("@class_decorator(arg)\n"
- "class foo():pass")
- self.check_suite("@decorator1\n"
- "@decorator2\n"
- "class foo():pass")
-
- self.check_suite("@False or x\n"
- "class C: pass")
- self.check_suite("@d := x\n"
- "class C: pass")
- self.check_suite("@lambda f: x(f)\n"
- "class C: pass")
- self.check_suite("@[..., x, ...][1]\n"
- "class C: pass")
- self.check_suite("@x(x)(x)\n"
- "class C: pass")
- self.check_suite("@(x, x)\n"
- "class C: pass")
- self.check_suite("@...\n"
- "class C: pass")
- self.check_suite("@None\n"
- "class C: pass")
- self.check_suite("@w @(x @y) @(z)\n"
- "class C: pass")
- self.check_suite("@w[x].y.z\n"
- "class C: pass")
-
- def test_import_from_statement(self):
- self.check_suite("from sys.path import *")
- self.check_suite("from sys.path import dirname")
- self.check_suite("from sys.path import (dirname)")
- self.check_suite("from sys.path import (dirname,)")
- self.check_suite("from sys.path import dirname as my_dirname")
- self.check_suite("from sys.path import (dirname as my_dirname)")
- self.check_suite("from sys.path import (dirname as my_dirname,)")
- self.check_suite("from sys.path import dirname, basename")
- self.check_suite("from sys.path import (dirname, basename)")
- self.check_suite("from sys.path import (dirname, basename,)")
- self.check_suite(
- "from sys.path import dirname as my_dirname, basename")
- self.check_suite(
- "from sys.path import (dirname as my_dirname, basename)")
- self.check_suite(
- "from sys.path import (dirname as my_dirname, basename,)")
- self.check_suite(
- "from sys.path import dirname, basename as my_basename")
- self.check_suite(
- "from sys.path import (dirname, basename as my_basename)")
- self.check_suite(
- "from sys.path import (dirname, basename as my_basename,)")
- self.check_suite("from .bogus import x")
-
- def test_basic_import_statement(self):
- self.check_suite("import sys")
- self.check_suite("import sys as system")
- self.check_suite("import sys, math")
- self.check_suite("import sys as system, math")
- self.check_suite("import sys, math as my_math")
-
- def test_relative_imports(self):
- self.check_suite("from . import name")
- self.check_suite("from .. import name")
- # check all the way up to '....', since '...' is tokenized
- # differently from '.' (it's an ellipsis token).
- self.check_suite("from ... import name")
- self.check_suite("from .... import name")
- self.check_suite("from .pkg import name")
- self.check_suite("from ..pkg import name")
- self.check_suite("from ...pkg import name")
- self.check_suite("from ....pkg import name")
-
- def test_pep263(self):
- self.check_suite("# -*- coding: iso-8859-1 -*-\n"
- "pass\n")
-
- def test_assert(self):
- self.check_suite("assert alo < ahi and blo < bhi\n")
-
- def test_with(self):
- self.check_suite("with open('x'): pass\n")
- self.check_suite("with open('x') as f: pass\n")
- self.check_suite("with open('x') as f, open('y') as g: pass\n")
-
- def test_try_stmt(self):
- self.check_suite("try: pass\nexcept: pass\n")
- self.check_suite("try: pass\nfinally: pass\n")
- self.check_suite("try: pass\nexcept A: pass\nfinally: pass\n")
- self.check_suite("try: pass\nexcept A: pass\nexcept: pass\n"
- "finally: pass\n")
- self.check_suite("try: pass\nexcept: pass\nelse: pass\n")
- self.check_suite("try: pass\nexcept: pass\nelse: pass\n"
- "finally: pass\n")
-
- def test_if_stmt(self):
- self.check_suite("if True:\n pass\nelse:\n pass\n")
- self.check_suite("if True:\n pass\nelif True:\n pass\nelse:\n pass\n")
-
- def test_position(self):
- # An absolutely minimal test of position information. Better
- # tests would be a big project.
- code = "def f(x):\n return x + 1"
- st = parser.suite(code)
-
- def walk(tree):
- node_type = tree[0]
- next = tree[1]
- if isinstance(next, (tuple, list)):
- for elt in tree[1:]:
- for x in walk(elt):
- yield x
- else:
- yield tree
-
- expected = [
- (1, 'def', 1, 0),
- (1, 'f', 1, 4),
- (7, '(', 1, 5),
- (1, 'x', 1, 6),
- (8, ')', 1, 7),
- (11, ':', 1, 8),
- (4, '', 1, 9),
- (5, '', 2, -1),
- (1, 'return', 2, 4),
- (1, 'x', 2, 11),
- (14, '+', 2, 13),
- (2, '1', 2, 15),
- (4, '', 2, 16),
- (6, '', 2, -1),
- (4, '', 2, -1),
- (0, '', 2, -1),
- ]
-
- self.assertEqual(list(walk(st.totuple(line_info=True, col_info=True))),
- expected)
- self.assertEqual(list(walk(st.totuple())),
- [(t, n) for t, n, l, c in expected])
- self.assertEqual(list(walk(st.totuple(line_info=True))),
- [(t, n, l) for t, n, l, c in expected])
- self.assertEqual(list(walk(st.totuple(col_info=True))),
- [(t, n, c) for t, n, l, c in expected])
- self.assertEqual(list(walk(st.tolist(line_info=True, col_info=True))),
- [list(x) for x in expected])
- self.assertEqual(list(walk(parser.st2tuple(st, line_info=True,
- col_info=True))),
- expected)
- self.assertEqual(list(walk(parser.st2list(st, line_info=True,
- col_info=True))),
- [list(x) for x in expected])
-
- def test_extended_unpacking(self):
- self.check_suite("*a = y")
- self.check_suite("x, *b, = m")
- self.check_suite("[*a, *b] = y")
- self.check_suite("for [*x, b] in x: pass")
-
- def test_raise_statement(self):
- self.check_suite("raise\n")
- self.check_suite("raise e\n")
- self.check_suite("try:\n"
- " suite\n"
- "except Exception as e:\n"
- " raise ValueError from e\n")
-
- def test_list_displays(self):
- self.check_expr('[]')
- self.check_expr('[*{2}, 3, *[4]]')
-
- def test_set_displays(self):
- self.check_expr('{*{2}, 3, *[4]}')
- self.check_expr('{2}')
- self.check_expr('{2,}')
- self.check_expr('{2, 3}')
- self.check_expr('{2, 3,}')
-
- def test_dict_displays(self):
- self.check_expr('{}')
- self.check_expr('{a:b}')
- self.check_expr('{a:b,}')
- self.check_expr('{a:b, c:d}')
- self.check_expr('{a:b, c:d,}')
- self.check_expr('{**{}}')
- self.check_expr('{**{}, 3:4, **{5:6, 7:8}}')
-
- def test_argument_unpacking(self):
- self.check_expr("f(*a, **b)")
- self.check_expr('f(a, *b, *c, *d)')
- self.check_expr('f(**a, **b)')
- self.check_expr('f(2, *a, *b, **b, **c, **d)')
- self.check_expr("f(*b, *() or () and (), **{} and {}, **() or {})")
-
- def test_set_comprehensions(self):
- self.check_expr('{x for x in seq}')
- self.check_expr('{f(x) for x in seq}')
- self.check_expr('{f(x) for x in seq if condition(x)}')
-
- def test_dict_comprehensions(self):
- self.check_expr('{x:x for x in seq}')
- self.check_expr('{x**2:x[3] for x in seq if condition(x)}')
- self.check_expr('{x:x for x in seq1 for y in seq2 if condition(x, y)}')
-
- def test_named_expressions(self):
- self.check_suite("(a := 1)")
- self.check_suite("(a := a)")
- self.check_suite("if (match := pattern.search(data)) is None: pass")
- self.check_suite("while match := pattern.search(f.read()): pass")
- self.check_suite("[y := f(x), y**2, y**3]")
- self.check_suite("filtered_data = [y for x in data if (y := f(x)) is None]")
- self.check_suite("(y := f(x))")
- self.check_suite("y0 = (y1 := f(x))")
- self.check_suite("foo(x=(y := f(x)))")
- self.check_suite("def foo(answer=(p := 42)): pass")
- self.check_suite("def foo(answer: (p := 42) = 5): pass")
- self.check_suite("lambda: (x := 1)")
- self.check_suite("(x := lambda: 1)")
- self.check_suite("(x := lambda: (y := 1))") # not in PEP
- self.check_suite("lambda line: (m := re.match(pattern, line)) and m.group(1)")
- self.check_suite("x = (y := 0)")
- self.check_suite("(z:=(y:=(x:=0)))")
- self.check_suite("(info := (name, phone, *rest))")
- self.check_suite("(x:=1,2)")
- self.check_suite("(total := total + tax)")
- self.check_suite("len(lines := f.readlines())")
- self.check_suite("foo(x := 3, cat='vector')")
- self.check_suite("foo(cat=(category := 'vector'))")
- self.check_suite("if any(len(longline := l) >= 100 for l in lines): print(longline)")
- self.check_suite(
- "if env_base := os.environ.get('PYTHONUSERBASE', None): return env_base"
- )
- self.check_suite(
- "if self._is_special and (ans := self._check_nans(context=context)): return ans"
- )
- self.check_suite("foo(b := 2, a=1)")
- self.check_suite("foo(b := 2, a=1)")
- self.check_suite("foo((b := 2), a=1)")
- self.check_suite("foo(c=(b := 2), a=1)")
- self.check_suite("{(x := C(i)).q: x for i in y}")
-
-
-#
-# Second, we take *invalid* trees and make sure we get ParserError
-# rejections for them.
-#
-
-class IllegalSyntaxTestCase(unittest.TestCase):
-
- def check_bad_tree(self, tree, label):
- try:
- parser.sequence2st(tree)
- except parser.ParserError:
- pass
- else:
- self.fail("did not detect invalid tree for %r" % label)
-
- def test_junk(self):
- # not even remotely valid:
- self.check_bad_tree((1, 2, 3), "<junk>")
-
- def test_illegal_terminal(self):
- tree = \
- (257,
- (269,
- (270,
- (271,
- (277,
- (1,))),
- (4, ''))),
- (4, ''),
- (0, ''))
- self.check_bad_tree(tree, "too small items in terminal node")
- tree = \
- (257,
- (269,
- (270,
- (271,
- (277,
- (1, b'pass'))),
- (4, ''))),
- (4, ''),
- (0, ''))
- self.check_bad_tree(tree, "non-string second item in terminal node")
- tree = \
- (257,
- (269,
- (270,
- (271,
- (277,
- (1, 'pass', '0', 0))),
- (4, ''))),
- (4, ''),
- (0, ''))
- self.check_bad_tree(tree, "non-integer third item in terminal node")
- tree = \
- (257,
- (269,
- (270,
- (271,
- (277,
- (1, 'pass', 0, 0))),
- (4, ''))),
- (4, ''),
- (0, ''))
- self.check_bad_tree(tree, "too many items in terminal node")
-
- def test_illegal_yield_1(self):
- # Illegal yield statement: def f(): return 1; yield 1
- tree = \
- (257,
- (264,
- (285,
- (259,
- (1, 'def'),
- (1, 'f'),
- (260, (7, '('), (8, ')')),
- (11, ':'),
- (291,
- (4, ''),
- (5, ''),
- (264,
- (265,
- (266,
- (272,
- (275,
- (1, 'return'),
- (313,
- (292,
- (293,
- (294,
- (295,
- (297,
- (298,
- (299,
- (300,
- (301,
- (302, (303, (304, (305, (2, '1')))))))))))))))))),
- (264,
- (265,
- (266,
- (272,
- (276,
- (1, 'yield'),
- (313,
- (292,
- (293,
- (294,
- (295,
- (297,
- (298,
- (299,
- (300,
- (301,
- (302,
- (303, (304, (305, (2, '1')))))))))))))))))),
- (4, ''))),
- (6, ''))))),
- (4, ''),
- (0, ''))))
- self.check_bad_tree(tree, "def f():\n return 1\n yield 1")
-
- def test_illegal_yield_2(self):
- # Illegal return in generator: def f(): return 1; yield 1
- tree = \
- (257,
- (264,
- (265,
- (266,
- (278,
- (1, 'from'),
- (281, (1, '__future__')),
- (1, 'import'),
- (279, (1, 'generators')))),
- (4, ''))),
- (264,
- (285,
- (259,
- (1, 'def'),
- (1, 'f'),
- (260, (7, '('), (8, ')')),
- (11, ':'),
- (291,
- (4, ''),
- (5, ''),
- (264,
- (265,
- (266,
- (272,
- (275,
- (1, 'return'),
- (313,
- (292,
- (293,
- (294,
- (295,
- (297,
- (298,
- (299,
- (300,
- (301,
- (302, (303, (304, (305, (2, '1')))))))))))))))))),
- (264,
- (265,
- (266,
- (272,
- (276,
- (1, 'yield'),
- (313,
- (292,
- (293,
- (294,
- (295,
- (297,
- (298,
- (299,
- (300,
- (301,
- (302,
- (303, (304, (305, (2, '1')))))))))))))))))),
- (4, ''))),
- (6, ''))))),
- (4, ''),
- (0, ''))))
- self.check_bad_tree(tree, "def f():\n return 1\n yield 1")
-
- def test_a_comma_comma_c(self):
- # Illegal input: a,,c
- tree = \
- (258,
- (311,
- (290,
- (291,
- (292,
- (293,
- (295,
- (296,
- (297,
- (298, (299, (300, (301, (302, (303, (1, 'a')))))))))))))),
- (12, ','),
- (12, ','),
- (290,
- (291,
- (292,
- (293,
- (295,
- (296,
- (297,
- (298, (299, (300, (301, (302, (303, (1, 'c'))))))))))))))),
- (4, ''),
- (0, ''))
- self.check_bad_tree(tree, "a,,c")
-
- def test_illegal_operator(self):
- # Illegal input: a $= b
- tree = \
- (257,
- (264,
- (265,
- (266,
- (267,
- (312,
- (291,
- (292,
- (293,
- (294,
- (296,
- (297,
- (298,
- (299,
- (300, (301, (302, (303, (304, (1, 'a'))))))))))))))),
- (268, (37, '$=')),
- (312,
- (291,
- (292,
- (293,
- (294,
- (296,
- (297,
- (298,
- (299,
- (300, (301, (302, (303, (304, (1, 'b'))))))))))))))))),
- (4, ''))),
- (0, ''))
- self.check_bad_tree(tree, "a $= b")
-
- def test_malformed_global(self):
- #doesn't have global keyword in ast
- tree = (257,
- (264,
- (265,
- (266,
- (282, (1, 'foo'))), (4, ''))),
- (4, ''),
- (0, ''))
- self.check_bad_tree(tree, "malformed global ast")
-
- def test_missing_import_source(self):
- # from import fred
- tree = \
- (257,
- (268,
- (269,
- (270,
- (282,
- (284, (1, 'from'), (1, 'import'),
- (287, (285, (1, 'fred')))))),
- (4, ''))),
- (4, ''), (0, ''))
- self.check_bad_tree(tree, "from import fred")
-
- def test_illegal_encoding(self):
- # Illegal encoding declaration
- tree = \
- (341,
- (257, (0, '')))
- self.check_bad_tree(tree, "missed encoding")
- tree = \
- (341,
- (257, (0, '')),
- b'iso-8859-1')
- self.check_bad_tree(tree, "non-string encoding")
- tree = \
- (341,
- (257, (0, '')),
- '\udcff')
- with self.assertRaises(UnicodeEncodeError):
- parser.sequence2st(tree)
-
- def test_invalid_node_id(self):
- tree = (257, (269, (-7, '')))
- self.check_bad_tree(tree, "negative node id")
- tree = (257, (269, (99, '')))
- self.check_bad_tree(tree, "invalid token id")
- tree = (257, (269, (9999, (0, ''))))
- self.check_bad_tree(tree, "invalid symbol id")
-
- def test_ParserError_message(self):
- try:
- parser.sequence2st((257,(269,(257,(0,'')))))
- except parser.ParserError as why:
- self.assertIn("compound_stmt", str(why)) # Expected
- self.assertIn("file_input", str(why)) # Got
-
-
-
-class CompileTestCase(unittest.TestCase):
-
- # These tests are very minimal. :-(
-
- def test_compile_expr(self):
- st = parser.expr('2 + 3')
- code = parser.compilest(st)
- self.assertEqual(eval(code), 5)
-
- def test_compile_suite(self):
- st = parser.suite('x = 2; y = x + 3')
- code = parser.compilest(st)
- globs = {}
- exec(code, globs)
- self.assertEqual(globs['y'], 5)
-
- def test_compile_error(self):
- st = parser.suite('1 = 3 + 4')
- self.assertRaises(SyntaxError, parser.compilest, st)
-
- def test_compile_badunicode(self):
- st = parser.suite('a = "\\U12345678"')
- self.assertRaises(SyntaxError, parser.compilest, st)
- st = parser.suite('a = "\\u1"')
- self.assertRaises(SyntaxError, parser.compilest, st)
-
- def test_issue_9011(self):
- # Issue 9011: compilation of an unary minus expression changed
- # the meaning of the ST, so that a second compilation produced
- # incorrect results.
- st = parser.expr('-3')
- code1 = parser.compilest(st)
- self.assertEqual(eval(code1), -3)
- code2 = parser.compilest(st)
- self.assertEqual(eval(code2), -3)
-
- def test_compile_filename(self):
- st = parser.expr('a + 5')
- code = parser.compilest(st)
- self.assertEqual(code.co_filename, '<syntax-tree>')
- code = st.compile()
- self.assertEqual(code.co_filename, '<syntax-tree>')
- for filename in 'file.py', b'file.py':
- code = parser.compilest(st, filename)
- self.assertEqual(code.co_filename, 'file.py')
- code = st.compile(filename)
- self.assertEqual(code.co_filename, 'file.py')
- for filename in bytearray(b'file.py'), memoryview(b'file.py'):
- with self.assertWarns(DeprecationWarning):
- code = parser.compilest(st, filename)
- self.assertEqual(code.co_filename, 'file.py')
- with self.assertWarns(DeprecationWarning):
- code = st.compile(filename)
- self.assertEqual(code.co_filename, 'file.py')
- self.assertRaises(TypeError, parser.compilest, st, list(b'file.py'))
- self.assertRaises(TypeError, st.compile, list(b'file.py'))
-
-
-class ParserStackLimitTestCase(unittest.TestCase):
- """try to push the parser to/over its limits.
- see http://bugs.python.org/issue1881 for a discussion
- """
- def _nested_expression(self, level):
- return "["*level+"]"*level
-
- def test_deeply_nested_list(self):
- # This has fluctuated between 99 levels in 2.x, down to 93 levels in
- # 3.7.X and back up to 99 in 3.8.X. Related to MAXSTACK size in Parser.h
- e = self._nested_expression(99)
- st = parser.expr(e)
- st.compile()
-
- def test_trigger_memory_error(self):
- e = self._nested_expression(100)
- rc, out, err = assert_python_failure('-Xoldparser', '-c', e)
- # parsing the expression will result in an error message
- # followed by a MemoryError (see #11963)
- self.assertIn(b's_push: parser stack overflow', err)
- self.assertIn(b'MemoryError', err)
-
-class STObjectTestCase(unittest.TestCase):
- """Test operations on ST objects themselves"""
-
- def test_comparisons(self):
- # ST objects should support order and equality comparisons
- st1 = parser.expr('2 + 3')
- st2 = parser.suite('x = 2; y = x + 3')
- st3 = parser.expr('list(x**3 for x in range(20))')
- st1_copy = parser.expr('2 + 3')
- st2_copy = parser.suite('x = 2; y = x + 3')
- st3_copy = parser.expr('list(x**3 for x in range(20))')
-
- # exercise fast path for object identity
- self.assertEqual(st1 == st1, True)
- self.assertEqual(st2 == st2, True)
- self.assertEqual(st3 == st3, True)
- # slow path equality
- self.assertEqual(st1, st1_copy)
- self.assertEqual(st2, st2_copy)
- self.assertEqual(st3, st3_copy)
- self.assertEqual(st1 == st2, False)
- self.assertEqual(st1 == st3, False)
- self.assertEqual(st2 == st3, False)
- self.assertEqual(st1 != st1, False)
- self.assertEqual(st2 != st2, False)
- self.assertEqual(st3 != st3, False)
- self.assertEqual(st1 != st1_copy, False)
- self.assertEqual(st2 != st2_copy, False)
- self.assertEqual(st3 != st3_copy, False)
- self.assertEqual(st2 != st1, True)
- self.assertEqual(st1 != st3, True)
- self.assertEqual(st3 != st2, True)
- # we don't particularly care what the ordering is; just that
- # it's usable and self-consistent
- self.assertEqual(st1 < st2, not (st2 <= st1))
- self.assertEqual(st1 < st3, not (st3 <= st1))
- self.assertEqual(st2 < st3, not (st3 <= st2))
- self.assertEqual(st1 < st2, st2 > st1)
- self.assertEqual(st1 < st3, st3 > st1)
- self.assertEqual(st2 < st3, st3 > st2)
- self.assertEqual(st1 <= st2, st2 >= st1)
- self.assertEqual(st3 <= st1, st1 >= st3)
- self.assertEqual(st2 <= st3, st3 >= st2)
- # transitivity
- bottom = min(st1, st2, st3)
- top = max(st1, st2, st3)
- mid = sorted([st1, st2, st3])[1]
- self.assertTrue(bottom < mid)
- self.assertTrue(bottom < top)
- self.assertTrue(mid < top)
- self.assertTrue(bottom <= mid)
- self.assertTrue(bottom <= top)
- self.assertTrue(mid <= top)
- self.assertTrue(bottom <= bottom)
- self.assertTrue(mid <= mid)
- self.assertTrue(top <= top)
- # interaction with other types
- self.assertEqual(st1 == 1588.602459, False)
- self.assertEqual('spanish armada' != st2, True)
- self.assertRaises(TypeError, operator.ge, st3, None)
- self.assertRaises(TypeError, operator.le, False, st1)
- self.assertRaises(TypeError, operator.lt, st1, 1815)
- self.assertRaises(TypeError, operator.gt, b'waterloo', st2)
-
- def test_copy_pickle(self):
- sts = [
- parser.expr('2 + 3'),
- parser.suite('x = 2; y = x + 3'),
- parser.expr('list(x**3 for x in range(20))')
- ]
- for st in sts:
- st_copy = copy.copy(st)
- self.assertEqual(st_copy.totuple(), st.totuple())
- st_copy = copy.deepcopy(st)
- self.assertEqual(st_copy.totuple(), st.totuple())
- for proto in range(pickle.HIGHEST_PROTOCOL+1):
- st_copy = pickle.loads(pickle.dumps(st, proto))
- self.assertEqual(st_copy.totuple(), st.totuple())
-
- check_sizeof = support.check_sizeof
-
- @support.cpython_only
- def test_sizeof(self):
- def XXXROUNDUP(n):
- if n <= 1:
- return n
- if n <= 128:
- return (n + 3) & ~3
- return 1 << (n - 1).bit_length()
-
- basesize = support.calcobjsize('Piii')
- nodesize = struct.calcsize('hP3iP0h2i')
- def sizeofchildren(node):
- if node is None:
- return 0
- res = 0
- hasstr = len(node) > 1 and isinstance(node[-1], str)
- if hasstr:
- res += len(node[-1]) + 1
- children = node[1:-1] if hasstr else node[1:]
- if children:
- res += XXXROUNDUP(len(children)) * nodesize
- for child in children:
- res += sizeofchildren(child)
- return res
-
- def check_st_sizeof(st):
- self.check_sizeof(st, basesize + nodesize +
- sizeofchildren(st.totuple()))
-
- check_st_sizeof(parser.expr('2 + 3'))
- check_st_sizeof(parser.expr('2 + 3 + 4'))
- check_st_sizeof(parser.suite('x = 2 + 3'))
- check_st_sizeof(parser.suite(''))
- check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-'))
- check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']'))
-
-
- # XXX tests for pickling and unpickling of ST objects should go here
-
-class OtherParserCase(unittest.TestCase):
-
- def test_two_args_to_expr(self):
- # See bug #12264
- with self.assertRaises(TypeError):
- parser.expr("a", "b")
-
-
-class TestDeprecation(unittest.TestCase):
- def test_deprecation_message(self):
- code = "def f():\n import parser\n\nf()"
- rc, out, err = assert_python_ok('-c', code)
- self.assertIn(b'<string>:2: DeprecationWarning', err)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/Lib/test/test_peg_parser.py b/Lib/test/test_peg_parser.py
deleted file mode 100644
index fae85e3..0000000
--- a/Lib/test/test_peg_parser.py
+++ /dev/null
@@ -1,803 +0,0 @@
-import ast
-import _peg_parser as peg_parser
-import unittest
-from typing import Any, Union, Iterable, Tuple
-from textwrap import dedent
-from test import support
-
-
-TEST_CASES = [
- ('annotated_assignment', 'x: int = 42'),
- ('annotated_assignment_with_tuple', 'x: tuple = 1, 2'),
- ('annotated_assignment_with_parens', '(paren): int = 3+2'),
- ('annotated_assignment_with_yield', 'x: int = yield 42'),
- ('annotated_no_assignment', 'x: int'),
- ('annotation_with_multiple_parens', '((parens)): int'),
- ('annotation_with_parens', '(parens): int'),
- ('annotated_assignment_with_attr', 'a.b: int'),
- ('annotated_assignment_with_subscript', 'a[b]: int'),
- ('annotated_assignment_with_attr_and_parens', '(a.b): int'),
- ('annotated_assignment_with_subscript_and_parens', '(a[b]): int'),
- ('assert', 'assert a'),
- ('assert_message', 'assert a, b'),
- ('assignment_false', 'a = False'),
- ('assignment_none', 'a = None'),
- ('assignment_true', 'a = True'),
- ('assignment_paren', '(a) = 42'),
- ('assignment_paren_multiple', '(a, b) = (0, 1)'),
- ('asyncfor',
- '''
- async for i in a:
- pass
- '''),
- ('attribute_call', 'a.b()'),
- ('attribute_multiple_names', 'abcd.efg.hij'),
- ('attribute_simple', 'a.b'),
- ('attributes_subscript', 'a.b[0]'),
- ('augmented_assignment', 'x += 42'),
- ('augmented_assignment_attribute', 'a.b.c += 42'),
- ('augmented_assignment_paren', '(x) += 42'),
- ('augmented_assignment_paren_subscript', '(x[0]) -= 42'),
- ('binop_add', '1 + 1'),
- ('binop_add_multiple', '1 + 1 + 1 + 1'),
- ('binop_all', '1 + 2 * 5 + 3 ** 2 - -3'),
- ('binop_boolop_comp', '1 + 1 == 2 or 1 + 1 == 3 and not b'),
- ('boolop_or', 'a or b'),
- ('boolop_or_multiple', 'a or b or c'),
- ('class_def_bases',
- '''
- class C(A, B):
- pass
- '''),
- ('class_def_decorators',
- '''
- @a
- class C:
- pass
- '''),
- ('class_def_decorator_with_expression',
- '''
- @lambda x: 42
- class C:
- pass
- '''),
- ('class_def_decorator_with_expression_and_walrus',
- '''
- @x:=lambda x: 42
- class C:
- pass
- '''),
-
- ('class_def_keywords',
- '''
- class C(keyword=a+b, **c):
- pass
- '''),
- ('class_def_mixed',
- '''
- class C(A, B, keyword=0, **a):
- pass
- '''),
- ('class_def_simple',
- '''
- class C:
- pass
- '''),
- ('class_def_starred_and_kwarg',
- '''
- class C(A, B, *x, **y):
- pass
- '''),
- ('class_def_starred_in_kwargs',
- '''
- class C(A, x=2, *[B, C], y=3):
- pass
- '''),
- ('call_attribute', 'f().b'),
- ('call_genexp', 'f(i for i in a)'),
- ('call_mixed_args', 'f(a, b, *c, **d)'),
- ('call_mixed_args_named', 'f(a, b, *c, d=4, **v)'),
- ('call_one_arg', 'f(a)'),
- ('call_posarg_genexp', 'f(a, (i for i in a))'),
- ('call_simple', 'f()'),
- ('call_subscript', 'f()[0]'),
- ('comp', 'a == b'),
- ('comp_multiple', 'a == b == c'),
- ('comp_paren_end', 'a == (b-1)'),
- ('comp_paren_start', '(a-1) == b'),
- ('decorator',
- '''
- @a
- def f():
- pass
- '''),
- ('decorator_async',
- '''
- @a
- async def d():
- pass
- '''),
- ('decorator_with_expression',
- '''
- @lambda x: 42
- def f():
- pass
- '''),
- ('decorator_with_expression_and_walrus',
- '''
- @x:=lambda x: 42
- def f():
- pass
- '''),
- ('del_attribute', 'del a.b'),
- ('del_call_attribute', 'del a().c'),
- ('del_call_genexp_attribute', 'del a(i for i in b).c'),
- ('del_empty', 'del()'),
- ('del_list', 'del a, [b, c]'),
- ('del_mixed', 'del a[0].b().c'),
- ('del_multiple', 'del a, b'),
- ('del_multiple_calls_attribute', 'del a()().b'),
- ('del_paren', 'del(a,b)'),
- ('del_paren_single_target', 'del(a)'),
- ('del_subscript_attribute', 'del a[0].b'),
- ('del_tuple', 'del a, (b, c)'),
- ('delete', 'del a'),
- ('dict',
- '''
- {
- a: 1,
- b: 2,
- c: 3
- }
- '''),
- ('dict_comp', '{x:1 for x in a}'),
- ('dict_comp_if', '{x:1+2 for x in a if b}'),
- ('dict_empty', '{}'),
- ('empty_line_after_linecont',
- r'''
- pass
- \
-
- pass
- '''),
- ('for',
- '''
- for i in a:
- pass
- '''),
- ('for_else',
- '''
- for i in a:
- pass
- else:
- pass
- '''),
- ('for_star_target_in_paren', 'for (a) in b: pass'),
- ('for_star_targets_attribute', 'for a.b in c: pass'),
- ('for_star_targets_call_attribute', 'for a().c in b: pass'),
- ('for_star_targets_empty', 'for () in a: pass'),
- ('for_star_targets_mixed', 'for a[0].b().c in d: pass'),
- ('for_star_targets_mixed_starred',
- '''
- for a, *b, (c, d) in e:
- pass
- '''),
- ('for_star_targets_multiple', 'for a, b in c: pass'),
- ('for_star_targets_nested_starred', 'for *[*a] in b: pass'),
- ('for_star_targets_starred', 'for *a in b: pass'),
- ('for_star_targets_subscript_attribute', 'for a[0].b in c: pass'),
- ('for_star_targets_trailing_comma',
- '''
- for a, (b, c), in d:
- pass
- '''),
- ('for_star_targets_tuple', 'for a, (b, c) in d: pass'),
- ('for_underscore',
- '''
- for _ in a:
- pass
- '''),
- ('function_return_type',
- '''
- def f() -> Any:
- pass
- '''),
- ('f-string_slice', "f'{x[2]}'"),
- ('f-string_slice_upper', "f'{x[2:3]}'"),
- ('f-string_slice_step', "f'{x[2:3:-2]}'"),
- ('f-string_constant', "f'{42}'"),
- ('f-string_boolop', "f'{x and y}'"),
- ('f-string_named_expr', "f'{(x:=42)}'"),
- ('f-string_binop', "f'{x+y}'"),
- ('f-string_unaryop', "f'{not x}'"),
- ('f-string_lambda', "f'{(lambda x, /, y, y2=42 , *z, k1, k2=34, **k3: 42)}'"),
- ('f-string_lambda_call', "f'{(lambda: 2)(2)}'"),
- ('f-string_ifexpr', "f'{x if y else z}'"),
- ('f-string_dict', "f'{ {2:34, 3:34} }'"),
- ('f-string_set', "f'{ {2,-45} }'"),
- ('f-string_list', "f'{ [2,-45] }'"),
- ('f-string_tuple', "f'{ (2,-45) }'"),
- ('f-string_listcomp', "f'{[x for x in y if z]}'"),
- ('f-string_setcomp', "f'{ {x for x in y if z} }'"),
- ('f-string_dictcomp', "f'{ {x:x for x in y if z} }'"),
- ('f-string_genexpr', "f'{ (x for x in y if z) }'"),
- ('f-string_yield', "f'{ (yield x) }'"),
- ('f-string_yieldfrom', "f'{ (yield from x) }'"),
- ('f-string_await', "f'{ await x }'"),
- ('f-string_compare', "f'{ x == y }'"),
- ('f-string_call', "f'{ f(x,y,z) }'"),
- ('f-string_attribute', "f'{ f.x.y.z }'"),
- ('f-string_starred', "f'{ *x, }'"),
- ('f-string_doublestarred', "f'{ {**x} }'"),
- ('f-string_escape_brace', "f'{{Escape'"),
- ('f-string_escape_closing_brace', "f'Escape}}'"),
- ('f-string_repr', "f'{a!r}'"),
- ('f-string_str', "f'{a!s}'"),
- ('f-string_ascii', "f'{a!a}'"),
- ('f-string_debug', "f'{a=}'"),
- ('f-string_padding', "f'{a:03d}'"),
- ('f-string_multiline',
- """
- f'''
- {hello}
- '''
- """),
- ('f-string_multiline_in_expr',
- """
- f'''
- {
- hello
- }
- '''
- """),
- ('f-string_multiline_in_call',
- """
- f'''
- {f(
- a, b, c
- )}
- '''
- """),
- ('global', 'global a, b'),
- ('group', '(yield a)'),
- ('if_elif',
- '''
- if a:
- pass
- elif b:
- pass
- '''),
- ('if_elif_elif',
- '''
- if a:
- pass
- elif b:
- pass
- elif c:
- pass
- '''),
- ('if_elif_else',
- '''
- if a:
- pass
- elif b:
- pass
- else:
- pass
- '''),
- ('if_else',
- '''
- if a:
- pass
- else:
- pass
- '''),
- ('if_simple', 'if a: pass'),
- ('import', 'import a'),
- ('import_alias', 'import a as b'),
- ('import_dotted', 'import a.b'),
- ('import_dotted_alias', 'import a.b as c'),
- ('import_dotted_multichar', 'import ab.cd'),
- ('import_from', 'from a import b'),
- ('import_from_alias', 'from a import b as c'),
- ('import_from_dotted', 'from a.b import c'),
- ('import_from_dotted_alias', 'from a.b import c as d'),
- ('import_from_multiple_aliases', 'from a import b as c, d as e'),
- ('import_from_one_dot', 'from .a import b'),
- ('import_from_one_dot_alias', 'from .a import b as c'),
- ('import_from_star', 'from a import *'),
- ('import_from_three_dots', 'from ...a import b'),
- ('import_from_trailing_comma', 'from a import (b,)'),
- ('kwarg',
- '''
- def f(**a):
- pass
- '''),
- ('kwonly_args',
- '''
- def f(*, a, b):
- pass
- '''),
- ('kwonly_args_with_default',
- '''
- def f(*, a=2, b):
- pass
- '''),
- ('lambda_kwarg', 'lambda **a: 42'),
- ('lambda_kwonly_args', 'lambda *, a, b: 42'),
- ('lambda_kwonly_args_with_default', 'lambda *, a=2, b: 42'),
- ('lambda_mixed_args', 'lambda a, /, b, *, c: 42'),
- ('lambda_mixed_args_with_default', 'lambda a, b=2, /, c=3, *e, f, **g: 42'),
- ('lambda_no_args', 'lambda: 42'),
- ('lambda_pos_args', 'lambda a,b: 42'),
- ('lambda_pos_args_with_default', 'lambda a, b=2: 42'),
- ('lambda_pos_only_args', 'lambda a, /: 42'),
- ('lambda_pos_only_args_with_default', 'lambda a=0, /: 42'),
- ('lambda_pos_posonly_args', 'lambda a, b, /, c, d: 42'),
- ('lambda_pos_posonly_args_with_default', 'lambda a, b=0, /, c=2: 42'),
- ('lambda_vararg', 'lambda *a: 42'),
- ('lambda_vararg_kwonly_args', 'lambda *a, b: 42'),
- ('list', '[1, 2, a]'),
- ('list_comp', '[i for i in a]'),
- ('list_comp_if', '[i for i in a if b]'),
- ('list_trailing_comma', '[1+2, a, 3+4,]'),
- ('mixed_args',
- '''
- def f(a, /, b, *, c):
- pass
- '''),
- ('mixed_args_with_default',
- '''
- def f(a, b=2, /, c=3, *e, f, **g):
- pass
- '''),
- ('multipart_string_bytes', 'b"Hola" b"Hello" b"Bye"'),
- ('multipart_string_triple', '"""Something here""" "and now"'),
- ('multipart_string_different_prefixes', 'u"Something" "Other thing" r"last thing"'),
- ('multiple_assignments', 'x = y = z = 42'),
- ('multiple_assignments_with_yield', 'x = y = z = yield 42'),
- ('multiple_pass',
- '''
- pass; pass
- pass
- '''),
- ('namedexpr', '(x := [1, 2, 3])'),
- ('namedexpr_false', '(x := False)'),
- ('namedexpr_none', '(x := None)'),
- ('namedexpr_true', '(x := True)'),
- ('nonlocal', 'nonlocal a, b'),
- ('number_complex', '-2.234+1j'),
- ('number_float', '-34.2333'),
- ('number_imaginary_literal', '1.1234j'),
- ('number_integer', '-234'),
- ('number_underscores', '1_234_567'),
- ('pass', 'pass'),
- ('pos_args',
- '''
- def f(a, b):
- pass
- '''),
- ('pos_args_with_default',
- '''
- def f(a, b=2):
- pass
- '''),
- ('pos_only_args',
- '''
- def f(a, /):
- pass
- '''),
- ('pos_only_args_with_default',
- '''
- def f(a=0, /):
- pass
- '''),
- ('pos_posonly_args',
- '''
- def f(a, b, /, c, d):
- pass
- '''),
- ('pos_posonly_args_with_default',
- '''
- def f(a, b=0, /, c=2):
- pass
- '''),
- ('primary_mixed', 'a.b.c().d[0]'),
- ('raise', 'raise'),
- ('raise_ellipsis', 'raise ...'),
- ('raise_expr', 'raise a'),
- ('raise_from', 'raise a from b'),
- ('return', 'return'),
- ('return_expr', 'return a'),
- ('set', '{1, 2+4, 3+5}'),
- ('set_comp', '{i for i in a}'),
- ('set_trailing_comma', '{1, 2, 3,}'),
- ('simple_assignment', 'x = 42'),
- ('simple_assignment_with_yield', 'x = yield 42'),
- ('string_bytes', 'b"hello"'),
- ('string_concatenation_bytes', 'b"hello" b"world"'),
- ('string_concatenation_simple', '"abcd" "efgh"'),
- ('string_format_simple', 'f"hello"'),
- ('string_format_with_formatted_value', 'f"hello {world}"'),
- ('string_simple', '"hello"'),
- ('string_unicode', 'u"hello"'),
- ('subscript_attribute', 'a[0].b'),
- ('subscript_call', 'a[b]()'),
- ('subscript_multiple_slices', 'a[0:a:2, 1]'),
- ('subscript_simple', 'a[0]'),
- ('subscript_single_element_tuple', 'a[0,]'),
- ('subscript_trailing_comma', 'a[0, 1, 2,]'),
- ('subscript_tuple', 'a[0, 1, 2]'),
- ('subscript_whole_slice', 'a[0+1:b:c]'),
- ('try_except',
- '''
- try:
- pass
- except:
- pass
- '''),
- ('try_except_else',
- '''
- try:
- pass
- except:
- pass
- else:
- pass
- '''),
- ('try_except_else_finally',
- '''
- try:
- pass
- except:
- pass
- else:
- pass
- finally:
- pass
- '''),
- ('try_except_expr',
- '''
- try:
- pass
- except a:
- pass
- '''),
- ('try_except_expr_target',
- '''
- try:
- pass
- except a as b:
- pass
- '''),
- ('try_except_finally',
- '''
- try:
- pass
- except:
- pass
- finally:
- pass
- '''),
- ('try_finally',
- '''
- try:
- pass
- finally:
- pass
- '''),
- ('unpacking_binop', '[*([1, 2, 3] + [3, 4, 5])]'),
- ('unpacking_call', '[*b()]'),
- ('unpacking_compare', '[*(x < y)]'),
- ('unpacking_constant', '[*3]'),
- ('unpacking_dict', '[*{1: 2, 3: 4}]'),
- ('unpacking_dict_comprehension', '[*{x:y for x,y in z}]'),
- ('unpacking_ifexpr', '[*([1, 2, 3] if x else y)]'),
- ('unpacking_list', '[*[1,2,3]]'),
- ('unpacking_list_comprehension', '[*[x for x in y]]'),
- ('unpacking_namedexpr', '[*(x:=[1, 2, 3])]'),
- ('unpacking_set', '[*{1,2,3}]'),
- ('unpacking_set_comprehension', '[*{x for x in y}]'),
- ('unpacking_string', '[*"myvalue"]'),
- ('unpacking_tuple', '[*(1,2,3)]'),
- ('unpacking_unaryop', '[*(not [1, 2, 3])]'),
- ('unpacking_yield', '[*(yield 42)]'),
- ('unpacking_yieldfrom', '[*(yield from x)]'),
- ('tuple', '(1, 2, 3)'),
- ('vararg',
- '''
- def f(*a):
- pass
- '''),
- ('vararg_kwonly_args',
- '''
- def f(*a, b):
- pass
- '''),
- ('while',
- '''
- while a:
- pass
- '''),
- ('while_else',
- '''
- while a:
- pass
- else:
- pass
- '''),
- ('with',
- '''
- with a:
- pass
- '''),
- ('with_as',
- '''
- with a as b:
- pass
- '''),
- ('with_as_paren',
- '''
- with a as (b):
- pass
- '''),
- ('with_as_empty', 'with a as (): pass'),
- ('with_list_recursive',
- '''
- with a as [x, [y, z]]:
- pass
- '''),
- ('with_tuple_recursive',
- '''
- with a as ((x, y), z):
- pass
- '''),
- ('with_tuple_target',
- '''
- with a as (x, y):
- pass
- '''),
- ('with_list_target',
- '''
- with a as [x, y]:
- pass
- '''),
- ('yield', 'yield'),
- ('yield_expr', 'yield a'),
- ('yield_from', 'yield from a'),
-]
-
-FAIL_TEST_CASES = [
- ("annotation_multiple_targets", "(a, b): int = 42"),
- ("annotation_nested_tuple", "((a, b)): int"),
- ("annotation_list", "[a]: int"),
- ("annotation_lambda", "lambda: int = 42"),
- ("annotation_tuple", "(a,): int"),
- ("annotation_tuple_without_paren", "a,: int"),
- ("assignment_keyword", "a = if"),
- ("augmented_assignment_list", "[a, b] += 1"),
- ("augmented_assignment_tuple", "a, b += 1"),
- ("augmented_assignment_tuple_paren", "(a, b) += (1, 2)"),
- ("comprehension_lambda", "(a for a in lambda: b)"),
- ("comprehension_else", "(a for a in b if c else d"),
- ("del_call", "del a()"),
- ("del_call_genexp", "del a(i for i in b)"),
- ("del_subscript_call", "del a[b]()"),
- ("del_attribute_call", "del a.b()"),
- ("del_mixed_call", "del a[0].b().c.d()"),
- ("for_star_targets_call", "for a() in b: pass"),
- ("for_star_targets_subscript_call", "for a[b]() in c: pass"),
- ("for_star_targets_attribute_call", "for a.b() in c: pass"),
- ("for_star_targets_mixed_call", "for a[0].b().c.d() in e: pass"),
- ("for_star_targets_in", "for a, in in b: pass"),
- ("f-string_assignment", "f'{x = 42}'"),
- ("f-string_empty", "f'{}'"),
- ("f-string_function_def", "f'{def f(): pass}'"),
- ("f-string_lambda", "f'{lambda x: 42}'"),
- ("f-string_singe_brace", "f'{'"),
- ("f-string_single_closing_brace", "f'}'"),
- ("from_import_invalid", "from import import a"),
- ("from_import_trailing_comma", "from a import b,"),
- ("import_non_ascii_syntax_error", "import ä £"),
- # This test case checks error paths involving tokens with uninitialized
- # values of col_offset and end_col_offset.
- ("invalid indentation",
- """
- def f():
- a
- a
- """),
- ("not_terminated_string", "a = 'example"),
- ("try_except_attribute_target",
- """
- try:
- pass
- except Exception as a.b:
- pass
- """),
- ("try_except_subscript_target",
- """
- try:
- pass
- except Exception as a[0]:
- pass
- """),
-]
-
-FAIL_SPECIALIZED_MESSAGE_CASES = [
- ("f(x, y, z=1, **b, *a", "iterable argument unpacking follows keyword argument unpacking"),
- ("f(x, y=1, *z, **a, b", "positional argument follows keyword argument unpacking"),
- ("f(x, y, z=1, a=2, b", "positional argument follows keyword argument"),
- ("True = 1", "cannot assign to True"),
- ("a() = 1", "cannot assign to function call"),
- ("(a, b): int", "only single target (not tuple) can be annotated"),
- ("[a, b]: int", "only single target (not list) can be annotated"),
- ("a(): int", "illegal target for annotation"),
- ("1 += 1", "'literal' is an illegal expression for augmented assignment"),
- ("pass\n pass", "unexpected indent"),
- ("def f():\npass", "expected an indented block"),
- ("def f(*): pass", "named arguments must follow bare *"),
- ("def f(*,): pass", "named arguments must follow bare *"),
- ("def f(*, **a): pass", "named arguments must follow bare *"),
- ("lambda *: pass", "named arguments must follow bare *"),
- ("lambda *,: pass", "named arguments must follow bare *"),
- ("lambda *, **a: pass", "named arguments must follow bare *"),
- ("f(g()=2", "expression cannot contain assignment, perhaps you meant \"==\"?"),
- ("f(a, b, *c, d.e=2", "expression cannot contain assignment, perhaps you meant \"==\"?"),
- ("f(*a, **b, c=0, d[1]=3)", "expression cannot contain assignment, perhaps you meant \"==\"?"),
-]
-
-GOOD_BUT_FAIL_TEST_CASES = [
- ('string_concatenation_format', 'f"{hello} world" f"again {and_again}"'),
- ('string_concatenation_multiple',
- '''
- f"hello" f"{world} again" f"and_again"
- '''),
- ('f-string_multiline_comp',
- """
- f'''
- {(i for i in a
- if b)}
- '''
- """),
-]
-
-FSTRINGS_TRACEBACKS = {
- 'multiline_fstrings_same_line_with_brace': (
- """
- f'''
- {a$b}
- '''
- """,
- '(a$b)',
- ),
- 'multiline_fstring_brace_on_next_line': (
- """
- f'''
- {a$b
- }'''
- """,
- '(a$b',
- ),
- 'multiline_fstring_brace_on_previous_line': (
- """
- f'''
- {
- a$b}'''
- """,
- 'a$b)',
- ),
-}
-
-EXPRESSIONS_TEST_CASES = [
- ("expression_add", "1+1"),
- ("expression_add_2", "a+b"),
- ("expression_call", "f(a, b=2, **kw)"),
- ("expression_tuple", "1, 2, 3"),
- ("expression_tuple_one_value", "1,")
-]
-
-
-def cleanup_source(source: Any) -> str:
- if isinstance(source, str):
- result = dedent(source)
- elif not isinstance(source, (list, tuple)):
- result = "\n".join(source)
- else:
- raise TypeError(f"Invalid type for test source: {source}")
- return result
-
-
-def prepare_test_cases(
- test_cases: Iterable[Tuple[str, Union[str, Iterable[str]]]]
-) -> Tuple[Iterable[str], Iterable[str]]:
-
- test_ids, _test_sources = zip(*test_cases)
- test_sources = list(_test_sources)
- for index, source in enumerate(test_sources):
- result = cleanup_source(source)
- test_sources[index] = result
- return test_ids, test_sources
-
-
-TEST_IDS, TEST_SOURCES = prepare_test_cases(TEST_CASES)
-
-GOOD_BUT_FAIL_TEST_IDS, GOOD_BUT_FAIL_SOURCES = prepare_test_cases(
- GOOD_BUT_FAIL_TEST_CASES
-)
-
-FAIL_TEST_IDS, FAIL_SOURCES = prepare_test_cases(FAIL_TEST_CASES)
-
-EXPRESSIONS_TEST_IDS, EXPRESSIONS_TEST_SOURCES = prepare_test_cases(
- EXPRESSIONS_TEST_CASES
-)
-
-
-class ASTGenerationTest(unittest.TestCase):
- def test_correct_ast_generation_on_source_files(self) -> None:
- self.maxDiff = None
- for source in TEST_SOURCES:
- actual_ast = peg_parser.parse_string(source)
- expected_ast = peg_parser.parse_string(source, oldparser=True)
- self.assertEqual(
- ast.dump(actual_ast, include_attributes=True),
- ast.dump(expected_ast, include_attributes=True),
- f"Wrong AST generation for source: {source}",
- )
-
- def test_incorrect_ast_generation_on_source_files(self) -> None:
- for source in FAIL_SOURCES:
- with self.assertRaises(SyntaxError, msg=f"Parsing {source} did not raise an exception"):
- peg_parser.parse_string(source)
-
- def test_incorrect_ast_generation_with_specialized_errors(self) -> None:
- for source, error_text in FAIL_SPECIALIZED_MESSAGE_CASES:
- exc = IndentationError if "indent" in error_text else SyntaxError
- with self.assertRaises(exc) as se:
- peg_parser.parse_string(source)
- self.assertTrue(
- error_text in se.exception.msg,
- f"Actual error message does not match expexted for {source}"
- )
-
- @unittest.expectedFailure
- def test_correct_but_known_to_fail_ast_generation_on_source_files(self) -> None:
- for source in GOOD_BUT_FAIL_SOURCES:
- actual_ast = peg_parser.parse_string(source)
- expected_ast = peg_parser.parse_string(source, oldparser=True)
- self.assertEqual(
- ast.dump(actual_ast, include_attributes=True),
- ast.dump(expected_ast, include_attributes=True),
- f"Wrong AST generation for source: {source}",
- )
-
- def test_correct_ast_generation_without_pos_info(self) -> None:
- for source in GOOD_BUT_FAIL_SOURCES:
- actual_ast = peg_parser.parse_string(source)
- expected_ast = peg_parser.parse_string(source, oldparser=True)
- self.assertEqual(
- ast.dump(actual_ast),
- ast.dump(expected_ast),
- f"Wrong AST generation for source: {source}",
- )
-
- def test_fstring_parse_error_tracebacks(self) -> None:
- for source, error_text in FSTRINGS_TRACEBACKS.values():
- with self.assertRaises(SyntaxError) as se:
- peg_parser.parse_string(dedent(source))
- self.assertEqual(error_text, se.exception.text)
-
- def test_correct_ast_generatrion_eval(self) -> None:
- for source in EXPRESSIONS_TEST_SOURCES:
- actual_ast = peg_parser.parse_string(source, mode='eval')
- expected_ast = peg_parser.parse_string(source, mode='eval', oldparser=True)
- self.assertEqual(
- ast.dump(actual_ast, include_attributes=True),
- ast.dump(expected_ast, include_attributes=True),
- f"Wrong AST generation for source: {source}",
- )
-
- def test_tokenizer_errors_are_propagated(self) -> None:
- n=201
- with self.assertRaisesRegex(SyntaxError, "too many nested parentheses"):
- peg_parser.parse_string(n*'(' + ')'*n)
diff --git a/Lib/test/test_string_literals.py b/Lib/test/test_string_literals.py
index 9565ee2..7231970 100644
--- a/Lib/test/test_string_literals.py
+++ b/Lib/test/test_string_literals.py
@@ -33,7 +33,6 @@ import shutil
import tempfile
import unittest
import warnings
-from test.support import use_old_parser
TEMPLATE = r"""# coding: %s
@@ -168,8 +167,7 @@ class TestLiterals(unittest.TestCase):
eval("b'''\n\\z'''")
self.assertEqual(len(w), 1)
self.assertEqual(w[0].filename, '<string>')
- if use_old_parser():
- self.assertEqual(w[0].lineno, 1)
+ self.assertEqual(w[0].lineno, 1)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('error', category=DeprecationWarning)
@@ -178,8 +176,7 @@ class TestLiterals(unittest.TestCase):
exc = cm.exception
self.assertEqual(w, [])
self.assertEqual(exc.filename, '<string>')
- if use_old_parser():
- self.assertEqual(exc.lineno, 1)
+ self.assertEqual(exc.lineno, 1)
def test_eval_bytes_raw(self):
self.assertEqual(eval(""" br'x' """), b'x')
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 0c207ec..6ea9a55 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -733,7 +733,6 @@ class SyntaxTestCase(unittest.TestCase):
def test_assign_call(self):
self._check_error("f() = 1", "assign")
- @unittest.skipIf(support.use_old_parser(), "The old parser cannot generate these error messages")
def test_assign_del(self):
self._check_error("del (,)", "invalid syntax")
self._check_error("del 1", "delete literal")
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index f9a5f2f..925a6bc 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -655,7 +655,6 @@ class BaseExceptionReportingTests:
self.assertIn('inner_raise() # Marker', blocks[2])
self.check_zero_div(blocks[2])
- @unittest.skipIf(support.use_old_parser(), "Pegen is arguably better here, so no need to fix this")
def test_syntax_error_offset_at_eol(self):
# See #10186.
def e():
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 5972dc7..6841712 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -300,32 +300,24 @@ LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
# Parser
PEGEN_OBJS= \
- Parser/pegen/pegen.o \
- Parser/pegen/parse.o \
- Parser/pegen/parse_string.o \
- Parser/pegen/peg_api.o
+ Parser/pegen.o \
+ Parser/parser.o \
+ Parser/string_parser.o \
+ Parser/peg_api.o
PEGEN_HEADERS= \
$(srcdir)/Include/internal/pegen_interface.h \
- $(srcdir)/Parser/pegen/pegen.h \
- $(srcdir)/Parser/pegen/parse_string.h
+ $(srcdir)/Parser/pegen.h \
+ $(srcdir)/Parser/string_parser.h
POBJS= \
- Parser/acceler.o \
- Parser/grammar1.o \
- Parser/listnode.o \
- Parser/node.o \
- Parser/parser.o \
Parser/token.o \
-PARSER_OBJS= $(POBJS) $(PEGEN_OBJS) Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o
+PARSER_OBJS= $(POBJS) $(PEGEN_OBJS) Parser/myreadline.o Parser/tokenizer.o
PARSER_HEADERS= \
$(PEGEN_HEADERS) \
- $(srcdir)/Include/grammar.h \
- $(srcdir)/Include/parsetok.h \
- $(srcdir)/Parser/parser.h \
$(srcdir)/Parser/tokenizer.h
##########################################################################
@@ -568,7 +560,7 @@ coverage-lcov:
@echo
# Force regeneration of parser and importlib
-coverage-report: regen-grammar regen-token regen-importlib
+coverage-report: regen-token regen-importlib
@ # build with coverage info
$(MAKE) coverage
@ # run tests, ignore failures
@@ -749,8 +741,8 @@ regen-importlib: Programs/_freeze_importlib
############################################################################
# Regenerate all generated files
-regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar \
- regen-token regen-keyword regen-symbol regen-ast regen-importlib clinic \
+regen-all: regen-opcode regen-opcode-targets regen-typeslots \
+ regen-token regen-symbol regen-ast regen-importlib clinic \
regen-pegen-metaparser regen-pegen
############################################################################
@@ -816,18 +808,6 @@ Python/initconfig.o: $(srcdir)/Python/initconfig.c
$(IO_OBJS): $(IO_H)
-.PHONY: regen-grammar
-regen-grammar: regen-token
- # Regenerate Include/graminit.h and Python/graminit.c
- # from Grammar/Grammar using pgen
- @$(MKDIR_P) Include
- PYTHONPATH=$(srcdir) $(PYTHON_FOR_REGEN) -m Parser.pgen $(srcdir)/Grammar/Grammar \
- $(srcdir)/Grammar/Tokens \
- $(srcdir)/Include/graminit.h.new \
- $(srcdir)/Python/graminit.c.new
- $(UPDATE_FILE) $(srcdir)/Include/graminit.h $(srcdir)/Include/graminit.h.new
- $(UPDATE_FILE) $(srcdir)/Python/graminit.c $(srcdir)/Python/graminit.c.new
-
.PHONY: regen-pegen-metaparser
regen-pegen-metaparser:
@$(MKDIR_P) $(srcdir)/Tools/peg_generator/pegen
@@ -839,12 +819,12 @@ regen-pegen-metaparser:
.PHONY: regen-pegen
regen-pegen:
- @$(MKDIR_P) $(srcdir)/Parser/pegen
+ @$(MKDIR_P) $(srcdir)/Parser
PYTHONPATH=$(srcdir)/Tools/peg_generator $(PYTHON_FOR_REGEN) -m pegen -q c \
$(srcdir)/Grammar/python.gram \
$(srcdir)/Grammar/Tokens \
- -o $(srcdir)/Parser/pegen/parse.new.c
- $(UPDATE_FILE) $(srcdir)/Parser/pegen/parse.c $(srcdir)/Parser/pegen/parse.new.c
+ -o $(srcdir)/Parser/parser.new.c
+ $(UPDATE_FILE) $(srcdir)/Parser/parser.c $(srcdir)/Parser/parser.new.c
.PHONY=regen-ast
regen-ast:
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-06-10-11-27-15.bpo-40939.DO-wAI.rst b/Misc/NEWS.d/next/Core and Builtins/2020-06-10-11-27-15.bpo-40939.DO-wAI.rst
new file mode 100644
index 0000000..b12985d
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2020-06-10-11-27-15.bpo-40939.DO-wAI.rst
@@ -0,0 +1 @@
+Remove the old parser, the :mod:`parser` module and all associated support code, command-line options and environment variables. Patch by Pablo Galindo. \ No newline at end of file
diff --git a/Modules/Setup b/Modules/Setup
index 02cfb67..5d428d5 100644
--- a/Modules/Setup
+++ b/Modules/Setup
@@ -134,9 +134,6 @@ faulthandler faulthandler.c
# can call _PyTraceMalloc_NewReference().
_tracemalloc _tracemalloc.c
-# PEG-based parser module -- slated to be *the* parser
-_peg_parser _peg_parser.c
-
# The rest of the modules listed in this file are all commented out by
# default. Usually they can be detected and built as dynamically
# loaded modules by the new setup.py script added in Python 2.1. If
@@ -331,10 +328,6 @@ _symtable symtablemodule.c
# Helper module for various ascii-encoders
#binascii binascii.c
-# Fred Drake's interface to the Python parser
-#parser parsermodule.c
-
-
# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
diff --git a/Modules/_peg_parser.c b/Modules/_peg_parser.c
deleted file mode 100644
index ca2a3cf..0000000
--- a/Modules/_peg_parser.c
+++ /dev/null
@@ -1,153 +0,0 @@
-#include <Python.h>
-#include "pegen_interface.h"
-
-static int
-_mode_str_to_int(char *mode_str)
-{
- int mode;
- if (strcmp(mode_str, "exec") == 0) {
- mode = Py_file_input;
- }
- else if (strcmp(mode_str, "eval") == 0) {
- mode = Py_eval_input;
- }
- else if (strcmp(mode_str, "single") == 0) {
- mode = Py_single_input;
- }
- else {
- mode = -1;
- }
- return mode;
-}
-
-static mod_ty
-_run_parser(char *str, char *filename, int mode, PyCompilerFlags *flags, PyArena *arena, int oldparser)
-{
- mod_ty mod;
- if (!oldparser) {
- mod = PyPegen_ASTFromString(str, filename, mode, flags, arena);
- }
- else {
- mod = PyParser_ASTFromString(str, filename, mode, flags, arena);
- }
- return mod;
-}
-
-PyObject *
-_Py_compile_string(PyObject *self, PyObject *args, PyObject *kwds)
-{
- static char *keywords[] = {"string", "filename", "mode", "oldparser", NULL};
- char *the_string;
- char *filename = "<string>";
- char *mode_str = "exec";
- int oldparser = 0;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ssp", keywords,
- &the_string, &filename, &mode_str, &oldparser)) {
- return NULL;
- }
-
- int mode = _mode_str_to_int(mode_str);
- if (mode == -1) {
- return PyErr_Format(PyExc_ValueError, "mode must be either 'exec' or 'eval' or 'single'");
- }
-
- PyCompilerFlags flags = _PyCompilerFlags_INIT;
- flags.cf_flags = PyCF_IGNORE_COOKIE;
-
- PyArena *arena = PyArena_New();
- if (arena == NULL) {
- return NULL;
- }
-
- mod_ty mod = _run_parser(the_string, filename, mode, &flags, arena, oldparser);
- if (mod == NULL) {
- PyArena_Free(arena);
- return NULL;
- }
-
- PyObject *filename_ob = PyUnicode_DecodeFSDefault(filename);
- if (filename_ob == NULL) {
- PyArena_Free(arena);
- return NULL;
- }
- PyCodeObject *result = PyAST_CompileObject(mod, filename_ob, &flags, -1, arena);
- Py_XDECREF(filename_ob);
- PyArena_Free(arena);
- return (PyObject *)result;
-}
-
-PyObject *
-_Py_parse_string(PyObject *self, PyObject *args, PyObject *kwds)
-{
- static char *keywords[] = {"string", "filename", "mode", "oldparser", "ast", NULL};
- char *the_string;
- char *filename = "<string>";
- char *mode_str = "exec";
- int oldparser = 0;
- int ast = 1;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|sspp", keywords,
- &the_string, &filename, &mode_str, &oldparser, &ast)) {
- return NULL;
- }
-
- int mode = _mode_str_to_int(mode_str);
- if (mode == -1) {
- return PyErr_Format(PyExc_ValueError, "mode must be either 'exec' or 'eval' or 'single'");
- }
-
- PyCompilerFlags flags = _PyCompilerFlags_INIT;
- flags.cf_flags = PyCF_IGNORE_COOKIE;
-
- PyArena *arena = PyArena_New();
- if (arena == NULL) {
- return NULL;
- }
-
- mod_ty mod = _run_parser(the_string, filename, mode, &flags, arena, oldparser);
- if (mod == NULL) {
- PyArena_Free(arena);
- return NULL;
- }
-
- PyObject *result;
- if (ast) {
- result = PyAST_mod2obj(mod);
- }
- else {
- Py_INCREF(Py_None);
- result = Py_None;
- }
- PyArena_Free(arena);
- return result;
-}
-
-static PyMethodDef ParseMethods[] = {
- {
- "parse_string",
- (PyCFunction)(void (*)(void))_Py_parse_string,
- METH_VARARGS|METH_KEYWORDS,
- "Parse a string, return an AST."
- },
- {
- "compile_string",
- (PyCFunction)(void (*)(void))_Py_compile_string,
- METH_VARARGS|METH_KEYWORDS,
- "Compile a string, return a code object."
- },
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-
-static struct PyModuleDef parsemodule = {
- PyModuleDef_HEAD_INIT,
- .m_name = "peg_parser",
- .m_doc = "A parser.",
- .m_methods = ParseMethods,
-};
-
-PyMODINIT_FUNC
-PyInit__peg_parser(void)
-{
- return PyModule_Create(&parsemodule);
-}
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
deleted file mode 100644
index 24b0ffb..0000000
--- a/Modules/parsermodule.c
+++ /dev/null
@@ -1,1222 +0,0 @@
-/* parsermodule.c
- *
- * Copyright 1995-1996 by Fred L. Drake, Jr. and Virginia Polytechnic
- * Institute and State University, Blacksburg, Virginia, USA.
- * Portions copyright 1991-1995 by Stichting Mathematisch Centrum,
- * Amsterdam, The Netherlands. Copying is permitted under the terms
- * associated with the main Python distribution, with the additional
- * restriction that this additional notice be included and maintained
- * on all distributed copies.
- *
- * This module serves to replace the original parser module written
- * by Guido. The functionality is not matched precisely, but the
- * original may be implemented on top of this. This is desirable
- * since the source of the text to be parsed is now divorced from
- * this interface.
- *
- * Unlike the prior interface, the ability to give a parse tree
- * produced by Python code as a tuple to the compiler is enabled by
- * this module. See the documentation for more details.
- *
- * I've added some annotations that help with the lint code-checking
- * program, but they're not complete by a long shot. The real errors
- * that lint detects are gone, but there are still warnings with
- * Py_[X]DECREF() and Py_[X]INCREF() macros. The lint annotations
- * look like "NOTE(...)".
- *
- */
-
-#include "Python.h" /* general Python API */
-#include "Python-ast.h" /* mod_ty */
-#undef Yield /* undefine macro conflicting with <winbase.h> */
-#include "ast.h"
-#include "graminit.h" /* symbols defined in the grammar */
-#include "node.h" /* internal parser structure */
-#include "errcode.h" /* error codes for PyNode_*() */
-#include "token.h" /* token definitions */
- /* ISTERMINAL() / ISNONTERMINAL() */
-#include "grammar.h"
-#include "parsetok.h"
-
-extern grammar _PyParser_Grammar; /* From graminit.c */
-
-#ifdef lint
-#include <note.h>
-#else
-#define NOTE(x)
-#endif
-
-/* String constants used to initialize module attributes.
- *
- */
-static const char parser_copyright_string[] =
-"Copyright 1995-1996 by Virginia Polytechnic Institute & State\n\
-University, Blacksburg, Virginia, USA, and Fred L. Drake, Jr., Reston,\n\
-Virginia, USA. Portions copyright 1991-1995 by Stichting Mathematisch\n\
-Centrum, Amsterdam, The Netherlands.";
-
-
-PyDoc_STRVAR(parser_doc_string,
-"This is an interface to Python's internal parser.");
-
-static const char parser_version_string[] = "0.5";
-
-
-typedef PyObject* (*SeqMaker) (Py_ssize_t length);
-typedef int (*SeqInserter) (PyObject* sequence,
- Py_ssize_t index,
- PyObject* element);
-
-/* The function below is copyrighted by Stichting Mathematisch Centrum. The
- * original copyright statement is included below, and continues to apply
- * in full to the function immediately following. All other material is
- * original, copyrighted by Fred L. Drake, Jr. and Virginia Polytechnic
- * Institute and State University. Changes were made to comply with the
- * new naming conventions. Added arguments to provide support for creating
- * lists as well as tuples, and optionally including the line numbers.
- */
-
-
-static PyObject*
-node2tuple(node *n, /* node to convert */
- SeqMaker mkseq, /* create sequence */
- SeqInserter addelem, /* func. to add elem. in seq. */
- int lineno, /* include line numbers? */
- int col_offset) /* include column offsets? */
-{
- PyObject *result = NULL, *w;
-
- if (n == NULL) {
- Py_RETURN_NONE;
- }
-
- if (ISNONTERMINAL(TYPE(n))) {
- int i;
-
- result = mkseq(1 + NCH(n) + (TYPE(n) == encoding_decl));
- if (result == NULL)
- goto error;
-
- w = PyLong_FromLong(TYPE(n));
- if (w == NULL)
- goto error;
- (void) addelem(result, 0, w);
-
- for (i = 0; i < NCH(n); i++) {
- w = node2tuple(CHILD(n, i), mkseq, addelem, lineno, col_offset);
- if (w == NULL)
- goto error;
- (void) addelem(result, i+1, w);
- }
-
- if (TYPE(n) == encoding_decl) {
- w = PyUnicode_FromString(STR(n));
- if (w == NULL)
- goto error;
- (void) addelem(result, i+1, w);
- }
- }
- else if (ISTERMINAL(TYPE(n))) {
- result = mkseq(2 + lineno + col_offset);
- if (result == NULL)
- goto error;
-
- w = PyLong_FromLong(TYPE(n));
- if (w == NULL)
- goto error;
- (void) addelem(result, 0, w);
-
- w = PyUnicode_FromString(STR(n));
- if (w == NULL)
- goto error;
- (void) addelem(result, 1, w);
-
- if (lineno) {
- w = PyLong_FromLong(n->n_lineno);
- if (w == NULL)
- goto error;
- (void) addelem(result, 2, w);
- }
-
- if (col_offset) {
- w = PyLong_FromLong(n->n_col_offset);
- if (w == NULL)
- goto error;
- (void) addelem(result, 2 + lineno, w);
- }
- }
- else {
- PyErr_SetString(PyExc_SystemError,
- "unrecognized parse tree node type");
- return ((PyObject*) NULL);
- }
- return result;
-
-error:
- Py_XDECREF(result);
- return NULL;
-}
-/*
- * End of material copyrighted by Stichting Mathematisch Centrum.
- */
-
-
-
-/* There are two types of intermediate objects we're interested in:
- * 'eval' and 'exec' types. These constants can be used in the st_type
- * field of the object type to identify which any given object represents.
- * These should probably go in an external header to allow other extensions
- * to use them, but then, we really should be using C++ too. ;-)
- */
-
-#define PyST_EXPR 1
-#define PyST_SUITE 2
-
-
-/* These are the internal objects and definitions required to implement the
- * ST type. Most of the internal names are more reminiscent of the 'old'
- * naming style, but the code uses the new naming convention.
- */
-
-static PyObject*
-parser_error = 0;
-
-
-typedef struct {
- PyObject_HEAD /* standard object header */
- node* st_node; /* the node* returned by the parser */
- int st_type; /* EXPR or SUITE ? */
- PyCompilerFlags st_flags; /* Parser and compiler flags */
-} PyST_Object;
-
-
-static void parser_free(PyST_Object *st);
-static PyObject* parser_sizeof(PyST_Object *, void *);
-static PyObject* parser_richcompare(PyObject *left, PyObject *right, int op);
-static PyObject* parser_compilest(PyST_Object *, PyObject *, PyObject *);
-static PyObject* parser_isexpr(PyST_Object *, PyObject *, PyObject *);
-static PyObject* parser_issuite(PyST_Object *, PyObject *, PyObject *);
-static PyObject* parser_st2list(PyST_Object *, PyObject *, PyObject *);
-static PyObject* parser_st2tuple(PyST_Object *, PyObject *, PyObject *);
-
-#define PUBLIC_METHOD_TYPE (METH_VARARGS|METH_KEYWORDS)
-
-static PyMethodDef parser_methods[] = {
- {"compile", (PyCFunction)(void(*)(void))parser_compilest, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Compile this ST object into a code object.")},
- {"isexpr", (PyCFunction)(void(*)(void))parser_isexpr, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Determines if this ST object was created from an expression.")},
- {"issuite", (PyCFunction)(void(*)(void))parser_issuite, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Determines if this ST object was created from a suite.")},
- {"tolist", (PyCFunction)(void(*)(void))parser_st2list, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a list-tree representation of this ST.")},
- {"totuple", (PyCFunction)(void(*)(void))parser_st2tuple, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a tuple-tree representation of this ST.")},
- {"__sizeof__", (PyCFunction)parser_sizeof, METH_NOARGS,
- PyDoc_STR("Returns size in memory, in bytes.")},
- {NULL, NULL, 0, NULL}
-};
-
-static
-PyTypeObject PyST_Type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "parser.st", /* tp_name */
- (int) sizeof(PyST_Object), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)parser_free, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_as_async */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
-
- /* Functions to access object as input/output buffer */
- 0, /* tp_as_buffer */
-
- Py_TPFLAGS_DEFAULT, /* tp_flags */
-
- /* __doc__ */
- "Intermediate representation of a Python parse tree.",
- 0, /* tp_traverse */
- 0, /* tp_clear */
- parser_richcompare, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- parser_methods, /* tp_methods */
-}; /* PyST_Type */
-
-
-/* PyST_Type isn't subclassable, so just check ob_type */
-#define PyST_Object_Check(v) Py_IS_TYPE(v, &PyST_Type)
-
-static int
-parser_compare_nodes(node *left, node *right)
-{
- int j;
-
- if (TYPE(left) < TYPE(right))
- return (-1);
-
- if (TYPE(right) < TYPE(left))
- return (1);
-
- if (ISTERMINAL(TYPE(left)))
- return (strcmp(STR(left), STR(right)));
-
- if (NCH(left) < NCH(right))
- return (-1);
-
- if (NCH(right) < NCH(left))
- return (1);
-
- for (j = 0; j < NCH(left); ++j) {
- int v = parser_compare_nodes(CHILD(left, j), CHILD(right, j));
-
- if (v != 0)
- return (v);
- }
- return (0);
-}
-
-/* parser_richcompare(PyObject* left, PyObject* right, int op)
- *
- * Comparison function used by the Python operators ==, !=, <, >, <=, >=
- * This really just wraps a call to parser_compare_nodes() with some easy
- * checks and protection code.
- *
- */
-
-static PyObject *
-parser_richcompare(PyObject *left, PyObject *right, int op)
-{
- int result;
-
- /* neither argument should be NULL, unless something's gone wrong */
- if (left == NULL || right == NULL) {
- PyErr_BadInternalCall();
- return NULL;
- }
-
- /* both arguments should be instances of PyST_Object */
- if (!PyST_Object_Check(left) || !PyST_Object_Check(right)) {
- Py_RETURN_NOTIMPLEMENTED;
- }
-
- if (left == right)
- /* if arguments are identical, they're equal */
- result = 0;
- else
- result = parser_compare_nodes(((PyST_Object *)left)->st_node,
- ((PyST_Object *)right)->st_node);
-
- Py_RETURN_RICHCOMPARE(result, 0, op);
-}
-
-/* parser_newstobject(node* st)
- *
- * Allocates a new Python object representing an ST. This is simply the
- * 'wrapper' object that holds a node* and allows it to be passed around in
- * Python code.
- *
- */
-static PyObject*
-parser_newstobject(node *st, int type)
-{
- PyST_Object* o = PyObject_New(PyST_Object, &PyST_Type);
-
- if (o != 0) {
- o->st_node = st;
- o->st_type = type;
- o->st_flags = _PyCompilerFlags_INIT;
- }
- else {
- PyNode_Free(st);
- }
- return ((PyObject*)o);
-}
-
-
-/* void parser_free(PyST_Object* st)
- *
- * This is called by a del statement that reduces the reference count to 0.
- *
- */
-static void
-parser_free(PyST_Object *st)
-{
- PyNode_Free(st->st_node);
- PyObject_Del(st);
-}
-
-static PyObject *
-parser_sizeof(PyST_Object *st, void *unused)
-{
- Py_ssize_t res;
-
- res = _PyObject_SIZE(Py_TYPE(st)) + _PyNode_SizeOf(st->st_node);
- return PyLong_FromSsize_t(res);
-}
-
-
-/* parser_st2tuple(PyObject* self, PyObject* args, PyObject* kw)
- *
- * This provides conversion from a node* to a tuple object that can be
- * returned to the Python-level caller. The ST object is not modified.
- *
- */
-static PyObject*
-parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- int line_info = 0;
- int col_info = 0;
- PyObject *res = 0;
- int ok;
-
- static char *keywords[] = {"st", "line_info", "col_info", NULL};
-
- if (self == NULL || PyModule_Check(self)) {
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|pp:st2tuple", keywords,
- &PyST_Type, &self, &line_info,
- &col_info);
- }
- else
- ok = PyArg_ParseTupleAndKeywords(args, kw, "|pp:totuple", &keywords[1],
- &line_info, &col_info);
- if (ok != 0) {
- /*
- * Convert ST into a tuple representation. Use Guido's function,
- * since it's known to work already.
- */
- res = node2tuple(((PyST_Object*)self)->st_node,
- PyTuple_New, PyTuple_SetItem, line_info, col_info);
- }
- return (res);
-}
-
-
-/* parser_st2list(PyObject* self, PyObject* args, PyObject* kw)
- *
- * This provides conversion from a node* to a list object that can be
- * returned to the Python-level caller. The ST object is not modified.
- *
- */
-static PyObject*
-parser_st2list(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- int line_info = 0;
- int col_info = 0;
- PyObject *res = 0;
- int ok;
-
- static char *keywords[] = {"st", "line_info", "col_info", NULL};
-
- if (self == NULL || PyModule_Check(self))
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|pp:st2list", keywords,
- &PyST_Type, &self, &line_info,
- &col_info);
- else
- ok = PyArg_ParseTupleAndKeywords(args, kw, "|pp:tolist", &keywords[1],
- &line_info, &col_info);
- if (ok) {
- /*
- * Convert ST into a tuple representation. Use Guido's function,
- * since it's known to work already.
- */
- res = node2tuple(self->st_node,
- PyList_New, PyList_SetItem, line_info, col_info);
- }
- return (res);
-}
-
-
-/* parser_compilest(PyObject* self, PyObject* args)
- *
- * This function creates code objects from the parse tree represented by
- * the passed-in data object. An optional file name is passed in as well.
- *
- */
-static PyObject*
-parser_compilest(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- PyObject* res = NULL;
- PyArena* arena = NULL;
- mod_ty mod;
- PyObject* filename = NULL;
- int ok;
-
- static char *keywords[] = {"st", "filename", NULL};
-
- if (self == NULL || PyModule_Check(self))
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O&:compilest", keywords,
- &PyST_Type, &self,
- PyUnicode_FSDecoder, &filename);
- else
- ok = PyArg_ParseTupleAndKeywords(args, kw, "|O&:compile", &keywords[1],
- PyUnicode_FSDecoder, &filename);
- if (!ok)
- goto error;
-
- if (filename == NULL) {
- filename = PyUnicode_FromString("<syntax-tree>");
- if (filename == NULL)
- goto error;
- }
-
- arena = PyArena_New();
- if (!arena)
- goto error;
-
- mod = PyAST_FromNodeObject(self->st_node, &self->st_flags,
- filename, arena);
- if (!mod)
- goto error;
-
- res = (PyObject *)PyAST_CompileObject(mod, filename,
- &self->st_flags, -1, arena);
-error:
- Py_XDECREF(filename);
- if (arena != NULL)
- PyArena_Free(arena);
- return res;
-}
-
-
-/* PyObject* parser_isexpr(PyObject* self, PyObject* args)
- * PyObject* parser_issuite(PyObject* self, PyObject* args)
- *
- * Checks the passed-in ST object to determine if it is an expression or
- * a statement suite, respectively. The return is a Python truth value.
- *
- */
-static PyObject*
-parser_isexpr(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- PyObject* res = 0;
- int ok;
-
- static char *keywords[] = {"st", NULL};
-
- if (self == NULL || PyModule_Check(self))
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:isexpr", keywords,
- &PyST_Type, &self);
- else
- ok = PyArg_ParseTupleAndKeywords(args, kw, ":isexpr", &keywords[1]);
-
- if (ok) {
- /* Check to see if the ST represents an expression or not. */
- res = (self->st_type == PyST_EXPR) ? Py_True : Py_False;
- Py_INCREF(res);
- }
- return (res);
-}
-
-
-static PyObject*
-parser_issuite(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- PyObject* res = 0;
- int ok;
-
- static char *keywords[] = {"st", NULL};
-
- if (self == NULL || PyModule_Check(self))
- ok = PyArg_ParseTupleAndKeywords(args, kw, "O!:issuite", keywords,
- &PyST_Type, &self);
- else
- ok = PyArg_ParseTupleAndKeywords(args, kw, ":issuite", &keywords[1]);
-
- if (ok) {
- /* Check to see if the ST represents an expression or not. */
- res = (self->st_type == PyST_EXPR) ? Py_False : Py_True;
- Py_INCREF(res);
- }
- return (res);
-}
-
-
-/* err_string(const char* message)
- *
- * Sets the error string for an exception of type ParserError.
- *
- */
-static void
-err_string(const char *message)
-{
- PyErr_SetString(parser_error, message);
-}
-
-
-/* PyObject* parser_do_parse(PyObject* args, int type)
- *
- * Internal function to actually execute the parse and return the result if
- * successful or set an exception if not.
- *
- */
-static PyObject*
-parser_do_parse(PyObject *args, PyObject *kw, const char *argspec, int type)
-{
- char* string = 0;
- PyObject* res = 0;
- int flags = 0;
- perrdetail err;
-
- static char *keywords[] = {"source", NULL};
-
- if (PyArg_ParseTupleAndKeywords(args, kw, argspec, keywords, &string)) {
- node* n = PyParser_ParseStringFlagsFilenameEx(string, NULL,
- &_PyParser_Grammar,
- (type == PyST_EXPR)
- ? eval_input : file_input,
- &err, &flags);
-
- if (n) {
- res = parser_newstobject(n, type);
- if (res) {
- ((PyST_Object *)res)->st_flags.cf_flags = flags & PyCF_MASK;
- ((PyST_Object *)res)->st_flags.cf_feature_version = PY_MINOR_VERSION;
- }
- }
- else {
- PyParser_SetError(&err);
- }
- PyParser_ClearError(&err);
- }
- return (res);
-}
-
-
-/* PyObject* parser_expr(PyObject* self, PyObject* args)
- * PyObject* parser_suite(PyObject* self, PyObject* args)
- *
- * External interfaces to the parser itself. Which is called determines if
- * the parser attempts to recognize an expression ('eval' form) or statement
- * suite ('exec' form). The real work is done by parser_do_parse() above.
- *
- */
-static PyObject*
-parser_expr(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- NOTE(ARGUNUSED(self))
- return (parser_do_parse(args, kw, "s:expr", PyST_EXPR));
-}
-
-
-static PyObject*
-parser_suite(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- NOTE(ARGUNUSED(self))
- return (parser_do_parse(args, kw, "s:suite", PyST_SUITE));
-}
-
-
-
-/* This is the messy part of the code. Conversion from a tuple to an ST
- * object requires that the input tuple be valid without having to rely on
- * catching an exception from the compiler. This is done to allow the
- * compiler itself to remain fast, since most of its input will come from
- * the parser directly, and therefore be known to be syntactically correct.
- * This validation is done to ensure that we don't core dump the compile
- * phase, returning an exception instead.
- *
- * Two aspects can be broken out in this code: creating a node tree from
- * the tuple passed in, and verifying that it is indeed valid. It may be
- * advantageous to expand the number of ST types to include funcdefs and
- * lambdadefs to take advantage of the optimizer, recognizing those STs
- * here. They are not necessary, and not quite as useful in a raw form.
- * For now, let's get expressions and suites working reliably.
- */
-
-
-static node* build_node_tree(PyObject *tuple);
-
-static int
-validate_node(node *tree)
-{
- int type = TYPE(tree);
- int nch = NCH(tree);
- state *dfa_state;
- int pos, arc;
-
- assert(ISNONTERMINAL(type));
- type -= NT_OFFSET;
- if (type >= _PyParser_Grammar.g_ndfas) {
- PyErr_Format(parser_error, "Unrecognized node type %d.", TYPE(tree));
- return 0;
- }
- const dfa *nt_dfa = &_PyParser_Grammar.g_dfa[type];
- REQ(tree, nt_dfa->d_type);
-
- /* Run the DFA for this nonterminal. */
- dfa_state = nt_dfa->d_state;
- for (pos = 0; pos < nch; ++pos) {
- node *ch = CHILD(tree, pos);
- int ch_type = TYPE(ch);
- if ((ch_type >= NT_OFFSET + _PyParser_Grammar.g_ndfas)
- || (ISTERMINAL(ch_type) && (ch_type >= N_TOKENS))
- || (ch_type < 0)
- ) {
- PyErr_Format(parser_error, "Unrecognized node type %d.", ch_type);
- return 0;
- }
- if (ch_type == suite && TYPE(tree) == funcdef) {
- /* This is the opposite hack of what we do in parser.c
- (search for func_body_suite), except we don't ever
- support type comments here. */
- ch_type = func_body_suite;
- }
- for (arc = 0; arc < dfa_state->s_narcs; ++arc) {
- short a_label = dfa_state->s_arc[arc].a_lbl;
- assert(a_label < _PyParser_Grammar.g_ll.ll_nlabels);
-
- const char *label_str = _PyParser_Grammar.g_ll.ll_label[a_label].lb_str;
- if ((_PyParser_Grammar.g_ll.ll_label[a_label].lb_type == ch_type)
- && ((ch->n_str == NULL) || (label_str == NULL)
- || (strcmp(ch->n_str, label_str) == 0))
- ) {
- /* The child is acceptable; if non-terminal, validate it recursively. */
- if (ISNONTERMINAL(ch_type) && !validate_node(ch))
- return 0;
-
- /* Update the state, and move on to the next child. */
- dfa_state = &nt_dfa->d_state[dfa_state->s_arc[arc].a_arrow];
- goto arc_found;
- }
- }
- /* What would this state have accepted? */
- {
- short a_label = dfa_state->s_arc->a_lbl;
- if (!a_label) /* Wouldn't accept any more children */
- goto illegal_num_children;
-
- int next_type = _PyParser_Grammar.g_ll.ll_label[a_label].lb_type;
- const char *expected_str = _PyParser_Grammar.g_ll.ll_label[a_label].lb_str;
-
- if (ISNONTERMINAL(next_type)) {
- PyErr_Format(parser_error, "Expected %s, got %s.",
- _PyParser_Grammar.g_dfa[next_type - NT_OFFSET].d_name,
- ISTERMINAL(ch_type) ? _PyParser_TokenNames[ch_type] :
- _PyParser_Grammar.g_dfa[ch_type - NT_OFFSET].d_name);
- }
- else if (expected_str != NULL) {
- PyErr_Format(parser_error, "Illegal terminal: expected '%s'.",
- expected_str);
- }
- else {
- PyErr_Format(parser_error, "Illegal terminal: expected %s.",
- _PyParser_TokenNames[next_type]);
- }
- return 0;
- }
-
-arc_found:
- continue;
- }
- /* Are we in a final state? If so, return 1 for successful validation. */
- for (arc = 0; arc < dfa_state->s_narcs; ++arc) {
- if (!dfa_state->s_arc[arc].a_lbl) {
- return 1;
- }
- }
-
-illegal_num_children:
- PyErr_Format(parser_error,
- "Illegal number of children for %s node.", nt_dfa->d_name);
- return 0;
-}
-
-/* PyObject* parser_tuple2st(PyObject* self, PyObject* args)
- *
- * This is the public function, called from the Python code. It receives a
- * single tuple object from the caller, and creates an ST object if the
- * tuple can be validated. It does this by checking the first code of the
- * tuple, and, if acceptable, builds the internal representation. If this
- * step succeeds, the internal representation is validated as fully as
- * possible with the recursive validate_node() routine defined above.
- *
- * This function must be changed if support is to be added for PyST_FRAGMENT
- * ST objects.
- *
- */
-static PyObject*
-parser_tuple2st(PyST_Object *self, PyObject *args, PyObject *kw)
-{
- NOTE(ARGUNUSED(self))
- PyObject *st = 0;
- PyObject *tuple;
- node *tree;
-
- static char *keywords[] = {"sequence", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kw, "O:sequence2st", keywords,
- &tuple))
- return (0);
- if (!PySequence_Check(tuple)) {
- PyErr_SetString(PyExc_ValueError,
- "sequence2st() requires a single sequence argument");
- return (0);
- }
- /*
- * Convert the tree to the internal form before checking it.
- */
- tree = build_node_tree(tuple);
- if (tree != 0) {
- node *validation_root = NULL;
- int tree_type = 0;
- switch (TYPE(tree)) {
- case eval_input:
- /* Might be an eval form. */
- tree_type = PyST_EXPR;
- validation_root = tree;
- break;
- case encoding_decl:
- /* This looks like an encoding_decl so far. */
- if (NCH(tree) == 1) {
- tree_type = PyST_SUITE;
- validation_root = CHILD(tree, 0);
- }
- else {
- err_string("Error Parsing encoding_decl");
- }
- break;
- case file_input:
- /* This looks like an exec form so far. */
- tree_type = PyST_SUITE;
- validation_root = tree;
- break;
- default:
- /* This is a fragment, at best. */
- err_string("parse tree does not use a valid start symbol");
- }
-
- if (validation_root != NULL && validate_node(validation_root))
- st = parser_newstobject(tree, tree_type);
- else
- PyNode_Free(tree);
- }
- /* Make sure we raise an exception on all errors. We should never
- * get this, but we'd do well to be sure something is done.
- */
- if (st == NULL && !PyErr_Occurred())
- err_string("unspecified ST error occurred");
-
- return st;
-}
-
-
-/* node* build_node_children()
- *
- * Iterate across the children of the current non-terminal node and build
- * their structures. If successful, return the root of this portion of
- * the tree, otherwise, 0. Any required exception will be specified already,
- * and no memory will have been deallocated.
- *
- */
-static node*
-build_node_children(PyObject *tuple, node *root, int *line_num)
-{
- Py_ssize_t len = PyObject_Size(tuple);
- Py_ssize_t i;
- int err;
-
- if (len < 0) {
- return NULL;
- }
- for (i = 1; i < len; ++i) {
- /* elem must always be a sequence, however simple */
- PyObject* elem = PySequence_GetItem(tuple, i);
- int ok = elem != NULL;
- int type = 0;
- char *strn = 0;
-
- if (ok)
- ok = PySequence_Check(elem);
- if (ok) {
- PyObject *temp = PySequence_GetItem(elem, 0);
- if (temp == NULL)
- ok = 0;
- else {
- ok = PyLong_Check(temp);
- if (ok) {
- type = _PyLong_AsInt(temp);
- if (type == -1 && PyErr_Occurred()) {
- Py_DECREF(temp);
- Py_DECREF(elem);
- return NULL;
- }
- }
- Py_DECREF(temp);
- }
- }
- if (!ok) {
- PyObject *err = Py_BuildValue("Os", elem,
- "Illegal node construct.");
- PyErr_SetObject(parser_error, err);
- Py_XDECREF(err);
- Py_XDECREF(elem);
- return NULL;
- }
- if (ISTERMINAL(type)) {
- Py_ssize_t len = PyObject_Size(elem);
- PyObject *temp;
- const char *temp_str;
-
- if ((len != 2) && (len != 3)) {
- err_string("terminal nodes must have 2 or 3 entries");
- Py_DECREF(elem);
- return NULL;
- }
- temp = PySequence_GetItem(elem, 1);
- if (temp == NULL) {
- Py_DECREF(elem);
- return NULL;
- }
- if (!PyUnicode_Check(temp)) {
- PyErr_Format(parser_error,
- "second item in terminal node must be a string,"
- " found %s",
- Py_TYPE(temp)->tp_name);
- Py_DECREF(temp);
- Py_DECREF(elem);
- return NULL;
- }
- if (len == 3) {
- PyObject *o = PySequence_GetItem(elem, 2);
- if (o == NULL) {
- Py_DECREF(temp);
- Py_DECREF(elem);
- return NULL;
- }
- if (PyLong_Check(o)) {
- int num = _PyLong_AsInt(o);
- if (num == -1 && PyErr_Occurred()) {
- Py_DECREF(o);
- Py_DECREF(temp);
- Py_DECREF(elem);
- return NULL;
- }
- *line_num = num;
- }
- else {
- PyErr_Format(parser_error,
- "third item in terminal node must be an"
- " integer, found %s",
- Py_TYPE(temp)->tp_name);
- Py_DECREF(o);
- Py_DECREF(temp);
- Py_DECREF(elem);
- return NULL;
- }
- Py_DECREF(o);
- }
- temp_str = PyUnicode_AsUTF8AndSize(temp, &len);
- if (temp_str == NULL) {
- Py_DECREF(temp);
- Py_DECREF(elem);
- return NULL;
- }
- strn = (char *)PyObject_MALLOC(len + 1);
- if (strn == NULL) {
- Py_DECREF(temp);
- Py_DECREF(elem);
- PyErr_NoMemory();
- return NULL;
- }
- (void) memcpy(strn, temp_str, len + 1);
- Py_DECREF(temp);
- }
- else if (!ISNONTERMINAL(type)) {
- /*
- * It has to be one or the other; this is an error.
- * Raise an exception.
- */
- PyObject *err = Py_BuildValue("Os", elem, "unknown node type.");
- PyErr_SetObject(parser_error, err);
- Py_XDECREF(err);
- Py_DECREF(elem);
- return NULL;
- }
- err = PyNode_AddChild(root, type, strn, *line_num, 0, *line_num, 0);
- if (err == E_NOMEM) {
- Py_DECREF(elem);
- PyObject_FREE(strn);
- PyErr_NoMemory();
- return NULL;
- }
- if (err == E_OVERFLOW) {
- Py_DECREF(elem);
- PyObject_FREE(strn);
- PyErr_SetString(PyExc_ValueError,
- "unsupported number of child nodes");
- return NULL;
- }
-
- if (ISNONTERMINAL(type)) {
- node* new_child = CHILD(root, i - 1);
-
- if (new_child != build_node_children(elem, new_child, line_num)) {
- Py_DECREF(elem);
- return NULL;
- }
- }
- else if (type == NEWLINE) { /* It's true: we increment the */
- ++(*line_num); /* line number *after* the newline! */
- }
- Py_DECREF(elem);
- }
- return root;
-}
-
-
-static node*
-build_node_tree(PyObject *tuple)
-{
- node* res = 0;
- PyObject *temp = PySequence_GetItem(tuple, 0);
- long num = -1;
-
- if (temp != NULL)
- num = PyLong_AsLong(temp);
- Py_XDECREF(temp);
- if (ISTERMINAL(num)) {
- /*
- * The tuple is simple, but it doesn't start with a start symbol.
- * Raise an exception now and be done with it.
- */
- tuple = Py_BuildValue("Os", tuple,
- "Illegal syntax-tree; cannot start with terminal symbol.");
- PyErr_SetObject(parser_error, tuple);
- Py_XDECREF(tuple);
- }
- else if (ISNONTERMINAL(num)) {
- /*
- * Not efficient, but that can be handled later.
- */
- int line_num = 0;
- PyObject *encoding = NULL;
-
- if (num == encoding_decl) {
- encoding = PySequence_GetItem(tuple, 2);
- if (encoding == NULL) {
- PyErr_SetString(parser_error, "missed encoding");
- return NULL;
- }
- if (!PyUnicode_Check(encoding)) {
- PyErr_Format(parser_error,
- "encoding must be a string, found %.200s",
- Py_TYPE(encoding)->tp_name);
- Py_DECREF(encoding);
- return NULL;
- }
- /* tuple isn't borrowed anymore here, need to DECREF */
- tuple = PySequence_GetSlice(tuple, 0, 2);
- if (tuple == NULL) {
- Py_DECREF(encoding);
- return NULL;
- }
- }
- res = PyNode_New(num);
- if (res != NULL) {
- if (res != build_node_children(tuple, res, &line_num)) {
- PyNode_Free(res);
- res = NULL;
- }
- if (res && encoding) {
- Py_ssize_t len;
- const char *temp;
- temp = PyUnicode_AsUTF8AndSize(encoding, &len);
- if (temp == NULL) {
- PyNode_Free(res);
- Py_DECREF(encoding);
- Py_DECREF(tuple);
- return NULL;
- }
- res->n_str = (char *)PyObject_MALLOC(len + 1);
- if (res->n_str == NULL) {
- PyNode_Free(res);
- Py_DECREF(encoding);
- Py_DECREF(tuple);
- PyErr_NoMemory();
- return NULL;
- }
- (void) memcpy(res->n_str, temp, len + 1);
- }
- }
- if (encoding != NULL) {
- Py_DECREF(encoding);
- Py_DECREF(tuple);
- }
- }
- else {
- /* The tuple is illegal -- if the number is neither TERMINAL nor
- * NONTERMINAL, we can't use it. Not sure the implementation
- * allows this condition, but the API doesn't preclude it.
- */
- PyObject *err = Py_BuildValue("Os", tuple,
- "Illegal component tuple.");
- PyErr_SetObject(parser_error, err);
- Py_XDECREF(err);
- }
-
- return (res);
-}
-
-
-static PyObject*
-pickle_constructor = NULL;
-
-
-static PyObject*
-parser__pickler(PyObject *self, PyObject *args)
-{
- NOTE(ARGUNUSED(self))
- PyObject *result = NULL;
- PyObject *st = NULL;
-
- if (PyArg_ParseTuple(args, "O!:_pickler", &PyST_Type, &st)) {
- PyObject *newargs;
- PyObject *tuple;
-
- if ((newargs = PyTuple_Pack(2, st, Py_True)) == NULL)
- return NULL;
- tuple = parser_st2tuple((PyST_Object*)NULL, newargs, NULL);
- if (tuple != NULL) {
- result = Py_BuildValue("O(O)", pickle_constructor, tuple);
- Py_DECREF(tuple);
- }
- Py_DECREF(newargs);
- }
-
- return (result);
-}
-
-
-/* Functions exported by this module. Most of this should probably
- * be converted into an ST object with methods, but that is better
- * done directly in Python, allowing subclasses to be created directly.
- * We'd really have to write a wrapper around it all anyway to allow
- * inheritance.
- */
-static PyMethodDef parser_functions[] = {
- {"compilest", (PyCFunction)(void(*)(void))parser_compilest, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Compiles an ST object into a code object.")},
- {"expr", (PyCFunction)(void(*)(void))parser_expr, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from an expression.")},
- {"isexpr", (PyCFunction)(void(*)(void))parser_isexpr, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Determines if an ST object was created from an expression.")},
- {"issuite", (PyCFunction)(void(*)(void))parser_issuite, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Determines if an ST object was created from a suite.")},
- {"suite", (PyCFunction)(void(*)(void))parser_suite, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from a suite.")},
- {"sequence2st", (PyCFunction)(void(*)(void))parser_tuple2st, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from a tree representation.")},
- {"st2tuple", (PyCFunction)(void(*)(void))parser_st2tuple, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a tuple-tree representation of an ST.")},
- {"st2list", (PyCFunction)(void(*)(void))parser_st2list, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates a list-tree representation of an ST.")},
- {"tuple2st", (PyCFunction)(void(*)(void))parser_tuple2st, PUBLIC_METHOD_TYPE,
- PyDoc_STR("Creates an ST object from a tree representation.")},
-
- /* private stuff: support pickle module */
- {"_pickler", (PyCFunction)parser__pickler, METH_VARARGS,
- PyDoc_STR("Returns the pickle magic to allow ST objects to be pickled.")},
-
- {NULL, NULL, 0, NULL}
- };
-
-
-
-static struct PyModuleDef parsermodule = {
- PyModuleDef_HEAD_INIT,
- "parser",
- NULL,
- -1,
- parser_functions,
- NULL,
- NULL,
- NULL,
- NULL
-};
-
-PyMODINIT_FUNC PyInit_parser(void); /* supply a prototype */
-
-PyMODINIT_FUNC
-PyInit_parser(void)
-{
- PyObject *module, *copyreg;
-
- if (PyErr_WarnEx(PyExc_DeprecationWarning,
- "The parser module is deprecated and will be removed "
- "in future versions of Python", 7) != 0) {
- return NULL;
- }
-
- if (PyType_Ready(&PyST_Type) < 0)
- return NULL;
- module = PyModule_Create(&parsermodule);
- if (module == NULL)
- return NULL;
-
- if (parser_error == 0)
- parser_error = PyErr_NewException("parser.ParserError", NULL, NULL);
-
- if (parser_error == 0)
- return NULL;
- /* CAUTION: The code next used to skip bumping the refcount on
- * parser_error. That's a disaster if PyInit_parser() gets called more
- * than once. By incref'ing, we ensure that each module dict that
- * gets created owns its reference to the shared parser_error object,
- * and the file static parser_error vrbl owns a reference too.
- */
- Py_INCREF(parser_error);
- if (PyModule_AddObject(module, "ParserError", parser_error) != 0)
- return NULL;
-
- Py_INCREF(&PyST_Type);
- PyModule_AddObject(module, "STType", (PyObject*)&PyST_Type);
-
- PyModule_AddStringConstant(module, "__copyright__",
- parser_copyright_string);
- PyModule_AddStringConstant(module, "__doc__",
- parser_doc_string);
- PyModule_AddStringConstant(module, "__version__",
- parser_version_string);
-
- /* Register to support pickling.
- * If this fails, the import of this module will fail because an
- * exception will be raised here; should we clear the exception?
- */
- copyreg = PyImport_ImportModuleNoBlock("copyreg");
- if (copyreg != NULL) {
- PyObject *func, *pickler;
- _Py_IDENTIFIER(pickle);
- _Py_IDENTIFIER(sequence2st);
- _Py_IDENTIFIER(_pickler);
-
- func = _PyObject_GetAttrId(copyreg, &PyId_pickle);
- pickle_constructor = _PyObject_GetAttrId(module, &PyId_sequence2st);
- pickler = _PyObject_GetAttrId(module, &PyId__pickler);
- Py_XINCREF(pickle_constructor);
- if ((func != NULL) && (pickle_constructor != NULL)
- && (pickler != NULL)) {
- PyObject *res;
-
- res = PyObject_CallFunctionObjArgs(func, &PyST_Type, pickler,
- pickle_constructor, NULL);
- Py_XDECREF(res);
- }
- Py_XDECREF(func);
- Py_XDECREF(pickle_constructor);
- Py_XDECREF(pickler);
- Py_DECREF(copyreg);
- }
- return module;
-}
diff --git a/PC/config.c b/PC/config.c
index 32af2a8..87cd76d 100644
--- a/PC/config.c
+++ b/PC/config.c
@@ -45,7 +45,6 @@ extern PyObject* PyInit__symtable(void);
extern PyObject* PyInit_mmap(void);
extern PyObject* PyInit__csv(void);
extern PyObject* PyInit__sre(void);
-extern PyObject* PyInit_parser(void);
extern PyObject* PyInit_winreg(void);
extern PyObject* PyInit__struct(void);
extern PyObject* PyInit__datetime(void);
@@ -75,7 +74,6 @@ extern PyObject* PyInit__opcode(void);
extern PyObject* PyInit__contextvars(void);
-extern PyObject* PyInit__peg_parser(void);
/* tools/freeze/makeconfig.py marker for additional "extern" */
/* -- ADDMODULE MARKER 1 -- */
@@ -127,7 +125,6 @@ struct _inittab _PyImport_Inittab[] = {
{"mmap", PyInit_mmap},
{"_csv", PyInit__csv},
{"_sre", PyInit__sre},
- {"parser", PyInit_parser},
{"winreg", PyInit_winreg},
{"_struct", PyInit__struct},
{"_datetime", PyInit__datetime},
@@ -171,7 +168,6 @@ struct _inittab _PyImport_Inittab[] = {
{"_opcode", PyInit__opcode},
{"_contextvars", PyInit__contextvars},
- {"_peg_parser", PyInit__peg_parser},
/* Sentinel */
{0, 0}
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 8d5f99f..2653ce9 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -279,10 +279,9 @@
<ClInclude Include="..\Objects\stringlib\replace.h" />
<ClInclude Include="..\Objects\stringlib\split.h" />
<ClInclude Include="..\Objects\unicodetype_db.h" />
- <ClInclude Include="..\Parser\parser.h" />
<ClInclude Include="..\Parser\tokenizer.h" />
- <ClInclude Include="..\Parser\pegen\parse_string.h" />
- <ClInclude Include="..\Parser\pegen\pegen.h" />
+ <ClInclude Include="..\Parser\string_parser.h" />
+ <ClInclude Include="..\Parser\pegen.h" />
<ClInclude Include="..\PC\errmap.h" />
<ClInclude Include="..\PC\pyconfig.h" />
<ClInclude Include="..\Python\ceval_gil.h" />
@@ -343,8 +342,6 @@
<ClCompile Include="..\Modules\mmapmodule.c" />
<ClCompile Include="..\Modules\_opcode.c" />
<ClCompile Include="..\Modules\_operator.c" />
- <ClCompile Include="..\Modules\parsermodule.c" />
- <ClCompile Include="..\Modules\_peg_parser.c" />
<ClCompile Include="..\Modules\posixmodule.c" />
<ClCompile Include="..\Modules\rotatingtree.c" />
<ClCompile Include="..\Modules\sha1module.c" />
@@ -417,19 +414,13 @@
<ClCompile Include="..\Objects\unicodectype.c" />
<ClCompile Include="..\Objects\unicodeobject.c" />
<ClCompile Include="..\Objects\weakrefobject.c" />
- <ClCompile Include="..\Parser\acceler.c" />
- <ClCompile Include="..\Parser\grammar1.c" />
- <ClCompile Include="..\Parser\listnode.c" />
<ClCompile Include="..\Parser\myreadline.c" />
- <ClCompile Include="..\Parser\node.c" />
- <ClCompile Include="..\Parser\parser.c" />
- <ClCompile Include="..\Parser\parsetok.c" />
<ClCompile Include="..\Parser\tokenizer.c" />
<ClCompile Include="..\Parser\token.c" />
- <ClCompile Include="..\Parser\pegen\pegen.c" />
- <ClCompile Include="..\Parser\pegen\parse.c" />
- <ClCompile Include="..\Parser\pegen\parse_string.c" />
- <ClCompile Include="..\Parser\pegen\peg_api.c" />
+ <ClCompile Include="..\Parser\pegen.c" />
+ <ClCompile Include="..\Parser\parser.c" />
+ <ClCompile Include="..\Parser\string_parser.c" />
+ <ClCompile Include="..\Parser\peg_api.c" />
<ClCompile Include="..\PC\invalid_parameter_handler.c" />
<ClCompile Include="..\PC\winreg.c" />
<ClCompile Include="..\PC\config.c" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index 7bc9f8f..6ea7afa 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -522,9 +522,6 @@
<ClInclude Include="..\Objects\unicodetype_db.h">
<Filter>Objects</Filter>
</ClInclude>
- <ClInclude Include="..\Parser\parser.h">
- <Filter>Parser</Filter>
- </ClInclude>
<ClInclude Include="..\Parser\tokenizer.h">
<Filter>Parser</Filter>
</ClInclude>
@@ -908,12 +905,6 @@
<ClCompile Include="..\Objects\weakrefobject.c">
<Filter>Objects</Filter>
</ClCompile>
- <ClCompile Include="..\Parser\acceler.c">
- <Filter>Parser</Filter>
- </ClCompile>
- <ClCompile Include="..\Parser\grammar1.c">
- <Filter>Parser</Filter>
- </ClCompile>
<ClCompile Include="..\Parser\pegen\pegen.c">
<Filter>Parser</Filter>
</ClCompile>
@@ -926,21 +917,9 @@
<ClCompile Include="..\Parser\pegen\peg_api.c">
<Filter>Parser</Filter>
</ClCompile>
- <ClCompile Include="..\Parser\listnode.c">
- <Filter>Parser</Filter>
- </ClCompile>
<ClCompile Include="..\Parser\myreadline.c">
<Filter>Parser</Filter>
</ClCompile>
- <ClCompile Include="..\Parser\node.c">
- <Filter>Parser</Filter>
- </ClCompile>
- <ClCompile Include="..\Parser\parser.c">
- <Filter>Parser</Filter>
- </ClCompile>
- <ClCompile Include="..\Parser\parsetok.c">
- <Filter>Parser</Filter>
- </ClCompile>
<ClCompile Include="..\Parser\tokenizer.c">
<Filter>Parser</Filter>
</ClCompile>
diff --git a/PCbuild/regen.vcxproj b/PCbuild/regen.vcxproj
index 564a4dd..ea246ff 100644
--- a/PCbuild/regen.vcxproj
+++ b/PCbuild/regen.vcxproj
@@ -155,22 +155,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
- <Target Name="_RegenGrammar" BeforeTargets="Build">
- <!-- Regenerate Include/graminit.h and Python/graminit.c from Grammar/Grammar using pgen-->
- <Exec Command="&quot;$(PythonExe)&quot; -m Parser.pgen &quot;$(PySourcePath)Grammar\Grammar&quot; &quot;$(PySourcePath)Grammar\Tokens&quot; &quot;$(IntDir)graminit.h&quot; &quot;$(IntDir)graminit.c&quot;" />
- <Copy SourceFiles="$(IntDir)graminit.h" DestinationFiles="$(PySourcePath)Include\graminit.h">
- <Output TaskParameter="CopiedFiles" ItemName="_UpdatedH" />
- </Copy>
- <Copy SourceFiles="$(IntDir)graminit.c" DestinationFiles="$(PySourcePath)Python\graminit.c">
- <Output TaskParameter="CopiedFiles" ItemName="_UpdatedC" />
- </Copy>
- <Warning Text="Grammar updated. You will need to rebuild pythoncore to see the changes." Condition="'@(_UpdatedH)' != '' and '@(_UpdatedC)' != ''" />
- </Target>
<Target Name="_RegenPegen" BeforeTargets="Build">
- <!-- Regenerate Parser/pegen/parse.c -->
+ <!-- Regenerate Parser/parser.c -->
<SetEnv Name="PYTHONPATH" Prefix="true" Value="$(PySourcePath)Tools\peg_generator\" />
- <Exec Command="&quot;$(PythonExe)&quot; -m pegen -q c &quot;$(PySourcePath)Grammar\python.gram&quot; &quot;$(PySourcePath)Grammar\Tokens&quot; -o &quot;$(IntDir)parse.c&quot;" />
- <Copy SourceFiles="$(IntDir)parse.c" DestinationFiles="$(PySourcePath)Parser\pegen\parse.c">
+ <Exec Command="&quot;$(PythonExe)&quot; -m pegen -q c &quot;$(PySourcePath)Grammar\python.gram&quot; &quot;$(PySourcePath)Grammar\Tokens&quot; -o &quot;$(IntDir)parser.c&quot;" />
+ <Copy SourceFiles="$(IntDir)parser.c" DestinationFiles="$(PySourcePath)Parser\parser.c">
<Output TaskParameter="CopiedFiles" ItemName="_UpdatedParse" />
</Copy>
<Warning Text="Pegen updated. You will need to rebuild pythoncore to see the changes." Condition="'@(_UpdatedParse)' != ''" />
diff --git a/Parser/acceler.c b/Parser/acceler.c
deleted file mode 100644
index e515833..0000000
--- a/Parser/acceler.c
+++ /dev/null
@@ -1,123 +0,0 @@
-
-/* Parser accelerator module */
-
-/* The parser as originally conceived had disappointing performance.
- This module does some precomputation that speeds up the selection
- of a DFA based upon a token, turning a search through an array
- into a simple indexing operation. The parser now cannot work
- without the accelerators installed. Note that the accelerators
- are installed dynamically when the parser is initialized, they
- are not part of the static data structure written on graminit.[ch]
- by the parser generator. */
-
-#include "Python.h"
-#include "grammar.h"
-#include "node.h"
-#include "token.h"
-#include "parser.h"
-
-/* Forward references */
-static void fixdfa(grammar *, const dfa *);
-static void fixstate(grammar *, state *);
-
-void
-PyGrammar_AddAccelerators(grammar *g)
-{
- int i;
- const dfa *d = g->g_dfa;
- for (i = g->g_ndfas; --i >= 0; d++)
- fixdfa(g, d);
- g->g_accel = 1;
-}
-
-void
-PyGrammar_RemoveAccelerators(grammar *g)
-{
- int i;
- g->g_accel = 0;
- const dfa *d = g->g_dfa;
- for (i = g->g_ndfas; --i >= 0; d++) {
- state *s;
- int j;
- s = d->d_state;
- for (j = 0; j < d->d_nstates; j++, s++) {
- if (s->s_accel)
- PyObject_FREE(s->s_accel);
- s->s_accel = NULL;
- }
- }
-}
-
-static void
-fixdfa(grammar *g, const dfa *d)
-{
- state *s;
- int j;
- s = d->d_state;
- for (j = 0; j < d->d_nstates; j++, s++)
- fixstate(g, s);
-}
-
-static void
-fixstate(grammar *g, state *s)
-{
- const arc *a;
- int k;
- int *accel;
- int nl = g->g_ll.ll_nlabels;
- s->s_accept = 0;
- accel = (int *) PyObject_MALLOC(nl * sizeof(int));
- if (accel == NULL) {
- fprintf(stderr, "no mem to build parser accelerators\n");
- exit(1);
- }
- for (k = 0; k < nl; k++)
- accel[k] = -1;
- a = s->s_arc;
- for (k = s->s_narcs; --k >= 0; a++) {
- int lbl = a->a_lbl;
- const label *l = &g->g_ll.ll_label[lbl];
- int type = l->lb_type;
- if (a->a_arrow >= (1 << 7)) {
- printf("XXX too many states!\n");
- continue;
- }
- if (ISNONTERMINAL(type)) {
- const dfa *d1 = PyGrammar_FindDFA(g, type);
- int ibit;
- if (type - NT_OFFSET >= (1 << 7)) {
- printf("XXX too high nonterminal number!\n");
- continue;
- }
- for (ibit = 0; ibit < g->g_ll.ll_nlabels; ibit++) {
- if (testbit(d1->d_first, ibit)) {
- if (accel[ibit] != -1)
- printf("XXX ambiguity!\n");
- accel[ibit] = a->a_arrow | (1 << 7) |
- ((type - NT_OFFSET) << 8);
- }
- }
- }
- else if (lbl == EMPTY)
- s->s_accept = 1;
- else if (lbl >= 0 && lbl < nl)
- accel[lbl] = a->a_arrow;
- }
- while (nl > 0 && accel[nl-1] == -1)
- nl--;
- for (k = 0; k < nl && accel[k] == -1;)
- k++;
- if (k < nl) {
- int i;
- s->s_accel = (int *) PyObject_MALLOC((nl-k) * sizeof(int));
- if (s->s_accel == NULL) {
- fprintf(stderr, "no mem to add parser accelerators\n");
- exit(1);
- }
- s->s_lower = k;
- s->s_upper = nl;
- for (i = 0; k < nl; i++, k++)
- s->s_accel[i] = accel[k];
- }
- PyObject_FREE(accel);
-}
diff --git a/Parser/grammar1.c b/Parser/grammar1.c
deleted file mode 100644
index c702040..0000000
--- a/Parser/grammar1.c
+++ /dev/null
@@ -1,47 +0,0 @@
-
-/* Grammar subroutines needed by parser */
-
-#include "Python.h"
-#include "grammar.h"
-#include "token.h"
-
-/* Return the DFA for the given type */
-
-const dfa *
-PyGrammar_FindDFA(grammar *g, int type)
-{
- /* Massive speed-up */
- const dfa *d = &g->g_dfa[type - NT_OFFSET];
- assert(d->d_type == type);
- return d;
-}
-
-const char *
-PyGrammar_LabelRepr(label *lb)
-{
- static char buf[100];
-
- if (lb->lb_type == ENDMARKER)
- return "EMPTY";
- else if (ISNONTERMINAL(lb->lb_type)) {
- if (lb->lb_str == NULL) {
- PyOS_snprintf(buf, sizeof(buf), "NT%d", lb->lb_type);
- return buf;
- }
- else
- return lb->lb_str;
- }
- else if (lb->lb_type < N_TOKENS) {
- if (lb->lb_str == NULL)
- return _PyParser_TokenNames[lb->lb_type];
- else {
- PyOS_snprintf(buf, sizeof(buf), "%.32s(%.32s)",
- _PyParser_TokenNames[lb->lb_type], lb->lb_str);
- return buf;
- }
- }
- else {
- Py_FatalError("invalid grammar label");
- return NULL;
- }
-}
diff --git a/Parser/listnode.c b/Parser/listnode.c
deleted file mode 100644
index 41e7a03..0000000
--- a/Parser/listnode.c
+++ /dev/null
@@ -1,71 +0,0 @@
-
-/* List a node on a file */
-
-#include "Python.h"
-#include "pycore_interp.h" // PyInterpreterState.parser
-#include "pycore_pystate.h" // _PyInterpreterState_GET()
-#include "token.h"
-#include "node.h"
-
-/* Forward */
-static void list1node(FILE *, node *);
-static void listnode(FILE *, node *);
-
-void
-PyNode_ListTree(node *n)
-{
- listnode(stdout, n);
-}
-
-static void
-listnode(FILE *fp, node *n)
-{
- PyInterpreterState *interp = _PyInterpreterState_GET();
-
- interp->parser.listnode.level = 0;
- interp->parser.listnode.atbol = 1;
- list1node(fp, n);
-}
-
-static void
-list1node(FILE *fp, node *n)
-{
- if (n == NULL)
- return;
- if (ISNONTERMINAL(TYPE(n))) {
- int i;
- for (i = 0; i < NCH(n); i++)
- list1node(fp, CHILD(n, i));
- }
- else if (ISTERMINAL(TYPE(n))) {
- PyInterpreterState *interp = _PyInterpreterState_GET();
- struct _Py_parser_state *parser = &interp->parser;
- switch (TYPE(n)) {
- case INDENT:
- parser->listnode.level++;
- break;
- case DEDENT:
- parser->listnode.level--;
- break;
- default:
- if (parser->listnode.atbol) {
- int i;
- for (i = 0; i < parser->listnode.level; ++i) {
- fprintf(fp, "\t");
- }
- parser->listnode.atbol = 0;
- }
- if (TYPE(n) == NEWLINE) {
- if (STR(n) != NULL)
- fprintf(fp, "%s", STR(n));
- fprintf(fp, "\n");
- parser->listnode.atbol = 1;
- }
- else
- fprintf(fp, "%s ", STR(n));
- break;
- }
- }
- else
- fprintf(fp, "? ");
-}
diff --git a/Parser/parser.c b/Parser/parser.c
index a61b2f5..d28e6c8 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -1,463 +1,24415 @@
+// @generated by pegen.py from ./Grammar/python.gram
+#include "pegen.h"
-/* Parser implementation */
+#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
+extern int Py_DebugFlag;
+#define D(x) if (Py_DebugFlag) x;
+#else
+#define D(x)
+#endif
+static const int n_keyword_lists = 9;
+static KeywordToken *reserved_keywords[] = {
+ NULL,
+ NULL,
+ (KeywordToken[]) {
+ {"if", 510},
+ {"in", 518},
+ {"is", 526},
+ {"as", 530},
+ {"or", 531},
+ {NULL, -1},
+ },
+ (KeywordToken[]) {
+ {"del", 503},
+ {"try", 511},
+ {"for", 517},
+ {"def", 522},
+ {"not", 525},
+ {"and", 532},
+ {NULL, -1},
+ },
+ (KeywordToken[]) {
+ {"pass", 502},
+ {"from", 514},
+ {"elif", 515},
+ {"else", 516},
+ {"with", 519},
+ {"True", 527},
+ {"None", 529},
+ {NULL, -1},
+ },
+ (KeywordToken[]) {
+ {"raise", 501},
+ {"yield", 504},
+ {"break", 506},
+ {"while", 512},
+ {"class", 523},
+ {"False", 528},
+ {NULL, -1},
+ },
+ (KeywordToken[]) {
+ {"return", 500},
+ {"assert", 505},
+ {"global", 508},
+ {"import", 513},
+ {"except", 520},
+ {"lambda", 524},
+ {NULL, -1},
+ },
+ (KeywordToken[]) {
+ {"finally", 521},
+ {NULL, -1},
+ },
+ (KeywordToken[]) {
+ {"continue", 507},
+ {"nonlocal", 509},
+ {NULL, -1},
+ },
+};
+#define file_type 1000
+#define interactive_type 1001
+#define eval_type 1002
+#define func_type_type 1003
+#define fstring_type 1004
+#define type_expressions_type 1005
+#define statements_type 1006
+#define statement_type 1007
+#define statement_newline_type 1008
+#define simple_stmt_type 1009
+#define small_stmt_type 1010
+#define compound_stmt_type 1011
+#define assignment_type 1012
+#define augassign_type 1013
+#define global_stmt_type 1014
+#define nonlocal_stmt_type 1015
+#define yield_stmt_type 1016
+#define assert_stmt_type 1017
+#define del_stmt_type 1018
+#define import_stmt_type 1019
+#define import_name_type 1020
+#define import_from_type 1021
+#define import_from_targets_type 1022
+#define import_from_as_names_type 1023
+#define import_from_as_name_type 1024
+#define dotted_as_names_type 1025
+#define dotted_as_name_type 1026
+#define dotted_name_type 1027 // Left-recursive
+#define if_stmt_type 1028
+#define elif_stmt_type 1029
+#define else_block_type 1030
+#define while_stmt_type 1031
+#define for_stmt_type 1032
+#define with_stmt_type 1033
+#define with_item_type 1034
+#define try_stmt_type 1035
+#define except_block_type 1036
+#define finally_block_type 1037
+#define return_stmt_type 1038
+#define raise_stmt_type 1039
+#define function_def_type 1040
+#define function_def_raw_type 1041
+#define func_type_comment_type 1042
+#define params_type 1043
+#define parameters_type 1044
+#define slash_no_default_type 1045
+#define slash_with_default_type 1046
+#define star_etc_type 1047
+#define kwds_type 1048
+#define param_no_default_type 1049
+#define param_with_default_type 1050
+#define param_maybe_default_type 1051
+#define param_type 1052
+#define annotation_type 1053
+#define default_type 1054
+#define decorators_type 1055
+#define class_def_type 1056
+#define class_def_raw_type 1057
+#define block_type 1058
+#define expressions_list_type 1059
+#define star_expressions_type 1060
+#define star_expression_type 1061
+#define star_named_expressions_type 1062
+#define star_named_expression_type 1063
+#define named_expression_type 1064
+#define annotated_rhs_type 1065
+#define expressions_type 1066
+#define expression_type 1067
+#define lambdef_type 1068
+#define lambda_params_type 1069
+#define lambda_parameters_type 1070
+#define lambda_slash_no_default_type 1071
+#define lambda_slash_with_default_type 1072
+#define lambda_star_etc_type 1073
+#define lambda_kwds_type 1074
+#define lambda_param_no_default_type 1075
+#define lambda_param_with_default_type 1076
+#define lambda_param_maybe_default_type 1077
+#define lambda_param_type 1078
+#define disjunction_type 1079
+#define conjunction_type 1080
+#define inversion_type 1081
+#define comparison_type 1082
+#define compare_op_bitwise_or_pair_type 1083
+#define eq_bitwise_or_type 1084
+#define noteq_bitwise_or_type 1085
+#define lte_bitwise_or_type 1086
+#define lt_bitwise_or_type 1087
+#define gte_bitwise_or_type 1088
+#define gt_bitwise_or_type 1089
+#define notin_bitwise_or_type 1090
+#define in_bitwise_or_type 1091
+#define isnot_bitwise_or_type 1092
+#define is_bitwise_or_type 1093
+#define bitwise_or_type 1094 // Left-recursive
+#define bitwise_xor_type 1095 // Left-recursive
+#define bitwise_and_type 1096 // Left-recursive
+#define shift_expr_type 1097 // Left-recursive
+#define sum_type 1098 // Left-recursive
+#define term_type 1099 // Left-recursive
+#define factor_type 1100
+#define power_type 1101
+#define await_primary_type 1102
+#define primary_type 1103 // Left-recursive
+#define slices_type 1104
+#define slice_type 1105
+#define atom_type 1106
+#define strings_type 1107
+#define list_type 1108
+#define listcomp_type 1109
+#define tuple_type 1110
+#define group_type 1111
+#define genexp_type 1112
+#define set_type 1113
+#define setcomp_type 1114
+#define dict_type 1115
+#define dictcomp_type 1116
+#define double_starred_kvpairs_type 1117
+#define double_starred_kvpair_type 1118
+#define kvpair_type 1119
+#define for_if_clauses_type 1120
+#define for_if_clause_type 1121
+#define yield_expr_type 1122
+#define arguments_type 1123
+#define args_type 1124
+#define kwargs_type 1125
+#define starred_expression_type 1126
+#define kwarg_or_starred_type 1127
+#define kwarg_or_double_starred_type 1128
+#define star_targets_type 1129
+#define star_targets_seq_type 1130
+#define star_target_type 1131
+#define star_atom_type 1132
+#define single_target_type 1133
+#define single_subscript_attribute_target_type 1134
+#define del_targets_type 1135
+#define del_target_type 1136
+#define del_t_atom_type 1137
+#define del_target_end_type 1138
+#define targets_type 1139
+#define target_type 1140
+#define t_primary_type 1141 // Left-recursive
+#define t_lookahead_type 1142
+#define t_atom_type 1143
+#define incorrect_arguments_type 1144
+#define invalid_kwarg_type 1145
+#define invalid_named_expression_type 1146
+#define invalid_assignment_type 1147
+#define invalid_block_type 1148
+#define invalid_comprehension_type 1149
+#define invalid_dict_comprehension_type 1150
+#define invalid_parameters_type 1151
+#define invalid_lambda_parameters_type 1152
+#define invalid_star_etc_type 1153
+#define invalid_lambda_star_etc_type 1154
+#define invalid_double_type_comments_type 1155
+#define invalid_del_target_type 1156
+#define invalid_import_from_targets_type 1157
+#define _loop0_1_type 1158
+#define _loop0_2_type 1159
+#define _loop0_4_type 1160
+#define _gather_3_type 1161
+#define _loop0_6_type 1162
+#define _gather_5_type 1163
+#define _loop0_8_type 1164
+#define _gather_7_type 1165
+#define _loop0_10_type 1166
+#define _gather_9_type 1167
+#define _loop1_11_type 1168
+#define _loop0_13_type 1169
+#define _gather_12_type 1170
+#define _tmp_14_type 1171
+#define _tmp_15_type 1172
+#define _tmp_16_type 1173
+#define _tmp_17_type 1174
+#define _tmp_18_type 1175
+#define _tmp_19_type 1176
+#define _tmp_20_type 1177
+#define _tmp_21_type 1178
+#define _loop1_22_type 1179
+#define _tmp_23_type 1180
+#define _tmp_24_type 1181
+#define _loop0_26_type 1182
+#define _gather_25_type 1183
+#define _loop0_28_type 1184
+#define _gather_27_type 1185
+#define _tmp_29_type 1186
+#define _loop0_30_type 1187
+#define _loop1_31_type 1188
+#define _loop0_33_type 1189
+#define _gather_32_type 1190
+#define _tmp_34_type 1191
+#define _loop0_36_type 1192
+#define _gather_35_type 1193
+#define _tmp_37_type 1194
+#define _loop0_39_type 1195
+#define _gather_38_type 1196
+#define _loop0_41_type 1197
+#define _gather_40_type 1198
+#define _loop0_43_type 1199
+#define _gather_42_type 1200
+#define _loop0_45_type 1201
+#define _gather_44_type 1202
+#define _tmp_46_type 1203
+#define _loop1_47_type 1204
+#define _tmp_48_type 1205
+#define _tmp_49_type 1206
+#define _tmp_50_type 1207
+#define _tmp_51_type 1208
+#define _tmp_52_type 1209
+#define _loop0_53_type 1210
+#define _loop0_54_type 1211
+#define _loop0_55_type 1212
+#define _loop1_56_type 1213
+#define _loop0_57_type 1214
+#define _loop1_58_type 1215
+#define _loop1_59_type 1216
+#define _loop1_60_type 1217
+#define _loop0_61_type 1218
+#define _loop1_62_type 1219
+#define _loop0_63_type 1220
+#define _loop1_64_type 1221
+#define _loop0_65_type 1222
+#define _loop1_66_type 1223
+#define _loop1_67_type 1224
+#define _tmp_68_type 1225
+#define _loop0_70_type 1226
+#define _gather_69_type 1227
+#define _loop1_71_type 1228
+#define _loop0_73_type 1229
+#define _gather_72_type 1230
+#define _loop1_74_type 1231
+#define _loop0_75_type 1232
+#define _loop0_76_type 1233
+#define _loop0_77_type 1234
+#define _loop1_78_type 1235
+#define _loop0_79_type 1236
+#define _loop1_80_type 1237
+#define _loop1_81_type 1238
+#define _loop1_82_type 1239
+#define _loop0_83_type 1240
+#define _loop1_84_type 1241
+#define _loop0_85_type 1242
+#define _loop1_86_type 1243
+#define _loop0_87_type 1244
+#define _loop1_88_type 1245
+#define _loop1_89_type 1246
+#define _loop1_90_type 1247
+#define _loop1_91_type 1248
+#define _tmp_92_type 1249
+#define _loop0_94_type 1250
+#define _gather_93_type 1251
+#define _tmp_95_type 1252
+#define _tmp_96_type 1253
+#define _tmp_97_type 1254
+#define _tmp_98_type 1255
+#define _loop1_99_type 1256
+#define _tmp_100_type 1257
+#define _tmp_101_type 1258
+#define _loop0_103_type 1259
+#define _gather_102_type 1260
+#define _loop1_104_type 1261
+#define _loop0_105_type 1262
+#define _loop0_106_type 1263
+#define _tmp_107_type 1264
+#define _tmp_108_type 1265
+#define _loop0_110_type 1266
+#define _gather_109_type 1267
+#define _loop0_112_type 1268
+#define _gather_111_type 1269
+#define _loop0_114_type 1270
+#define _gather_113_type 1271
+#define _loop0_116_type 1272
+#define _gather_115_type 1273
+#define _loop0_117_type 1274
+#define _loop0_119_type 1275
+#define _gather_118_type 1276
+#define _tmp_120_type 1277
+#define _loop0_122_type 1278
+#define _gather_121_type 1279
+#define _loop0_124_type 1280
+#define _gather_123_type 1281
+#define _tmp_125_type 1282
+#define _loop0_126_type 1283
+#define _tmp_127_type 1284
+#define _loop0_128_type 1285
+#define _loop0_129_type 1286
+#define _tmp_130_type 1287
+#define _tmp_131_type 1288
+#define _loop0_132_type 1289
+#define _tmp_133_type 1290
+#define _loop0_134_type 1291
+#define _tmp_135_type 1292
+#define _tmp_136_type 1293
+#define _tmp_137_type 1294
+#define _tmp_138_type 1295
+#define _tmp_139_type 1296
+#define _tmp_140_type 1297
+#define _tmp_141_type 1298
+#define _tmp_142_type 1299
+#define _tmp_143_type 1300
+#define _tmp_144_type 1301
+#define _tmp_145_type 1302
+#define _tmp_146_type 1303
+#define _tmp_147_type 1304
+#define _tmp_148_type 1305
+#define _tmp_149_type 1306
+#define _tmp_150_type 1307
+#define _loop1_151_type 1308
+#define _loop1_152_type 1309
+#define _tmp_153_type 1310
+#define _tmp_154_type 1311
-/* For a description, see the comments at end of this file */
+static mod_ty file_rule(Parser *p);
+static mod_ty interactive_rule(Parser *p);
+static mod_ty eval_rule(Parser *p);
+static mod_ty func_type_rule(Parser *p);
+static expr_ty fstring_rule(Parser *p);
+static asdl_seq* type_expressions_rule(Parser *p);
+static asdl_seq* statements_rule(Parser *p);
+static asdl_seq* statement_rule(Parser *p);
+static asdl_seq* statement_newline_rule(Parser *p);
+static asdl_seq* simple_stmt_rule(Parser *p);
+static stmt_ty small_stmt_rule(Parser *p);
+static stmt_ty compound_stmt_rule(Parser *p);
+static stmt_ty assignment_rule(Parser *p);
+static AugOperator* augassign_rule(Parser *p);
+static stmt_ty global_stmt_rule(Parser *p);
+static stmt_ty nonlocal_stmt_rule(Parser *p);
+static stmt_ty yield_stmt_rule(Parser *p);
+static stmt_ty assert_stmt_rule(Parser *p);
+static stmt_ty del_stmt_rule(Parser *p);
+static stmt_ty import_stmt_rule(Parser *p);
+static stmt_ty import_name_rule(Parser *p);
+static stmt_ty import_from_rule(Parser *p);
+static asdl_seq* import_from_targets_rule(Parser *p);
+static asdl_seq* import_from_as_names_rule(Parser *p);
+static alias_ty import_from_as_name_rule(Parser *p);
+static asdl_seq* dotted_as_names_rule(Parser *p);
+static alias_ty dotted_as_name_rule(Parser *p);
+static expr_ty dotted_name_rule(Parser *p);
+static stmt_ty if_stmt_rule(Parser *p);
+static stmt_ty elif_stmt_rule(Parser *p);
+static asdl_seq* else_block_rule(Parser *p);
+static stmt_ty while_stmt_rule(Parser *p);
+static stmt_ty for_stmt_rule(Parser *p);
+static stmt_ty with_stmt_rule(Parser *p);
+static withitem_ty with_item_rule(Parser *p);
+static stmt_ty try_stmt_rule(Parser *p);
+static excepthandler_ty except_block_rule(Parser *p);
+static asdl_seq* finally_block_rule(Parser *p);
+static stmt_ty return_stmt_rule(Parser *p);
+static stmt_ty raise_stmt_rule(Parser *p);
+static stmt_ty function_def_rule(Parser *p);
+static stmt_ty function_def_raw_rule(Parser *p);
+static Token* func_type_comment_rule(Parser *p);
+static arguments_ty params_rule(Parser *p);
+static arguments_ty parameters_rule(Parser *p);
+static asdl_seq* slash_no_default_rule(Parser *p);
+static SlashWithDefault* slash_with_default_rule(Parser *p);
+static StarEtc* star_etc_rule(Parser *p);
+static arg_ty kwds_rule(Parser *p);
+static arg_ty param_no_default_rule(Parser *p);
+static NameDefaultPair* param_with_default_rule(Parser *p);
+static NameDefaultPair* param_maybe_default_rule(Parser *p);
+static arg_ty param_rule(Parser *p);
+static expr_ty annotation_rule(Parser *p);
+static expr_ty default_rule(Parser *p);
+static asdl_seq* decorators_rule(Parser *p);
+static stmt_ty class_def_rule(Parser *p);
+static stmt_ty class_def_raw_rule(Parser *p);
+static asdl_seq* block_rule(Parser *p);
+static asdl_seq* expressions_list_rule(Parser *p);
+static expr_ty star_expressions_rule(Parser *p);
+static expr_ty star_expression_rule(Parser *p);
+static asdl_seq* star_named_expressions_rule(Parser *p);
+static expr_ty star_named_expression_rule(Parser *p);
+static expr_ty named_expression_rule(Parser *p);
+static expr_ty annotated_rhs_rule(Parser *p);
+static expr_ty expressions_rule(Parser *p);
+static expr_ty expression_rule(Parser *p);
+static expr_ty lambdef_rule(Parser *p);
+static arguments_ty lambda_params_rule(Parser *p);
+static arguments_ty lambda_parameters_rule(Parser *p);
+static asdl_seq* lambda_slash_no_default_rule(Parser *p);
+static SlashWithDefault* lambda_slash_with_default_rule(Parser *p);
+static StarEtc* lambda_star_etc_rule(Parser *p);
+static arg_ty lambda_kwds_rule(Parser *p);
+static arg_ty lambda_param_no_default_rule(Parser *p);
+static NameDefaultPair* lambda_param_with_default_rule(Parser *p);
+static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p);
+static arg_ty lambda_param_rule(Parser *p);
+static expr_ty disjunction_rule(Parser *p);
+static expr_ty conjunction_rule(Parser *p);
+static expr_ty inversion_rule(Parser *p);
+static expr_ty comparison_rule(Parser *p);
+static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p);
+static CmpopExprPair* eq_bitwise_or_rule(Parser *p);
+static CmpopExprPair* noteq_bitwise_or_rule(Parser *p);
+static CmpopExprPair* lte_bitwise_or_rule(Parser *p);
+static CmpopExprPair* lt_bitwise_or_rule(Parser *p);
+static CmpopExprPair* gte_bitwise_or_rule(Parser *p);
+static CmpopExprPair* gt_bitwise_or_rule(Parser *p);
+static CmpopExprPair* notin_bitwise_or_rule(Parser *p);
+static CmpopExprPair* in_bitwise_or_rule(Parser *p);
+static CmpopExprPair* isnot_bitwise_or_rule(Parser *p);
+static CmpopExprPair* is_bitwise_or_rule(Parser *p);
+static expr_ty bitwise_or_rule(Parser *p);
+static expr_ty bitwise_xor_rule(Parser *p);
+static expr_ty bitwise_and_rule(Parser *p);
+static expr_ty shift_expr_rule(Parser *p);
+static expr_ty sum_rule(Parser *p);
+static expr_ty term_rule(Parser *p);
+static expr_ty factor_rule(Parser *p);
+static expr_ty power_rule(Parser *p);
+static expr_ty await_primary_rule(Parser *p);
+static expr_ty primary_rule(Parser *p);
+static expr_ty slices_rule(Parser *p);
+static expr_ty slice_rule(Parser *p);
+static expr_ty atom_rule(Parser *p);
+static expr_ty strings_rule(Parser *p);
+static expr_ty list_rule(Parser *p);
+static expr_ty listcomp_rule(Parser *p);
+static expr_ty tuple_rule(Parser *p);
+static expr_ty group_rule(Parser *p);
+static expr_ty genexp_rule(Parser *p);
+static expr_ty set_rule(Parser *p);
+static expr_ty setcomp_rule(Parser *p);
+static expr_ty dict_rule(Parser *p);
+static expr_ty dictcomp_rule(Parser *p);
+static asdl_seq* double_starred_kvpairs_rule(Parser *p);
+static KeyValuePair* double_starred_kvpair_rule(Parser *p);
+static KeyValuePair* kvpair_rule(Parser *p);
+static asdl_seq* for_if_clauses_rule(Parser *p);
+static comprehension_ty for_if_clause_rule(Parser *p);
+static expr_ty yield_expr_rule(Parser *p);
+static expr_ty arguments_rule(Parser *p);
+static expr_ty args_rule(Parser *p);
+static asdl_seq* kwargs_rule(Parser *p);
+static expr_ty starred_expression_rule(Parser *p);
+static KeywordOrStarred* kwarg_or_starred_rule(Parser *p);
+static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p);
+static expr_ty star_targets_rule(Parser *p);
+static asdl_seq* star_targets_seq_rule(Parser *p);
+static expr_ty star_target_rule(Parser *p);
+static expr_ty star_atom_rule(Parser *p);
+static expr_ty single_target_rule(Parser *p);
+static expr_ty single_subscript_attribute_target_rule(Parser *p);
+static asdl_seq* del_targets_rule(Parser *p);
+static expr_ty del_target_rule(Parser *p);
+static expr_ty del_t_atom_rule(Parser *p);
+static void *del_target_end_rule(Parser *p);
+static asdl_seq* targets_rule(Parser *p);
+static expr_ty target_rule(Parser *p);
+static expr_ty t_primary_rule(Parser *p);
+static void *t_lookahead_rule(Parser *p);
+static expr_ty t_atom_rule(Parser *p);
+static void *incorrect_arguments_rule(Parser *p);
+static void *invalid_kwarg_rule(Parser *p);
+static void *invalid_named_expression_rule(Parser *p);
+static void *invalid_assignment_rule(Parser *p);
+static void *invalid_block_rule(Parser *p);
+static void *invalid_comprehension_rule(Parser *p);
+static void *invalid_dict_comprehension_rule(Parser *p);
+static void *invalid_parameters_rule(Parser *p);
+static void *invalid_lambda_parameters_rule(Parser *p);
+static void *invalid_star_etc_rule(Parser *p);
+static void *invalid_lambda_star_etc_rule(Parser *p);
+static void *invalid_double_type_comments_rule(Parser *p);
+static void *invalid_del_target_rule(Parser *p);
+static void *invalid_import_from_targets_rule(Parser *p);
+static asdl_seq *_loop0_1_rule(Parser *p);
+static asdl_seq *_loop0_2_rule(Parser *p);
+static asdl_seq *_loop0_4_rule(Parser *p);
+static asdl_seq *_gather_3_rule(Parser *p);
+static asdl_seq *_loop0_6_rule(Parser *p);
+static asdl_seq *_gather_5_rule(Parser *p);
+static asdl_seq *_loop0_8_rule(Parser *p);
+static asdl_seq *_gather_7_rule(Parser *p);
+static asdl_seq *_loop0_10_rule(Parser *p);
+static asdl_seq *_gather_9_rule(Parser *p);
+static asdl_seq *_loop1_11_rule(Parser *p);
+static asdl_seq *_loop0_13_rule(Parser *p);
+static asdl_seq *_gather_12_rule(Parser *p);
+static void *_tmp_14_rule(Parser *p);
+static void *_tmp_15_rule(Parser *p);
+static void *_tmp_16_rule(Parser *p);
+static void *_tmp_17_rule(Parser *p);
+static void *_tmp_18_rule(Parser *p);
+static void *_tmp_19_rule(Parser *p);
+static void *_tmp_20_rule(Parser *p);
+static void *_tmp_21_rule(Parser *p);
+static asdl_seq *_loop1_22_rule(Parser *p);
+static void *_tmp_23_rule(Parser *p);
+static void *_tmp_24_rule(Parser *p);
+static asdl_seq *_loop0_26_rule(Parser *p);
+static asdl_seq *_gather_25_rule(Parser *p);
+static asdl_seq *_loop0_28_rule(Parser *p);
+static asdl_seq *_gather_27_rule(Parser *p);
+static void *_tmp_29_rule(Parser *p);
+static asdl_seq *_loop0_30_rule(Parser *p);
+static asdl_seq *_loop1_31_rule(Parser *p);
+static asdl_seq *_loop0_33_rule(Parser *p);
+static asdl_seq *_gather_32_rule(Parser *p);
+static void *_tmp_34_rule(Parser *p);
+static asdl_seq *_loop0_36_rule(Parser *p);
+static asdl_seq *_gather_35_rule(Parser *p);
+static void *_tmp_37_rule(Parser *p);
+static asdl_seq *_loop0_39_rule(Parser *p);
+static asdl_seq *_gather_38_rule(Parser *p);
+static asdl_seq *_loop0_41_rule(Parser *p);
+static asdl_seq *_gather_40_rule(Parser *p);
+static asdl_seq *_loop0_43_rule(Parser *p);
+static asdl_seq *_gather_42_rule(Parser *p);
+static asdl_seq *_loop0_45_rule(Parser *p);
+static asdl_seq *_gather_44_rule(Parser *p);
+static void *_tmp_46_rule(Parser *p);
+static asdl_seq *_loop1_47_rule(Parser *p);
+static void *_tmp_48_rule(Parser *p);
+static void *_tmp_49_rule(Parser *p);
+static void *_tmp_50_rule(Parser *p);
+static void *_tmp_51_rule(Parser *p);
+static void *_tmp_52_rule(Parser *p);
+static asdl_seq *_loop0_53_rule(Parser *p);
+static asdl_seq *_loop0_54_rule(Parser *p);
+static asdl_seq *_loop0_55_rule(Parser *p);
+static asdl_seq *_loop1_56_rule(Parser *p);
+static asdl_seq *_loop0_57_rule(Parser *p);
+static asdl_seq *_loop1_58_rule(Parser *p);
+static asdl_seq *_loop1_59_rule(Parser *p);
+static asdl_seq *_loop1_60_rule(Parser *p);
+static asdl_seq *_loop0_61_rule(Parser *p);
+static asdl_seq *_loop1_62_rule(Parser *p);
+static asdl_seq *_loop0_63_rule(Parser *p);
+static asdl_seq *_loop1_64_rule(Parser *p);
+static asdl_seq *_loop0_65_rule(Parser *p);
+static asdl_seq *_loop1_66_rule(Parser *p);
+static asdl_seq *_loop1_67_rule(Parser *p);
+static void *_tmp_68_rule(Parser *p);
+static asdl_seq *_loop0_70_rule(Parser *p);
+static asdl_seq *_gather_69_rule(Parser *p);
+static asdl_seq *_loop1_71_rule(Parser *p);
+static asdl_seq *_loop0_73_rule(Parser *p);
+static asdl_seq *_gather_72_rule(Parser *p);
+static asdl_seq *_loop1_74_rule(Parser *p);
+static asdl_seq *_loop0_75_rule(Parser *p);
+static asdl_seq *_loop0_76_rule(Parser *p);
+static asdl_seq *_loop0_77_rule(Parser *p);
+static asdl_seq *_loop1_78_rule(Parser *p);
+static asdl_seq *_loop0_79_rule(Parser *p);
+static asdl_seq *_loop1_80_rule(Parser *p);
+static asdl_seq *_loop1_81_rule(Parser *p);
+static asdl_seq *_loop1_82_rule(Parser *p);
+static asdl_seq *_loop0_83_rule(Parser *p);
+static asdl_seq *_loop1_84_rule(Parser *p);
+static asdl_seq *_loop0_85_rule(Parser *p);
+static asdl_seq *_loop1_86_rule(Parser *p);
+static asdl_seq *_loop0_87_rule(Parser *p);
+static asdl_seq *_loop1_88_rule(Parser *p);
+static asdl_seq *_loop1_89_rule(Parser *p);
+static asdl_seq *_loop1_90_rule(Parser *p);
+static asdl_seq *_loop1_91_rule(Parser *p);
+static void *_tmp_92_rule(Parser *p);
+static asdl_seq *_loop0_94_rule(Parser *p);
+static asdl_seq *_gather_93_rule(Parser *p);
+static void *_tmp_95_rule(Parser *p);
+static void *_tmp_96_rule(Parser *p);
+static void *_tmp_97_rule(Parser *p);
+static void *_tmp_98_rule(Parser *p);
+static asdl_seq *_loop1_99_rule(Parser *p);
+static void *_tmp_100_rule(Parser *p);
+static void *_tmp_101_rule(Parser *p);
+static asdl_seq *_loop0_103_rule(Parser *p);
+static asdl_seq *_gather_102_rule(Parser *p);
+static asdl_seq *_loop1_104_rule(Parser *p);
+static asdl_seq *_loop0_105_rule(Parser *p);
+static asdl_seq *_loop0_106_rule(Parser *p);
+static void *_tmp_107_rule(Parser *p);
+static void *_tmp_108_rule(Parser *p);
+static asdl_seq *_loop0_110_rule(Parser *p);
+static asdl_seq *_gather_109_rule(Parser *p);
+static asdl_seq *_loop0_112_rule(Parser *p);
+static asdl_seq *_gather_111_rule(Parser *p);
+static asdl_seq *_loop0_114_rule(Parser *p);
+static asdl_seq *_gather_113_rule(Parser *p);
+static asdl_seq *_loop0_116_rule(Parser *p);
+static asdl_seq *_gather_115_rule(Parser *p);
+static asdl_seq *_loop0_117_rule(Parser *p);
+static asdl_seq *_loop0_119_rule(Parser *p);
+static asdl_seq *_gather_118_rule(Parser *p);
+static void *_tmp_120_rule(Parser *p);
+static asdl_seq *_loop0_122_rule(Parser *p);
+static asdl_seq *_gather_121_rule(Parser *p);
+static asdl_seq *_loop0_124_rule(Parser *p);
+static asdl_seq *_gather_123_rule(Parser *p);
+static void *_tmp_125_rule(Parser *p);
+static asdl_seq *_loop0_126_rule(Parser *p);
+static void *_tmp_127_rule(Parser *p);
+static asdl_seq *_loop0_128_rule(Parser *p);
+static asdl_seq *_loop0_129_rule(Parser *p);
+static void *_tmp_130_rule(Parser *p);
+static void *_tmp_131_rule(Parser *p);
+static asdl_seq *_loop0_132_rule(Parser *p);
+static void *_tmp_133_rule(Parser *p);
+static asdl_seq *_loop0_134_rule(Parser *p);
+static void *_tmp_135_rule(Parser *p);
+static void *_tmp_136_rule(Parser *p);
+static void *_tmp_137_rule(Parser *p);
+static void *_tmp_138_rule(Parser *p);
+static void *_tmp_139_rule(Parser *p);
+static void *_tmp_140_rule(Parser *p);
+static void *_tmp_141_rule(Parser *p);
+static void *_tmp_142_rule(Parser *p);
+static void *_tmp_143_rule(Parser *p);
+static void *_tmp_144_rule(Parser *p);
+static void *_tmp_145_rule(Parser *p);
+static void *_tmp_146_rule(Parser *p);
+static void *_tmp_147_rule(Parser *p);
+static void *_tmp_148_rule(Parser *p);
+static void *_tmp_149_rule(Parser *p);
+static void *_tmp_150_rule(Parser *p);
+static asdl_seq *_loop1_151_rule(Parser *p);
+static asdl_seq *_loop1_152_rule(Parser *p);
+static void *_tmp_153_rule(Parser *p);
+static void *_tmp_154_rule(Parser *p);
-/* XXX To do: error recovery */
-#include "Python.h"
-#include "token.h"
-#include "grammar.h"
-#include "node.h"
-#include "parser.h"
-#include "errcode.h"
-#include "graminit.h"
+// file: statements? $
+static mod_ty
+file_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ mod_ty _res = NULL;
+ int _mark = p->mark;
+ { // statements? $
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> file[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statements? $"));
+ void *a;
+ Token * endmarker_var;
+ if (
+ (a = statements_rule(p), 1) // statements?
+ &&
+ (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
+ )
+ {
+ D(fprintf(stderr, "%*c+ file[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statements? $"));
+ _res = _PyPegen_make_module ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s file[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statements? $"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+// interactive: statement_newline
+static mod_ty
+interactive_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ mod_ty _res = NULL;
+ int _mark = p->mark;
+ { // statement_newline
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> interactive[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement_newline"));
+ asdl_seq* a;
+ if (
+ (a = statement_newline_rule(p)) // statement_newline
+ )
+ {
+ D(fprintf(stderr, "%*c+ interactive[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement_newline"));
+ _res = Interactive ( a , p -> arena );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s interactive[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement_newline"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-#ifdef Py_DEBUG
-extern int Py_DebugFlag;
-#define D(x) if (!Py_DebugFlag); else x
-#else
-#define D(x)
-#endif
+// eval: expressions NEWLINE* $
+static mod_ty
+eval_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ mod_ty _res = NULL;
+ int _mark = p->mark;
+ { // expressions NEWLINE* $
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> eval[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $"));
+ asdl_seq * _loop0_1_var;
+ expr_ty a;
+ Token * endmarker_var;
+ if (
+ (a = expressions_rule(p)) // expressions
+ &&
+ (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE*
+ &&
+ (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
+ )
+ {
+ D(fprintf(stderr, "%*c+ eval[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $"));
+ _res = Expression ( a , p -> arena );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s eval[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions NEWLINE* $"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+// func_type: '(' type_expressions? ')' '->' expression NEWLINE* $
+static mod_ty
+func_type_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ mod_ty _res = NULL;
+ int _mark = p->mark;
+ { // '(' type_expressions? ')' '->' expression NEWLINE* $
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> func_type[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $"));
+ Token * _literal;
+ Token * _literal_1;
+ Token * _literal_2;
+ asdl_seq * _loop0_2_var;
+ void *a;
+ expr_ty b;
+ Token * endmarker_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = type_expressions_rule(p), 1) // type_expressions?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ &&
+ (_literal_2 = _PyPegen_expect_token(p, 51)) // token='->'
+ &&
+ (b = expression_rule(p)) // expression
+ &&
+ (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE*
+ &&
+ (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
+ )
+ {
+ D(fprintf(stderr, "%*c+ func_type[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $"));
+ _res = FunctionType ( a , b , p -> arena );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s func_type[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-/* STACK DATA TYPE */
+// fstring: star_expressions
+static expr_ty
+fstring_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ { // star_expressions
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> fstring[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ expr_ty star_expressions_var;
+ if (
+ (star_expressions_var = star_expressions_rule(p)) // star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ fstring[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ _res = star_expressions_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s fstring[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-static void s_reset(stack *);
+// type_expressions:
+// | ','.expression+ ',' '*' expression ',' '**' expression
+// | ','.expression+ ',' '*' expression
+// | ','.expression+ ',' '**' expression
+// | '*' expression ',' '**' expression
+// | '*' expression
+// | '**' expression
+// | ','.expression+
+static asdl_seq*
+type_expressions_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.expression+ ',' '*' expression ',' '**' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression"));
+ Token * _literal;
+ Token * _literal_1;
+ Token * _literal_2;
+ Token * _literal_3;
+ asdl_seq * a;
+ expr_ty b;
+ expr_ty c;
+ if (
+ (a = _gather_3_rule(p)) // ','.expression+
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (b = expression_rule(p)) // expression
+ &&
+ (_literal_2 = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (c = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression"));
+ _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression"));
+ }
+ { // ','.expression+ ',' '*' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * a;
+ expr_ty b;
+ if (
+ (a = _gather_5_rule(p)) // ','.expression+
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression"));
+ _res = _PyPegen_seq_append_to_end ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression"));
+ }
+ { // ','.expression+ ',' '**' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * a;
+ expr_ty b;
+ if (
+ (a = _gather_7_rule(p)) // ','.expression+
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression"));
+ _res = _PyPegen_seq_append_to_end ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '**' expression"));
+ }
+ { // '*' expression ',' '**' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression"));
+ Token * _literal;
+ Token * _literal_1;
+ Token * _literal_2;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = expression_rule(p)) // expression
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression"));
+ _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression ',' '**' expression"));
+ }
+ { // '*' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression"));
+ _res = _PyPegen_singleton_seq ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression"));
+ }
+ { // '**' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression"));
+ _res = _PyPegen_singleton_seq ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression"));
+ }
+ { // ','.expression+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+"));
+ asdl_seq * _gather_9_var;
+ if (
+ (_gather_9_var = _gather_9_rule(p)) // ','.expression+
+ )
+ {
+ D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+"));
+ _res = _gather_9_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-static void
-s_reset(stack *s)
+// statements: statement+
+static asdl_seq*
+statements_rule(Parser *p)
{
- s->s_top = &s->s_base[MAXSTACK];
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // statement+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> statements[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement+"));
+ asdl_seq * a;
+ if (
+ (a = _loop1_11_rule(p)) // statement+
+ )
+ {
+ D(fprintf(stderr, "%*c+ statements[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement+"));
+ _res = _PyPegen_seq_flatten ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s statements[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
-#define s_empty(s) ((s)->s_top == &(s)->s_base[MAXSTACK])
+// statement: compound_stmt | simple_stmt
+static asdl_seq*
+statement_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // compound_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt"));
+ stmt_ty a;
+ if (
+ (a = compound_stmt_rule(p)) // compound_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt"));
+ _res = _PyPegen_singleton_seq ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt"));
+ }
+ { // simple_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ asdl_seq* simple_stmt_var;
+ if (
+ (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ _res = simple_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-static int
-s_push(stack *s, const dfa *d, node *parent)
+// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
+static asdl_seq*
+statement_newline_rule(Parser *p)
{
- stackentry *top;
- if (s->s_top == s->s_base) {
- fprintf(stderr, "s_push: parser stack overflow\n");
- return E_NOMEM;
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
}
- top = --s->s_top;
- top->s_dfa = d;
- top->s_parent = parent;
- top->s_state = 0;
- return 0;
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // compound_stmt NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE"));
+ stmt_ty a;
+ Token * newline_var;
+ if (
+ (a = compound_stmt_rule(p)) // compound_stmt
+ &&
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE"));
+ _res = _PyPegen_singleton_seq ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE"));
+ }
+ { // simple_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ asdl_seq* simple_stmt_var;
+ if (
+ (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ _res = simple_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ }
+ { // NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
+ Token * newline_var;
+ if (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
+ }
+ { // $
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "$"));
+ Token * endmarker_var;
+ if (
+ (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
+ )
+ {
+ D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "$"));
+ _res = _PyPegen_interactive_exit ( p );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "$"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
-#ifdef Py_DEBUG
+// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
+static asdl_seq*
+simple_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // small_stmt !';' NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
+ stmt_ty a;
+ Token * newline_var;
+ if (
+ (a = small_stmt_rule(p)) // small_stmt
+ &&
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
+ &&
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
+ _res = _PyPegen_singleton_seq ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt !';' NEWLINE"));
+ }
+ { // ';'.small_stmt+ ';'? NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ Token * newline_var;
+ if (
+ (a = _gather_12_rule(p)) // ';'.small_stmt+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
+ &&
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-static void
-s_pop(stack *s)
+// small_stmt:
+// | assignment
+// | star_expressions
+// | &'return' return_stmt
+// | &('import' | 'from') import_stmt
+// | &'raise' raise_stmt
+// | 'pass'
+// | &'del' del_stmt
+// | &'yield' yield_stmt
+// | &'assert' assert_stmt
+// | 'break'
+// | 'continue'
+// | &'global' global_stmt
+// | &'nonlocal' nonlocal_stmt
+static stmt_ty
+small_stmt_rule(Parser *p)
{
- if (s_empty(s)) {
- Py_FatalError("parser stack underflow");
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
}
- s->s_top++;
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // assignment
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
+ stmt_ty assignment_var;
+ if (
+ (assignment_var = assignment_rule(p)) // assignment
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
+ _res = assignment_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment"));
+ }
+ { // star_expressions
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ expr_ty e;
+ if (
+ (e = star_expressions_rule(p)) // star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Expr ( e , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
+ }
+ { // &'return' return_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
+ stmt_ty return_stmt_var;
+ if (
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
+ &&
+ (return_stmt_var = return_stmt_rule(p)) // return_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
+ _res = return_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt"));
+ }
+ { // &('import' | 'from') import_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
+ stmt_ty import_stmt_var;
+ if (
+ _PyPegen_lookahead(1, _tmp_14_rule, p)
+ &&
+ (import_stmt_var = import_stmt_rule(p)) // import_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
+ _res = import_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt"));
+ }
+ { // &'raise' raise_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_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, 501) // token='raise'
+ &&
+ (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
+ _res = raise_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt"));
+ }
+ { // 'pass'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 502)) // token='pass'
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Pass ( EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'"));
+ }
+ { // &'del' del_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_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, 503) // token='del'
+ &&
+ (del_stmt_var = del_stmt_rule(p)) // del_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
+ _res = del_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt"));
+ }
+ { // &'yield' yield_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
+ stmt_ty yield_stmt_var;
+ if (
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
+ &&
+ (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
+ _res = yield_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt"));
+ }
+ { // &'assert' assert_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_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, 505) // token='assert'
+ &&
+ (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
+ _res = assert_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt"));
+ }
+ { // 'break'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 506)) // token='break'
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Break ( EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'"));
+ }
+ { // 'continue'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 507)) // token='continue'
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Continue ( EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'"));
+ }
+ { // &'global' global_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
+ stmt_ty global_stmt_var;
+ if (
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
+ &&
+ (global_stmt_var = global_stmt_rule(p)) // global_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
+ _res = global_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt"));
+ }
+ { // &'nonlocal' nonlocal_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
+ stmt_ty nonlocal_stmt_var;
+ if (
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
+ &&
+ (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
+ _res = nonlocal_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, small_stmt_type, _res);
+ D(p->level--);
+ return _res;
}
-#else /* !Py_DEBUG */
+// compound_stmt:
+// | &('def' | '@' | ASYNC) function_def
+// | &'if' if_stmt
+// | &('class' | '@') class_def
+// | &('with' | ASYNC) with_stmt
+// | &('for' | ASYNC) for_stmt
+// | &'try' try_stmt
+// | &'while' while_stmt
+static stmt_ty
+compound_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ { // &('def' | '@' | ASYNC) function_def
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def"));
+ stmt_ty function_def_var;
+ if (
+ _PyPegen_lookahead(1, _tmp_15_rule, p)
+ &&
+ (function_def_var = function_def_rule(p)) // function_def
+ )
+ {
+ D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def"));
+ _res = function_def_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('def' | '@' | ASYNC) function_def"));
+ }
+ { // &'if' if_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ 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, 510) // token='if'
+ &&
+ (if_stmt_var = if_stmt_rule(p)) // if_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt"));
+ _res = if_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'if' if_stmt"));
+ }
+ { // &('class' | '@') class_def
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def"));
+ stmt_ty class_def_var;
+ if (
+ _PyPegen_lookahead(1, _tmp_16_rule, p)
+ &&
+ (class_def_var = class_def_rule(p)) // class_def
+ )
+ {
+ D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def"));
+ _res = class_def_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('class' | '@') class_def"));
+ }
+ { // &('with' | ASYNC) with_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt"));
+ stmt_ty with_stmt_var;
+ if (
+ _PyPegen_lookahead(1, _tmp_17_rule, p)
+ &&
+ (with_stmt_var = with_stmt_rule(p)) // with_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt"));
+ _res = with_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('with' | ASYNC) with_stmt"));
+ }
+ { // &('for' | ASYNC) for_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt"));
+ stmt_ty for_stmt_var;
+ if (
+ _PyPegen_lookahead(1, _tmp_18_rule, p)
+ &&
+ (for_stmt_var = for_stmt_rule(p)) // for_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt"));
+ _res = for_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('for' | ASYNC) for_stmt"));
+ }
+ { // &'try' try_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ 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, 511) // token='try'
+ &&
+ (try_stmt_var = try_stmt_rule(p)) // try_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt"));
+ _res = try_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'try' try_stmt"));
+ }
+ { // &'while' while_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ 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, 512) // token='while'
+ &&
+ (while_stmt_var = while_stmt_rule(p)) // while_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt"));
+ _res = while_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'while' while_stmt"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-#define s_pop(s) (s)->s_top++
+// assignment:
+// | NAME ':' expression ['=' annotated_rhs]
+// | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]
+// | ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?
+// | single_target augassign (yield_expr | star_expressions)
+// | invalid_assignment
+static stmt_ty
+assignment_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME ':' expression ['=' annotated_rhs]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ void *c;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = expression_rule(p)) // expression
+ &&
+ (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs]
+ )
+ {
+ D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]"));
+ }
+ { // ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]"));
+ Token * _literal;
+ void *a;
+ expr_ty b;
+ void *c;
+ if (
+ (a = _tmp_20_rule(p)) // '(' single_target ')' | single_subscript_attribute_target
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = expression_rule(p)) // expression
+ &&
+ (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs]
+ )
+ {
+ D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]"));
+ }
+ { // ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?"));
+ asdl_seq * a;
+ void *b;
+ void *tc;
+ if (
+ (a = _loop1_22_rule(p)) // ((star_targets '='))+
+ &&
+ (b = _tmp_23_rule(p)) // yield_expr | star_expressions
+ &&
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='='
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ )
+ {
+ D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?"));
+ }
+ { // single_target augassign (yield_expr | star_expressions)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_target augassign (yield_expr | star_expressions)"));
+ expr_ty a;
+ AugOperator* b;
+ void *c;
+ if (
+ (a = single_target_rule(p)) // single_target
+ &&
+ (b = augassign_rule(p)) // augassign
+ &&
+ (c = _tmp_24_rule(p)) // yield_expr | star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_target augassign (yield_expr | star_expressions)"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_AugAssign ( a , b -> kind , c , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_target augassign (yield_expr | star_expressions)"));
+ }
+ { // invalid_assignment
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_assignment"));
+ void *invalid_assignment_var;
+ if (
+ (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment
+ )
+ {
+ D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_assignment"));
+ _res = invalid_assignment_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_assignment"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-#endif
+// augassign:
+// | '+='
+// | '-='
+// | '*='
+// | '@='
+// | '/='
+// | '%='
+// | '&='
+// | '|='
+// | '^='
+// | '<<='
+// | '>>='
+// | '**='
+// | '//='
+static AugOperator*
+augassign_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ AugOperator* _res = NULL;
+ int _mark = p->mark;
+ { // '+='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 36)) // token='+='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+='"));
+ _res = _PyPegen_augoperator ( p , Add );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+='"));
+ }
+ { // '-='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 37)) // token='-='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-='"));
+ _res = _PyPegen_augoperator ( p , Sub );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-='"));
+ }
+ { // '*='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 38)) // token='*='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*='"));
+ _res = _PyPegen_augoperator ( p , Mult );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*='"));
+ }
+ { // '@='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 50)) // token='@='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@='"));
+ _res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@='"));
+ }
+ { // '/='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 39)) // token='/='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/='"));
+ _res = _PyPegen_augoperator ( p , Div );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/='"));
+ }
+ { // '%='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'%='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 40)) // token='%='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'%='"));
+ _res = _PyPegen_augoperator ( p , Mod );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'%='"));
+ }
+ { // '&='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'&='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 41)) // token='&='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'&='"));
+ _res = _PyPegen_augoperator ( p , BitAnd );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'&='"));
+ }
+ { // '|='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 42)) // token='|='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|='"));
+ _res = _PyPegen_augoperator ( p , BitOr );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|='"));
+ }
+ { // '^='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'^='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 43)) // token='^='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'^='"));
+ _res = _PyPegen_augoperator ( p , BitXor );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'^='"));
+ }
+ { // '<<='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<<='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 44)) // token='<<='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<<='"));
+ _res = _PyPegen_augoperator ( p , LShift );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<<='"));
+ }
+ { // '>>='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>>='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 45)) // token='>>='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>>='"));
+ _res = _PyPegen_augoperator ( p , RShift );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>>='"));
+ }
+ { // '**='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 46)) // token='**='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**='"));
+ _res = _PyPegen_augoperator ( p , Pow );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**='"));
+ }
+ { // '//='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'//='"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 48)) // token='//='
+ )
+ {
+ D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'//='"));
+ _res = _PyPegen_augoperator ( p , FloorDiv );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'//='"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+// global_stmt: 'global' ','.NAME+
+static stmt_ty
+global_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'global' ','.NAME+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> global_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+"));
+ Token * _keyword;
+ asdl_seq * a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 508)) // token='global'
+ &&
+ (a = _gather_25_rule(p)) // ','.NAME+
+ )
+ {
+ D(fprintf(stderr, "%*c+ global_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s global_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'global' ','.NAME+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-/* PARSER CREATION */
+// nonlocal_stmt: 'nonlocal' ','.NAME+
+static stmt_ty
+nonlocal_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'nonlocal' ','.NAME+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> nonlocal_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+"));
+ Token * _keyword;
+ asdl_seq * a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal'
+ &&
+ (a = _gather_27_rule(p)) // ','.NAME+
+ )
+ {
+ D(fprintf(stderr, "%*c+ nonlocal_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s nonlocal_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'nonlocal' ','.NAME+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-parser_state *
-PyParser_New(grammar *g, int start)
+// yield_stmt: yield_expr
+static stmt_ty
+yield_stmt_rule(Parser *p)
{
- parser_state *ps;
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // yield_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> yield_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ expr_ty y;
+ if (
+ (y = yield_expr_rule(p)) // yield_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ yield_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Expr ( y , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s yield_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- if (!g->g_accel)
- PyGrammar_AddAccelerators(g);
- ps = (parser_state *)PyMem_MALLOC(sizeof(parser_state));
- if (ps == NULL)
+// assert_stmt: 'assert' expression [',' expression]
+static stmt_ty
+assert_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
return NULL;
- ps->p_grammar = g;
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
- ps->p_flags = 0;
-#endif
- ps->p_tree = PyNode_New(start);
- if (ps->p_tree == NULL) {
- PyMem_FREE(ps);
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
return NULL;
}
- s_reset(&ps->p_stack);
- (void) s_push(&ps->p_stack, PyGrammar_FindDFA(g, start), ps->p_tree);
- return ps;
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'assert' expression [',' expression]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]"));
+ Token * _keyword;
+ expr_ty a;
+ void *b;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 505)) // token='assert'
+ &&
+ (a = expression_rule(p)) // expression
+ &&
+ (b = _tmp_29_rule(p), 1) // [',' expression]
+ )
+ {
+ D(fprintf(stderr, "%*c+ assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Assert ( a , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s assert_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression [',' expression]"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
-void
-PyParser_Delete(parser_state *ps)
+// del_stmt: 'del' del_targets
+static stmt_ty
+del_stmt_rule(Parser *p)
{
- /* NB If you want to save the parse tree,
- you must set p_tree to NULL before calling delparser! */
- PyNode_Free(ps->p_tree);
- PyMem_FREE(ps);
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'del' del_targets
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'del' del_targets"));
+ Token * _keyword;
+ asdl_seq* a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 503)) // token='del'
+ &&
+ (a = del_targets_rule(p)) // del_targets
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'del' del_targets"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Delete ( a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'del' del_targets"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// import_stmt: import_name | import_from
+static stmt_ty
+import_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ { // import_name
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_name"));
+ stmt_ty import_name_var;
+ if (
+ (import_name_var = import_name_rule(p)) // import_name
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_name"));
+ _res = import_name_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_name"));
+ }
+ { // import_from
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from"));
+ stmt_ty import_from_var;
+ if (
+ (import_from_var = import_from_rule(p)) // import_from
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from"));
+ _res = import_from_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// import_name: 'import' dotted_as_names
+static stmt_ty
+import_name_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'import' dotted_as_names
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names"));
+ Token * _keyword;
+ asdl_seq* a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 513)) // token='import'
+ &&
+ (a = dotted_as_names_rule(p)) // dotted_as_names
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Import ( a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_name[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' dotted_as_names"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// import_from:
+// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
+// | 'from' (('.' | '...'))+ 'import' import_from_targets
+static stmt_ty
+import_from_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets"));
+ Token * _keyword;
+ Token * _keyword_1;
+ asdl_seq * a;
+ expr_ty b;
+ asdl_seq* c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
+ &&
+ (a = _loop0_30_rule(p)) // (('.' | '...'))*
+ &&
+ (b = dotted_name_rule(p)) // dotted_name
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
+ &&
+ (c = import_from_targets_rule(p)) // import_from_targets
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets"));
+ }
+ { // 'from' (('.' | '...'))+ 'import' import_from_targets
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets"));
+ Token * _keyword;
+ Token * _keyword_1;
+ asdl_seq * a;
+ asdl_seq* b;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
+ &&
+ (a = _loop1_31_rule(p)) // (('.' | '...'))+
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
+ &&
+ (b = import_from_targets_rule(p)) // import_from_targets
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
+// import_from_targets:
+// | '(' import_from_as_names ','? ')'
+// | import_from_as_names !','
+// | '*'
+// | invalid_import_from_targets
+static asdl_seq*
+import_from_targets_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // '(' import_from_as_names ','? ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq* a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = import_from_as_names_rule(p)) // import_from_as_names
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' import_from_as_names ','? ')'"));
+ }
+ { // import_from_as_names !','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','"));
+ asdl_seq* import_from_as_names_var;
+ if (
+ (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names
+ &&
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','"));
+ _res = import_from_as_names_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names !','"));
+ }
+ { // '*'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'"));
+ _res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'"));
+ }
+ { // invalid_import_from_targets
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets"));
+ void *invalid_import_from_targets_var;
+ if (
+ (invalid_import_from_targets_var = invalid_import_from_targets_rule(p)) // invalid_import_from_targets
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets"));
+ _res = invalid_import_from_targets_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_import_from_targets"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-/* PARSER STACK OPERATIONS */
+// import_from_as_names: ','.import_from_as_name+
+static asdl_seq*
+import_from_as_names_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.import_from_as_name+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+"));
+ asdl_seq * a;
+ if (
+ (a = _gather_32_rule(p)) // ','.import_from_as_name+
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from_as_names[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.import_from_as_name+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-static int
-shift(stack *s, int type, char *str, int newstate, int lineno, int col_offset,
- int end_lineno, int end_col_offset)
+// import_from_as_name: NAME ['as' NAME]
+static alias_ty
+import_from_as_name_rule(Parser *p)
{
- int err;
- assert(!s_empty(s));
- err = PyNode_AddChild(s->s_top->s_parent, type, str, lineno, col_offset,
- end_lineno, end_col_offset);
- if (err)
- return err;
- s->s_top->s_state = newstate;
- return 0;
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ alias_ty _res = NULL;
+ int _mark = p->mark;
+ { // NAME ['as' NAME]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> import_from_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]"));
+ expr_ty a;
+ void *b;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ (b = _tmp_34_rule(p), 1) // ['as' NAME]
+ )
+ {
+ D(fprintf(stderr, "%*c+ import_from_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]"));
+ _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s import_from_as_name[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ['as' NAME]"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
-static int
-push(stack *s, int type, const dfa *d, int newstate, int lineno, int col_offset,
- int end_lineno, int end_col_offset)
+// dotted_as_names: ','.dotted_as_name+
+static asdl_seq*
+dotted_as_names_rule(Parser *p)
{
- int err;
- node *n;
- n = s->s_top->s_parent;
- assert(!s_empty(s));
- err = PyNode_AddChild(n, type, (char *)NULL, lineno, col_offset,
- end_lineno, end_col_offset);
- if (err)
- return err;
- s->s_top->s_state = newstate;
- return s_push(s, d, CHILD(n, NCH(n)-1));
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.dotted_as_name+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> dotted_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+"));
+ asdl_seq * a;
+ if (
+ (a = _gather_35_rule(p)) // ','.dotted_as_name+
+ )
+ {
+ D(fprintf(stderr, "%*c+ dotted_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s dotted_as_names[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.dotted_as_name+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
+// dotted_as_name: dotted_name ['as' NAME]
+static alias_ty
+dotted_as_name_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ alias_ty _res = NULL;
+ int _mark = p->mark;
+ { // dotted_name ['as' NAME]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> dotted_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]"));
+ expr_ty a;
+ void *b;
+ if (
+ (a = dotted_name_rule(p)) // dotted_name
+ &&
+ (b = _tmp_37_rule(p), 1) // ['as' NAME]
+ )
+ {
+ D(fprintf(stderr, "%*c+ dotted_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]"));
+ _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s dotted_as_name[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name ['as' NAME]"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-/* PARSER PROPER */
+// Left-recursive
+// dotted_name: dotted_name '.' NAME | NAME
+static expr_ty dotted_name_raw(Parser *);
+static expr_ty
+dotted_name_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, dotted_name_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res);
+ if (tmpvar_0) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = dotted_name_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+dotted_name_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ { // dotted_name '.' NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = dotted_name_rule(p)) // dotted_name
+ &&
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ &&
+ (b = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME"));
+ _res = _PyPegen_join_names_with_dot ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name '.' NAME"));
+ }
+ { // NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
+ expr_ty name_var;
+ if (
+ (name_var = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
+ _res = name_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-static int
-classify(parser_state *ps, int type, const char *str)
+// if_stmt:
+// | 'if' named_expression ':' block elif_stmt
+// | 'if' named_expression ':' block else_block?
+static stmt_ty
+if_stmt_rule(Parser *p)
{
- grammar *g = ps->p_grammar;
- int n = g->g_ll.ll_nlabels;
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'if' named_expression ':' block elif_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt"));
+ Token * _keyword;
+ Token * _literal;
+ expr_ty a;
+ asdl_seq* b;
+ stmt_ty c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
+ &&
+ (a = named_expression_rule(p)) // named_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (c = elif_stmt_rule(p)) // elif_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block elif_stmt"));
+ }
+ { // 'if' named_expression ':' block else_block?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?"));
+ Token * _keyword;
+ Token * _literal;
+ expr_ty a;
+ asdl_seq* b;
+ void *c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
+ &&
+ (a = named_expression_rule(p)) // named_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (c = else_block_rule(p), 1) // else_block?
+ )
+ {
+ D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_If ( a , b , c , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block else_block?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- if (type == NAME) {
- const label *l = g->g_ll.ll_label;
- int i;
- for (i = n; i > 0; i--, l++) {
- if (l->lb_type != NAME || l->lb_str == NULL ||
- l->lb_str[0] != str[0] ||
- strcmp(l->lb_str, str) != 0)
- continue;
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
-#if 0
- /* Leaving this in as an example */
- if (!(ps->p_flags & CO_FUTURE_WITH_STATEMENT)) {
- if (str[0] == 'w' && strcmp(str, "with") == 0)
- break; /* not a keyword yet */
- else if (str[0] == 'a' && strcmp(str, "as") == 0)
- break; /* not a keyword yet */
+// elif_stmt:
+// | 'elif' named_expression ':' block elif_stmt
+// | 'elif' named_expression ':' block else_block?
+static stmt_ty
+elif_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'elif' named_expression ':' block elif_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt"));
+ Token * _keyword;
+ Token * _literal;
+ expr_ty a;
+ asdl_seq* b;
+ stmt_ty c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 515)) // token='elif'
+ &&
+ (a = named_expression_rule(p)) // named_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (c = elif_stmt_rule(p)) // elif_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
}
-#endif
-#endif
- D(printf("It's a keyword\n"));
- return n - i;
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
}
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block elif_stmt"));
}
+ { // 'elif' named_expression ':' block else_block?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?"));
+ Token * _keyword;
+ Token * _literal;
+ expr_ty a;
+ asdl_seq* b;
+ void *c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 515)) // token='elif'
+ &&
+ (a = named_expression_rule(p)) // named_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (c = else_block_rule(p), 1) // else_block?
+ )
+ {
+ D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_If ( a , b , c , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block else_block?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- {
- const label *l = g->g_ll.ll_label;
- int i;
- for (i = n; i > 0; i--, l++) {
- if (l->lb_type == type && l->lb_str == NULL) {
- D(printf("It's a token we know\n"));
- return n - i;
+// else_block: 'else' ':' block
+static asdl_seq*
+else_block_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // 'else' ':' block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> else_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' ':' block"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq* b;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 516)) // token='else'
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ else_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' block"));
+ _res = b;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
}
+ goto done;
}
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s else_block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' ':' block"));
}
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- D(printf("Illegal token\n"));
- return -1;
+// while_stmt: 'while' named_expression ':' block else_block?
+static stmt_ty
+while_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'while' named_expression ':' block else_block?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?"));
+ Token * _keyword;
+ Token * _literal;
+ expr_ty a;
+ asdl_seq* b;
+ void *c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 512)) // token='while'
+ &&
+ (a = named_expression_rule(p)) // named_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (c = else_block_rule(p), 1) // else_block?
+ )
+ {
+ D(fprintf(stderr, "%*c+ while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_While ( a , b , c , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s while_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression ':' block else_block?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
-#if 0
-/* Leaving this in as an example */
-static void
-future_hack(parser_state *ps)
+// for_stmt:
+// | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
+// | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
+static stmt_ty
+for_stmt_rule(Parser *p)
{
- node *n = ps->p_stack.s_top->s_parent;
- node *ch, *cch;
- int i;
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
+ Token * _keyword;
+ Token * _keyword_1;
+ Token * _literal;
+ asdl_seq* b;
+ void *el;
+ expr_ty ex;
+ expr_ty t;
+ void *tc;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
+ &&
+ (t = star_targets_rule(p)) // star_targets
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
+ &&
+ (ex = star_expressions_rule(p)) // star_expressions
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (el = else_block_rule(p), 1) // else_block?
+ )
+ {
+ D(fprintf(stderr, "%*c+ for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
+ }
+ { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
+ Token * _keyword;
+ Token * _keyword_1;
+ Token * _literal;
+ Token * async_var;
+ asdl_seq* b;
+ void *el;
+ expr_ty ex;
+ expr_ty t;
+ void *tc;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ &&
+ (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
+ &&
+ (t = star_targets_rule(p)) // star_targets
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
+ &&
+ (ex = star_expressions_rule(p)) // star_expressions
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (el = else_block_rule(p), 1) // else_block?
+ )
+ {
+ D(fprintf(stderr, "%*c+ for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- /* from __future__ import ..., must have at least 4 children */
- n = CHILD(n, 0);
- if (NCH(n) < 4)
- return;
- ch = CHILD(n, 0);
- if (STR(ch) == NULL || strcmp(STR(ch), "from") != 0)
- return;
- ch = CHILD(n, 1);
- if (NCH(ch) == 1 && STR(CHILD(ch, 0)) &&
- strcmp(STR(CHILD(ch, 0)), "__future__") != 0)
- return;
- ch = CHILD(n, 3);
- /* ch can be a star, a parenthesis or import_as_names */
- if (TYPE(ch) == STAR)
- return;
- if (TYPE(ch) == LPAR)
- ch = CHILD(n, 4);
+// with_stmt:
+// | 'with' '(' ','.with_item+ ','? ')' ':' block
+// | 'with' ','.with_item+ ':' TYPE_COMMENT? block
+// | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
+// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
+static stmt_ty
+with_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'with' '(' ','.with_item+ ','? ')' ':' block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block"));
+ Token * _keyword;
+ Token * _literal;
+ Token * _literal_1;
+ Token * _literal_2;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ asdl_seq* b;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
+ &&
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = _gather_38_rule(p)) // ','.with_item+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ &&
+ (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_With ( a , b , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block"));
+ }
+ { // 'with' ','.with_item+ ':' TYPE_COMMENT? block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq * a;
+ asdl_seq* b;
+ void *tc;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
+ &&
+ (a = _gather_40_rule(p)) // ','.with_item+
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block"));
+ }
+ { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block"));
+ Token * _keyword;
+ Token * _literal;
+ Token * _literal_1;
+ Token * _literal_2;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ Token * async_var;
+ asdl_seq* b;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ &&
+ (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
+ &&
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = _gather_42_rule(p)) // ','.with_item+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ &&
+ (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block"));
+ }
+ { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq * a;
+ Token * async_var;
+ asdl_seq* b;
+ void *tc;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ &&
+ (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
+ &&
+ (a = _gather_44_rule(p)) // ','.with_item+
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- for (i = 0; i < NCH(ch); i += 2) {
- cch = CHILD(ch, i);
- if (NCH(cch) >= 1 && TYPE(CHILD(cch, 0)) == NAME) {
- char *str_ch = STR(CHILD(cch, 0));
- if (strcmp(str_ch, FUTURE_WITH_STATEMENT) == 0) {
- ps->p_flags |= CO_FUTURE_WITH_STATEMENT;
- } else if (strcmp(str_ch, FUTURE_PRINT_FUNCTION) == 0) {
- ps->p_flags |= CO_FUTURE_PRINT_FUNCTION;
- } else if (strcmp(str_ch, FUTURE_UNICODE_LITERALS) == 0) {
- ps->p_flags |= CO_FUTURE_UNICODE_LITERALS;
+// with_item: expression ['as' target]
+static withitem_ty
+with_item_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ withitem_ty _res = NULL;
+ int _mark = p->mark;
+ { // expression ['as' target]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' target]"));
+ expr_ty e;
+ void *o;
+ if (
+ (e = expression_rule(p)) // expression
+ &&
+ (o = _tmp_46_rule(p), 1) // ['as' target]
+ )
+ {
+ D(fprintf(stderr, "%*c+ with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' target]"));
+ _res = _Py_withitem ( e , o , p -> arena );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
}
+ goto done;
}
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s with_item[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' target]"));
}
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
-#endif
-#endif /* future keyword */
-
-int
-PyParser_AddToken(parser_state *ps, int type, char *str,
- int lineno, int col_offset,
- int end_lineno, int end_col_offset,
- int *expected_ret)
-{
- int ilabel;
- int err;
-
- D(printf("Token %s/'%s' ... ", _PyParser_TokenNames[type], str));
-
- /* Find out which label this token is */
- ilabel = classify(ps, type, str);
- if (ilabel < 0)
- return E_SYNTAX;
-
- /* Loop until the token is shifted or an error occurred */
- for (;;) {
- /* Fetch the current dfa and state */
- const dfa *d = ps->p_stack.s_top->s_dfa;
- state *s = &d->d_state[ps->p_stack.s_top->s_state];
-
- D(printf(" DFA '%s', state %d:",
- d->d_name, ps->p_stack.s_top->s_state));
-
- /* Check accelerator */
- if (s->s_lower <= ilabel && ilabel < s->s_upper) {
- int x = s->s_accel[ilabel - s->s_lower];
- if (x != -1) {
- if (x & (1<<7)) {
- /* Push non-terminal */
- int nt = (x >> 8) + NT_OFFSET;
- int arrow = x & ((1<<7)-1);
- if (nt == func_body_suite && !(ps->p_flags & PyCF_TYPE_COMMENTS)) {
- /* When parsing type comments is not requested,
- we can provide better errors about bad indentation
- by using 'suite' for the body of a funcdef */
- D(printf(" [switch func_body_suite to suite]"));
- nt = suite;
- }
- const dfa *d1 = PyGrammar_FindDFA(
- ps->p_grammar, nt);
- if ((err = push(&ps->p_stack, nt, d1,
- arrow, lineno, col_offset,
- end_lineno, end_col_offset)) > 0) {
- D(printf(" MemError: push\n"));
- return err;
- }
- D(printf(" Push '%s'\n", d1->d_name));
- continue;
- }
-
- /* Shift the token */
- if ((err = shift(&ps->p_stack, type, str,
- x, lineno, col_offset,
- end_lineno, end_col_offset)) > 0) {
- D(printf(" MemError: shift.\n"));
- return err;
- }
- D(printf(" Shift.\n"));
- /* Pop while we are in an accept-only state */
- while (s = &d->d_state
- [ps->p_stack.s_top->s_state],
- s->s_accept && s->s_narcs == 1) {
- D(printf(" DFA '%s', state %d: "
- "Direct pop.\n",
- d->d_name,
- ps->p_stack.s_top->s_state));
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
-#if 0
- if (d->d_name[0] == 'i' &&
- strcmp(d->d_name,
- "import_stmt") == 0)
- future_hack(ps);
-#endif
-#endif
- s_pop(&ps->p_stack);
- if (s_empty(&ps->p_stack)) {
- D(printf(" ACCEPT.\n"));
- return E_DONE;
- }
- d = ps->p_stack.s_top->s_dfa;
+
+// try_stmt:
+// | 'try' ':' block finally_block
+// | 'try' ':' block except_block+ else_block? finally_block?
+static stmt_ty
+try_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'try' ':' block finally_block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block finally_block"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq* b;
+ asdl_seq* f;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 511)) // token='try'
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (f = finally_block_rule(p)) // finally_block
+ )
+ {
+ D(fprintf(stderr, "%*c+ try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block finally_block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Try ( b , NULL , NULL , f , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block finally_block"));
+ }
+ { // 'try' ':' block except_block+ else_block? finally_block?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block except_block+ else_block? finally_block?"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq* b;
+ void *el;
+ asdl_seq * ex;
+ void *f;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 511)) // token='try'
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ &&
+ (ex = _loop1_47_rule(p)) // except_block+
+ &&
+ (el = else_block_rule(p), 1) // else_block?
+ &&
+ (f = finally_block_rule(p), 1) // finally_block?
+ )
+ {
+ D(fprintf(stderr, "%*c+ try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block except_block+ else_block? finally_block?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Try ( b , ex , el , f , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block except_block+ else_block? finally_block?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// except_block: 'except' expression ['as' NAME] ':' block | 'except' ':' block
+static excepthandler_ty
+except_block_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ excepthandler_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'except' expression ['as' NAME] ':' block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq* b;
+ expr_ty e;
+ void *t;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 520)) // token='except'
+ &&
+ (e = expression_rule(p)) // expression
+ &&
+ (t = _tmp_48_rule(p), 1) // ['as' NAME]
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] ':' block"));
+ }
+ { // 'except' ':' block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' ':' block"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq* b;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 520)) // token='except'
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' ':' block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' ':' block"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// finally_block: 'finally' ':' block
+static asdl_seq*
+finally_block_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // 'finally' ':' block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> finally_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally' ':' block"));
+ Token * _keyword;
+ Token * _literal;
+ asdl_seq* a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 521)) // token='finally'
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (a = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ finally_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally' ':' block"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s finally_block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally' ':' block"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// return_stmt: 'return' star_expressions?
+static stmt_ty
+return_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'return' star_expressions?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?"));
+ Token * _keyword;
+ void *a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 500)) // token='return'
+ &&
+ (a = star_expressions_rule(p), 1) // star_expressions?
+ )
+ {
+ D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Return ( a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// raise_stmt: 'raise' expression ['from' expression] | 'raise'
+static stmt_ty
+raise_stmt_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'raise' expression ['from' expression]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]"));
+ Token * _keyword;
+ expr_ty a;
+ void *b;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 501)) // token='raise'
+ &&
+ (a = expression_rule(p)) // expression
+ &&
+ (b = _tmp_49_rule(p), 1) // ['from' expression]
+ )
+ {
+ D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Raise ( a , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]"));
+ }
+ { // 'raise'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 501)) // token='raise'
+ )
+ {
+ D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Raise ( NULL , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// function_def: decorators function_def_raw | function_def_raw
+static stmt_ty
+function_def_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ { // decorators function_def_raw
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw"));
+ asdl_seq* d;
+ stmt_ty f;
+ if (
+ (d = decorators_rule(p)) // decorators
+ &&
+ (f = function_def_raw_rule(p)) // function_def_raw
+ )
+ {
+ D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw"));
+ _res = _PyPegen_function_def_decorators ( p , d , f );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators function_def_raw"));
+ }
+ { // function_def_raw
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "function_def_raw"));
+ stmt_ty function_def_raw_var;
+ if (
+ (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw
+ )
+ {
+ D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "function_def_raw"));
+ _res = function_def_raw_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "function_def_raw"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// function_def_raw:
+// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
+// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
+static stmt_ty
+function_def_raw_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
+ Token * _keyword;
+ Token * _literal;
+ Token * _literal_1;
+ Token * _literal_2;
+ void *a;
+ asdl_seq* b;
+ expr_ty n;
+ void *params;
+ void *tc;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 522)) // token='def'
+ &&
+ (n = _PyPegen_name_token(p)) // NAME
+ &&
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (params = params_rule(p), 1) // params?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ &&
+ (a = _tmp_50_rule(p), 1) // ['->' expression]
+ &&
+ (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (tc = func_type_comment_rule(p), 1) // func_type_comment?
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
+ }
+ { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
+ Token * _keyword;
+ Token * _literal;
+ Token * _literal_1;
+ Token * _literal_2;
+ void *a;
+ Token * async_var;
+ asdl_seq* b;
+ expr_ty n;
+ void *params;
+ void *tc;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ &&
+ (_keyword = _PyPegen_expect_token(p, 522)) // token='def'
+ &&
+ (n = _PyPegen_name_token(p)) // NAME
+ &&
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (params = params_rule(p), 1) // params?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ &&
+ (a = _tmp_51_rule(p), 1) // ['->' expression]
+ &&
+ (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (tc = func_type_comment_rule(p), 1) // func_type_comment?
+ &&
+ (b = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// func_type_comment:
+// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
+// | invalid_double_type_comments
+// | TYPE_COMMENT
+static Token*
+func_type_comment_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ Token* _res = NULL;
+ int _mark = p->mark;
+ { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)"));
+ Token * newline_var;
+ Token * t;
+ if (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ &&
+ (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
+ &&
+ _PyPegen_lookahead(1, _tmp_52_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)"));
+ _res = t;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)"));
+ }
+ { // invalid_double_type_comments
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments"));
+ void *invalid_double_type_comments_var;
+ if (
+ (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments
+ )
+ {
+ D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments"));
+ _res = invalid_double_type_comments_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments"));
+ }
+ { // TYPE_COMMENT
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT"));
+ Token * type_comment_var;
+ if (
+ (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
+ )
+ {
+ D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT"));
+ _res = type_comment_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// params: invalid_parameters | parameters
+static arguments_ty
+params_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arguments_ty _res = NULL;
+ int _mark = p->mark;
+ { // invalid_parameters
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_parameters"));
+ void *invalid_parameters_var;
+ if (
+ (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters
+ )
+ {
+ D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_parameters"));
+ _res = invalid_parameters_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_parameters"));
+ }
+ { // parameters
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "parameters"));
+ arguments_ty parameters_var;
+ if (
+ (parameters_var = parameters_rule(p)) // parameters
+ )
+ {
+ D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "parameters"));
+ _res = parameters_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "parameters"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// parameters:
+// | slash_no_default param_no_default* param_with_default* star_etc?
+// | slash_with_default param_with_default* star_etc?
+// | param_no_default+ param_with_default* star_etc?
+// | param_with_default+ star_etc?
+// | star_etc
+static arguments_ty
+parameters_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arguments_ty _res = NULL;
+ int _mark = p->mark;
+ { // slash_no_default param_no_default* param_with_default* star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?"));
+ asdl_seq* a;
+ asdl_seq * b;
+ asdl_seq * c;
+ void *d;
+ if (
+ (a = slash_no_default_rule(p)) // slash_no_default
+ &&
+ (b = _loop0_53_rule(p)) // param_no_default*
+ &&
+ (c = _loop0_54_rule(p)) // param_with_default*
+ &&
+ (d = star_etc_rule(p), 1) // star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?"));
+ _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?"));
+ }
+ { // slash_with_default param_with_default* star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?"));
+ SlashWithDefault* a;
+ asdl_seq * b;
+ void *c;
+ if (
+ (a = slash_with_default_rule(p)) // slash_with_default
+ &&
+ (b = _loop0_55_rule(p)) // param_with_default*
+ &&
+ (c = star_etc_rule(p), 1) // star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?"));
+ _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default param_with_default* star_etc?"));
+ }
+ { // param_no_default+ param_with_default* star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?"));
+ asdl_seq * a;
+ asdl_seq * b;
+ void *c;
+ if (
+ (a = _loop1_56_rule(p)) // param_no_default+
+ &&
+ (b = _loop0_57_rule(p)) // param_with_default*
+ &&
+ (c = star_etc_rule(p), 1) // star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?"));
+ _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ param_with_default* star_etc?"));
+ }
+ { // param_with_default+ star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?"));
+ asdl_seq * a;
+ void *b;
+ if (
+ (a = _loop1_58_rule(p)) // param_with_default+
+ &&
+ (b = star_etc_rule(p), 1) // star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?"));
+ _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+ star_etc?"));
+ }
+ { // star_etc
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_etc"));
+ StarEtc* a;
+ if (
+ (a = star_etc_rule(p)) // star_etc
+ )
+ {
+ D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_etc"));
+ _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_etc"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')'
+static asdl_seq*
+slash_no_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // param_no_default+ '/' ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * a;
+ if (
+ (a = _loop1_59_rule(p)) // param_no_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' ','"));
+ }
+ { // param_no_default+ '/' &')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'"));
+ Token * _literal;
+ asdl_seq * a;
+ if (
+ (a = _loop1_60_rule(p)) // param_no_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' &')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// slash_with_default:
+// | param_no_default* param_with_default+ '/' ','
+// | param_no_default* param_with_default+ '/' &')'
+static SlashWithDefault*
+slash_with_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ SlashWithDefault* _res = NULL;
+ int _mark = p->mark;
+ { // param_no_default* param_with_default+ '/' ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * a;
+ asdl_seq * b;
+ if (
+ (a = _loop0_61_rule(p)) // param_no_default*
+ &&
+ (b = _loop1_62_rule(p)) // param_with_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','"));
+ _res = _PyPegen_slash_with_default ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' ','"));
+ }
+ { // param_no_default* param_with_default+ '/' &')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'"));
+ Token * _literal;
+ asdl_seq * a;
+ asdl_seq * b;
+ if (
+ (a = _loop0_63_rule(p)) // param_no_default*
+ &&
+ (b = _loop1_64_rule(p)) // param_with_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'"));
+ _res = _PyPegen_slash_with_default ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' &')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// star_etc:
+// | '*' param_no_default param_maybe_default* kwds?
+// | '*' ',' param_maybe_default+ kwds?
+// | kwds
+// | invalid_star_etc
+static StarEtc*
+star_etc_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ StarEtc* _res = NULL;
+ int _mark = p->mark;
+ { // '*' param_no_default param_maybe_default* kwds?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?"));
+ Token * _literal;
+ arg_ty a;
+ asdl_seq * b;
+ void *c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = param_no_default_rule(p)) // param_no_default
+ &&
+ (b = _loop0_65_rule(p)) // param_maybe_default*
+ &&
+ (c = kwds_rule(p), 1) // kwds?
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?"));
+ _res = _PyPegen_star_etc ( p , a , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?"));
+ }
+ { // '*' ',' param_maybe_default+ kwds?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * b;
+ void *c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (b = _loop1_66_rule(p)) // param_maybe_default+
+ &&
+ (c = kwds_rule(p), 1) // kwds?
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?"));
+ _res = _PyPegen_star_etc ( p , NULL , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' param_maybe_default+ kwds?"));
+ }
+ { // kwds
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwds"));
+ arg_ty a;
+ if (
+ (a = kwds_rule(p)) // kwds
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwds"));
+ _res = _PyPegen_star_etc ( p , NULL , NULL , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwds"));
+ }
+ { // invalid_star_etc
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_star_etc"));
+ void *invalid_star_etc_var;
+ if (
+ (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_star_etc"));
+ _res = invalid_star_etc_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_star_etc"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// kwds: '**' param_no_default
+static arg_ty
+kwds_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arg_ty _res = NULL;
+ int _mark = p->mark;
+ { // '**' param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param_no_default"));
+ Token * _literal;
+ arg_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (a = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param_no_default"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwds[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param_no_default"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')'
+static arg_ty
+param_no_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arg_ty _res = NULL;
+ int _mark = p->mark;
+ { // param ',' TYPE_COMMENT?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?"));
+ Token * _literal;
+ arg_ty a;
+ void *tc;
+ if (
+ (a = param_rule(p)) // param
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ )
+ {
+ D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?"));
+ _res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param ',' TYPE_COMMENT?"));
+ }
+ { // param TYPE_COMMENT? &')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'"));
+ arg_ty a;
+ void *tc;
+ if (
+ (a = param_rule(p)) // param
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'"));
+ _res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param TYPE_COMMENT? &')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')'
+static NameDefaultPair*
+param_with_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ NameDefaultPair* _res = NULL;
+ int _mark = p->mark;
+ { // param default ',' TYPE_COMMENT?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?"));
+ Token * _literal;
+ arg_ty a;
+ expr_ty c;
+ void *tc;
+ if (
+ (a = param_rule(p)) // param
+ &&
+ (c = default_rule(p)) // default
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ )
+ {
+ D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?"));
+ _res = _PyPegen_name_default_pair ( p , a , c , tc );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default ',' TYPE_COMMENT?"));
+ }
+ { // param default TYPE_COMMENT? &')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'"));
+ arg_ty a;
+ expr_ty c;
+ void *tc;
+ if (
+ (a = param_rule(p)) // param
+ &&
+ (c = default_rule(p)) // default
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'"));
+ _res = _PyPegen_name_default_pair ( p , a , c , tc );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default TYPE_COMMENT? &')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// param_maybe_default:
+// | param default? ',' TYPE_COMMENT?
+// | param default? TYPE_COMMENT? &')'
+static NameDefaultPair*
+param_maybe_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ NameDefaultPair* _res = NULL;
+ int _mark = p->mark;
+ { // param default? ',' TYPE_COMMENT?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?"));
+ Token * _literal;
+ arg_ty a;
+ void *c;
+ void *tc;
+ if (
+ (a = param_rule(p)) // param
+ &&
+ (c = default_rule(p), 1) // default?
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ )
+ {
+ D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?"));
+ _res = _PyPegen_name_default_pair ( p , a , c , tc );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? ',' TYPE_COMMENT?"));
+ }
+ { // param default? TYPE_COMMENT? &')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'"));
+ arg_ty a;
+ void *c;
+ void *tc;
+ if (
+ (a = param_rule(p)) // param
+ &&
+ (c = default_rule(p), 1) // default?
+ &&
+ (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'"));
+ _res = _PyPegen_name_default_pair ( p , a , c , tc );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? TYPE_COMMENT? &')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// param: NAME annotation?
+static arg_ty
+param_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arg_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME annotation?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME annotation?"));
+ expr_ty a;
+ void *b;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ (b = annotation_rule(p), 1) // annotation?
+ )
+ {
+ D(fprintf(stderr, "%*c+ param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME annotation?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s param[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME annotation?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// annotation: ':' expression
+static expr_ty
+annotation_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ { // ':' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> annotation[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ annotation[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s annotation[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// default: '=' expression
+static expr_ty
+default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ { // '=' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' expression"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ &&
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' expression"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// decorators: (('@' named_expression NEWLINE))+
+static asdl_seq*
+decorators_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // (('@' named_expression NEWLINE))+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+"));
+ asdl_seq * a;
+ if (
+ (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+
+ )
+ {
+ D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s decorators[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(('@' named_expression NEWLINE))+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// class_def: decorators class_def_raw | class_def_raw
+static stmt_ty
+class_def_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ { // decorators class_def_raw
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw"));
+ asdl_seq* a;
+ stmt_ty b;
+ if (
+ (a = decorators_rule(p)) // decorators
+ &&
+ (b = class_def_raw_rule(p)) // class_def_raw
+ )
+ {
+ D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw"));
+ _res = _PyPegen_class_def_decorators ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators class_def_raw"));
+ }
+ { // class_def_raw
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_def_raw"));
+ stmt_ty class_def_raw_var;
+ if (
+ (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw
+ )
+ {
+ D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_def_raw"));
+ _res = class_def_raw_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_def_raw"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block
+static stmt_ty
+class_def_raw_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ stmt_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'class' NAME ['(' arguments? ')'] ':' block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block"));
+ Token * _keyword;
+ Token * _literal;
+ expr_ty a;
+ void *b;
+ asdl_seq* c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 523)) // token='class'
+ &&
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ (b = _tmp_68_rule(p), 1) // ['(' arguments? ')']
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (c = block_rule(p)) // block
+ )
+ {
+ D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
+static asdl_seq*
+block_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ if (_PyPegen_is_memoized(p, block_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ { // NEWLINE INDENT statements DEDENT
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
+ asdl_seq* a;
+ Token * dedent_var;
+ Token * indent_var;
+ Token * newline_var;
+ if (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ &&
+ (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
+ &&
+ (a = statements_rule(p)) // statements
+ &&
+ (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT'
+ )
+ {
+ D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
+ }
+ { // simple_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ asdl_seq* simple_stmt_var;
+ if (
+ (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
+ )
+ {
+ D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
+ _res = simple_stmt_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
+ }
+ { // invalid_block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_block"));
+ void *invalid_block_var;
+ if (
+ (invalid_block_var = invalid_block_rule(p)) // invalid_block
+ )
+ {
+ D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_block"));
+ _res = invalid_block_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_block"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, block_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// expressions_list: ','.star_expression+ ','?
+static asdl_seq*
+expressions_list_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.star_expression+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> expressions_list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ if (
+ (a = _gather_69_rule(p)) // ','.star_expression+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ expressions_list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s expressions_list[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_expression+ ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// star_expressions:
+// | star_expression ((',' star_expression))+ ','?
+// | star_expression ','
+// | star_expression
+static expr_ty
+star_expressions_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // star_expression ((',' star_expression))+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ expr_ty a;
+ asdl_seq * b;
+ if (
+ (a = star_expression_rule(p)) // star_expression
+ &&
+ (b = _loop1_71_rule(p)) // ((',' star_expression))+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ((',' star_expression))+ ','?"));
+ }
+ { // star_expression ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ','"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (a = star_expression_rule(p)) // star_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ','"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ','"));
+ }
+ { // star_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression"));
+ expr_ty star_expression_var;
+ if (
+ (star_expression_var = star_expression_rule(p)) // star_expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression"));
+ _res = star_expression_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// star_expression: '*' bitwise_or | expression
+static expr_ty
+star_expression_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, star_expression_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '*' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Starred ( a , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or"));
+ }
+ { // expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression"));
+ expr_ty expression_var;
+ if (
+ (expression_var = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression"));
+ _res = expression_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, star_expression_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// star_named_expressions: ','.star_named_expression+ ','?
+static asdl_seq*
+star_named_expressions_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.star_named_expression+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_named_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ if (
+ (a = _gather_72_rule(p)) // ','.star_named_expression+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_named_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_named_expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_named_expression+ ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// star_named_expression: '*' bitwise_or | named_expression
+static expr_ty
+star_named_expression_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '*' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Starred ( a , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or"));
+ }
+ { // named_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression"));
+ expr_ty named_expression_var;
+ if (
+ (named_expression_var = named_expression_rule(p)) // named_expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression"));
+ _res = named_expression_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression
+static expr_ty
+named_expression_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME ':=' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ (_literal = _PyPegen_expect_token(p, 53)) // token=':='
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' expression"));
+ }
+ { // expression !':='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='"));
+ expr_ty expression_var;
+ if (
+ (expression_var = expression_rule(p)) // expression
+ &&
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':='
+ )
+ {
+ D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='"));
+ _res = expression_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='"));
+ }
+ { // invalid_named_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_named_expression"));
+ void *invalid_named_expression_var;
+ if (
+ (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_named_expression"));
+ _res = invalid_named_expression_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_named_expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// annotated_rhs: yield_expr | star_expressions
+static expr_ty
+annotated_rhs_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ { // yield_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ expr_ty yield_expr_var;
+ if (
+ (yield_expr_var = yield_expr_rule(p)) // yield_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ _res = yield_expr_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
+ }
+ { // star_expressions
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ expr_ty star_expressions_var;
+ if (
+ (star_expressions_var = star_expressions_rule(p)) // star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ _res = star_expressions_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// expressions: expression ((',' expression))+ ','? | expression ',' | expression
+static expr_ty
+expressions_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // expression ((',' expression))+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ expr_ty a;
+ asdl_seq * b;
+ if (
+ (a = expression_rule(p)) // expression
+ &&
+ (b = _loop1_74_rule(p)) // ((',' expression))+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ((',' expression))+ ','?"));
+ }
+ { // expression ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ','"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (a = expression_rule(p)) // expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ','"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ','"));
+ }
+ { // expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression"));
+ expr_ty expression_var;
+ if (
+ (expression_var = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression"));
+ _res = expression_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef
+static expr_ty
+expression_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, expression_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // disjunction 'if' disjunction 'else' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression"));
+ Token * _keyword;
+ Token * _keyword_1;
+ expr_ty a;
+ expr_ty b;
+ expr_ty c;
+ if (
+ (a = disjunction_rule(p)) // disjunction
+ &&
+ (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
+ &&
+ (b = disjunction_rule(p)) // disjunction
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else'
+ &&
+ (c = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_IfExp ( b , a , c , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression"));
+ }
+ { // disjunction
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction"));
+ expr_ty disjunction_var;
+ if (
+ (disjunction_var = disjunction_rule(p)) // disjunction
+ )
+ {
+ D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction"));
+ _res = disjunction_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction"));
+ }
+ { // lambdef
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef"));
+ expr_ty lambdef_var;
+ if (
+ (lambdef_var = lambdef_rule(p)) // lambdef
+ )
+ {
+ D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef"));
+ _res = lambdef_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, expression_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// lambdef: 'lambda' lambda_params? ':' expression
+static expr_ty
+lambdef_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'lambda' lambda_params? ':' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambdef[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression"));
+ Token * _keyword;
+ Token * _literal;
+ void *a;
+ expr_ty b;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 524)) // token='lambda'
+ &&
+ (a = lambda_params_rule(p), 1) // lambda_params?
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambdef[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambdef[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_params: invalid_lambda_parameters | lambda_parameters
+static arguments_ty
+lambda_params_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arguments_ty _res = NULL;
+ int _mark = p->mark;
+ { // invalid_lambda_parameters
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters"));
+ void *invalid_lambda_parameters_var;
+ if (
+ (invalid_lambda_parameters_var = invalid_lambda_parameters_rule(p)) // invalid_lambda_parameters
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters"));
+ _res = invalid_lambda_parameters_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_parameters"));
+ }
+ { // lambda_parameters
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_parameters"));
+ arguments_ty lambda_parameters_var;
+ if (
+ (lambda_parameters_var = lambda_parameters_rule(p)) // lambda_parameters
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_parameters"));
+ _res = lambda_parameters_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_parameters"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_parameters:
+// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
+// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
+// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
+// | lambda_param_with_default+ lambda_star_etc?
+// | lambda_star_etc
+static arguments_ty
+lambda_parameters_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arguments_ty _res = NULL;
+ int _mark = p->mark;
+ { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?"));
+ asdl_seq* a;
+ asdl_seq * b;
+ asdl_seq * c;
+ void *d;
+ if (
+ (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default
+ &&
+ (b = _loop0_75_rule(p)) // lambda_param_no_default*
+ &&
+ (c = _loop0_76_rule(p)) // lambda_param_with_default*
+ &&
+ (d = lambda_star_etc_rule(p), 1) // lambda_star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?"));
+ _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?"));
+ }
+ { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?"));
+ SlashWithDefault* a;
+ asdl_seq * b;
+ void *c;
+ if (
+ (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
+ &&
+ (b = _loop0_77_rule(p)) // lambda_param_with_default*
+ &&
+ (c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?"));
+ _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?"));
+ }
+ { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?"));
+ asdl_seq * a;
+ asdl_seq * b;
+ void *c;
+ if (
+ (a = _loop1_78_rule(p)) // lambda_param_no_default+
+ &&
+ (b = _loop0_79_rule(p)) // lambda_param_with_default*
+ &&
+ (c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?"));
+ _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?"));
+ }
+ { // lambda_param_with_default+ lambda_star_etc?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?"));
+ asdl_seq * a;
+ void *b;
+ if (
+ (a = _loop1_80_rule(p)) // lambda_param_with_default+
+ &&
+ (b = lambda_star_etc_rule(p), 1) // lambda_star_etc?
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?"));
+ _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?"));
+ }
+ { // lambda_star_etc
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_star_etc"));
+ StarEtc* a;
+ if (
+ (a = lambda_star_etc_rule(p)) // lambda_star_etc
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_star_etc"));
+ _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_star_etc"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_slash_no_default:
+// | lambda_param_no_default+ '/' ','
+// | lambda_param_no_default+ '/' &':'
+static asdl_seq*
+lambda_slash_no_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // lambda_param_no_default+ '/' ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * a;
+ if (
+ (a = _loop1_81_rule(p)) // lambda_param_no_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' ','"));
+ }
+ { // lambda_param_no_default+ '/' &':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'"));
+ Token * _literal;
+ asdl_seq * a;
+ if (
+ (a = _loop1_82_rule(p)) // lambda_param_no_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' &':'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_slash_with_default:
+// | lambda_param_no_default* lambda_param_with_default+ '/' ','
+// | lambda_param_no_default* lambda_param_with_default+ '/' &':'
+static SlashWithDefault*
+lambda_slash_with_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ SlashWithDefault* _res = NULL;
+ int _mark = p->mark;
+ { // lambda_param_no_default* lambda_param_with_default+ '/' ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * a;
+ asdl_seq * b;
+ if (
+ (a = _loop0_83_rule(p)) // lambda_param_no_default*
+ &&
+ (b = _loop1_84_rule(p)) // lambda_param_with_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','"));
+ _res = _PyPegen_slash_with_default ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','"));
+ }
+ { // lambda_param_no_default* lambda_param_with_default+ '/' &':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'"));
+ Token * _literal;
+ asdl_seq * a;
+ asdl_seq * b;
+ if (
+ (a = _loop0_85_rule(p)) // lambda_param_no_default*
+ &&
+ (b = _loop1_86_rule(p)) // lambda_param_with_default+
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'"));
+ _res = _PyPegen_slash_with_default ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_star_etc:
+// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
+// | '*' ',' lambda_param_maybe_default+ lambda_kwds?
+// | lambda_kwds
+// | invalid_lambda_star_etc
+static StarEtc*
+lambda_star_etc_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ StarEtc* _res = NULL;
+ int _mark = p->mark;
+ { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?"));
+ Token * _literal;
+ arg_ty a;
+ asdl_seq * b;
+ void *c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ &&
+ (b = _loop0_87_rule(p)) // lambda_param_maybe_default*
+ &&
+ (c = lambda_kwds_rule(p), 1) // lambda_kwds?
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?"));
+ _res = _PyPegen_star_etc ( p , a , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?"));
+ }
+ { // '*' ',' lambda_param_maybe_default+ lambda_kwds?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * b;
+ void *c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (b = _loop1_88_rule(p)) // lambda_param_maybe_default+
+ &&
+ (c = lambda_kwds_rule(p), 1) // lambda_kwds?
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?"));
+ _res = _PyPegen_star_etc ( p , NULL , b , c );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?"));
+ }
+ { // lambda_kwds
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_kwds"));
+ arg_ty a;
+ if (
+ (a = lambda_kwds_rule(p)) // lambda_kwds
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_kwds"));
+ _res = _PyPegen_star_etc ( p , NULL , NULL , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_kwds"));
+ }
+ { // invalid_lambda_star_etc
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc"));
+ void *invalid_lambda_star_etc_var;
+ if (
+ (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc"));
+ _res = invalid_lambda_star_etc_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_star_etc"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_kwds: '**' lambda_param_no_default
+static arg_ty
+lambda_kwds_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arg_ty _res = NULL;
+ int _mark = p->mark;
+ { // '**' lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default"));
+ Token * _literal;
+ arg_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param_no_default"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_param_no_default: lambda_param ',' | lambda_param &':'
+static arg_ty
+lambda_param_no_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arg_ty _res = NULL;
+ int _mark = p->mark;
+ { // lambda_param ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param ','"));
+ Token * _literal;
+ arg_ty a;
+ if (
+ (a = lambda_param_rule(p)) // lambda_param
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param ','"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param ','"));
+ }
+ { // lambda_param &':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param &':'"));
+ arg_ty a;
+ if (
+ (a = lambda_param_rule(p)) // lambda_param
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param &':'"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param &':'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_param_with_default: lambda_param default ',' | lambda_param default &':'
+static NameDefaultPair*
+lambda_param_with_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ NameDefaultPair* _res = NULL;
+ int _mark = p->mark;
+ { // lambda_param default ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default ','"));
+ Token * _literal;
+ arg_ty a;
+ expr_ty c;
+ if (
+ (a = lambda_param_rule(p)) // lambda_param
+ &&
+ (c = default_rule(p)) // default
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default ','"));
+ _res = _PyPegen_name_default_pair ( p , a , c , NULL );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default ','"));
+ }
+ { // lambda_param default &':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'"));
+ arg_ty a;
+ expr_ty c;
+ if (
+ (a = lambda_param_rule(p)) // lambda_param
+ &&
+ (c = default_rule(p)) // default
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'"));
+ _res = _PyPegen_name_default_pair ( p , a , c , NULL );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default &':'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':'
+static NameDefaultPair*
+lambda_param_maybe_default_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ NameDefaultPair* _res = NULL;
+ int _mark = p->mark;
+ { // lambda_param default? ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','"));
+ Token * _literal;
+ arg_ty a;
+ void *c;
+ if (
+ (a = lambda_param_rule(p)) // lambda_param
+ &&
+ (c = default_rule(p), 1) // default?
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','"));
+ _res = _PyPegen_name_default_pair ( p , a , c , NULL );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? ','"));
+ }
+ { // lambda_param default? &':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'"));
+ arg_ty a;
+ void *c;
+ if (
+ (a = lambda_param_rule(p)) // lambda_param
+ &&
+ (c = default_rule(p), 1) // default?
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'"));
+ _res = _PyPegen_name_default_pair ( p , a , c , NULL );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? &':'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lambda_param: NAME
+static arg_ty
+lambda_param_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ arg_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lambda_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
+ expr_ty a;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ lambda_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lambda_param[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// disjunction: conjunction (('or' conjunction))+ | conjunction
+static expr_ty
+disjunction_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, disjunction_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // conjunction (('or' conjunction))+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+"));
+ expr_ty a;
+ asdl_seq * b;
+ if (
+ (a = conjunction_rule(p)) // conjunction
+ &&
+ (b = _loop1_89_rule(p)) // (('or' conjunction))+
+ )
+ {
+ D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction (('or' conjunction))+"));
+ }
+ { // conjunction
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction"));
+ expr_ty conjunction_var;
+ if (
+ (conjunction_var = conjunction_rule(p)) // conjunction
+ )
+ {
+ D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction"));
+ _res = conjunction_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, disjunction_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// conjunction: inversion (('and' inversion))+ | inversion
+static expr_ty
+conjunction_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, conjunction_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // inversion (('and' inversion))+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+"));
+ expr_ty a;
+ asdl_seq * b;
+ if (
+ (a = inversion_rule(p)) // inversion
+ &&
+ (b = _loop1_90_rule(p)) // (('and' inversion))+
+ )
+ {
+ D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion (('and' inversion))+"));
+ }
+ { // inversion
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion"));
+ expr_ty inversion_var;
+ if (
+ (inversion_var = inversion_rule(p)) // inversion
+ )
+ {
+ D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion"));
+ _res = inversion_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, conjunction_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// inversion: 'not' inversion | comparison
+static expr_ty
+inversion_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, inversion_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'not' inversion
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' inversion"));
+ Token * _keyword;
+ expr_ty a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 525)) // token='not'
+ &&
+ (a = inversion_rule(p)) // inversion
+ )
+ {
+ D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' inversion"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_UnaryOp ( Not , a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' inversion"));
+ }
+ { // comparison
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "comparison"));
+ expr_ty comparison_var;
+ if (
+ (comparison_var = comparison_rule(p)) // comparison
+ )
+ {
+ D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "comparison"));
+ _res = comparison_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "comparison"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, inversion_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or
+static expr_ty
+comparison_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // bitwise_or compare_op_bitwise_or_pair+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+"));
+ expr_ty a;
+ asdl_seq * b;
+ if (
+ (a = bitwise_or_rule(p)) // bitwise_or
+ &&
+ (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+
+ )
+ {
+ D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+"));
+ }
+ { // bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or"));
+ expr_ty bitwise_or_var;
+ if (
+ (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or"));
+ _res = bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// compare_op_bitwise_or_pair:
+// | eq_bitwise_or
+// | noteq_bitwise_or
+// | lte_bitwise_or
+// | lt_bitwise_or
+// | gte_bitwise_or
+// | gt_bitwise_or
+// | notin_bitwise_or
+// | in_bitwise_or
+// | isnot_bitwise_or
+// | is_bitwise_or
+static CmpopExprPair*
+compare_op_bitwise_or_pair_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // eq_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or"));
+ CmpopExprPair* eq_bitwise_or_var;
+ if (
+ (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or"));
+ _res = eq_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "eq_bitwise_or"));
+ }
+ { // noteq_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or"));
+ CmpopExprPair* noteq_bitwise_or_var;
+ if (
+ (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or"));
+ _res = noteq_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "noteq_bitwise_or"));
+ }
+ { // lte_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or"));
+ CmpopExprPair* lte_bitwise_or_var;
+ if (
+ (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or"));
+ _res = lte_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lte_bitwise_or"));
+ }
+ { // lt_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or"));
+ CmpopExprPair* lt_bitwise_or_var;
+ if (
+ (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or"));
+ _res = lt_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lt_bitwise_or"));
+ }
+ { // gte_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or"));
+ CmpopExprPair* gte_bitwise_or_var;
+ if (
+ (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or"));
+ _res = gte_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gte_bitwise_or"));
+ }
+ { // gt_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or"));
+ CmpopExprPair* gt_bitwise_or_var;
+ if (
+ (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or"));
+ _res = gt_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gt_bitwise_or"));
+ }
+ { // notin_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or"));
+ CmpopExprPair* notin_bitwise_or_var;
+ if (
+ (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or"));
+ _res = notin_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "notin_bitwise_or"));
+ }
+ { // in_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "in_bitwise_or"));
+ CmpopExprPair* in_bitwise_or_var;
+ if (
+ (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "in_bitwise_or"));
+ _res = in_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "in_bitwise_or"));
+ }
+ { // isnot_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or"));
+ CmpopExprPair* isnot_bitwise_or_var;
+ if (
+ (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or"));
+ _res = isnot_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "isnot_bitwise_or"));
+ }
+ { // is_bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "is_bitwise_or"));
+ CmpopExprPair* is_bitwise_or_var;
+ if (
+ (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "is_bitwise_or"));
+ _res = is_bitwise_or_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "is_bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// eq_bitwise_or: '==' bitwise_or
+static CmpopExprPair*
+eq_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // '==' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> eq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 27)) // token='=='
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ eq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , Eq , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s eq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// noteq_bitwise_or: ('!=') bitwise_or
+static CmpopExprPair*
+noteq_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // ('!=') bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or"));
+ void *_tmp_92_var;
+ expr_ty a;
+ if (
+ (_tmp_92_var = _tmp_92_rule(p)) // '!='
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ noteq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s noteq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lte_bitwise_or: '<=' bitwise_or
+static CmpopExprPair*
+lte_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // '<=' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 29)) // token='<='
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ lte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , LtE , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// lt_bitwise_or: '<' bitwise_or
+static CmpopExprPair*
+lt_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // '<' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> lt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 20)) // token='<'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ lt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , Lt , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s lt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// gte_bitwise_or: '>=' bitwise_or
+static CmpopExprPair*
+gte_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // '>=' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> gte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 30)) // token='>='
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ gte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , GtE , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s gte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// gt_bitwise_or: '>' bitwise_or
+static CmpopExprPair*
+gt_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // '>' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> gt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 21)) // token='>'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ gt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , Gt , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s gt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// notin_bitwise_or: 'not' 'in' bitwise_or
+static CmpopExprPair*
+notin_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // 'not' 'in' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> notin_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or"));
+ Token * _keyword;
+ Token * _keyword_1;
+ expr_ty a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 525)) // token='not'
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ notin_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s notin_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// in_bitwise_or: 'in' bitwise_or
+static CmpopExprPair*
+in_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // 'in' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> in_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or"));
+ Token * _keyword;
+ expr_ty a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 518)) // token='in'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ in_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , In , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s in_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// isnot_bitwise_or: 'is' 'not' bitwise_or
+static CmpopExprPair*
+isnot_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // 'is' 'not' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> isnot_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or"));
+ Token * _keyword;
+ Token * _keyword_1;
+ expr_ty a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 526)) // token='is'
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 525)) // token='not'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ isnot_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s isnot_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// is_bitwise_or: 'is' bitwise_or
+static CmpopExprPair*
+is_bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ CmpopExprPair* _res = NULL;
+ int _mark = p->mark;
+ { // 'is' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> is_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or"));
+ Token * _keyword;
+ expr_ty a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 526)) // token='is'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ is_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or"));
+ _res = _PyPegen_cmpop_expr_pair ( p , Is , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s is_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor
+static expr_ty bitwise_or_raw(Parser *);
+static expr_ty
+bitwise_or_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res);
+ if (tmpvar_1) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = bitwise_or_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+bitwise_or_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // bitwise_or '|' bitwise_xor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = bitwise_or_rule(p)) // bitwise_or
+ &&
+ (_literal = _PyPegen_expect_token(p, 18)) // token='|'
+ &&
+ (b = bitwise_xor_rule(p)) // bitwise_xor
+ )
+ {
+ D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , BitOr , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor"));
+ }
+ { // bitwise_xor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor"));
+ expr_ty bitwise_xor_var;
+ if (
+ (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor
+ )
+ {
+ D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor"));
+ _res = bitwise_xor_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and
+static expr_ty bitwise_xor_raw(Parser *);
+static expr_ty
+bitwise_xor_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res);
+ if (tmpvar_2) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = bitwise_xor_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+bitwise_xor_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // bitwise_xor '^' bitwise_and
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = bitwise_xor_rule(p)) // bitwise_xor
+ &&
+ (_literal = _PyPegen_expect_token(p, 32)) // token='^'
+ &&
+ (b = bitwise_and_rule(p)) // bitwise_and
+ )
+ {
+ D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , BitXor , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and"));
+ }
+ { // bitwise_and
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and"));
+ expr_ty bitwise_and_var;
+ if (
+ (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and
+ )
+ {
+ D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and"));
+ _res = bitwise_and_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// bitwise_and: bitwise_and '&' shift_expr | shift_expr
+static expr_ty bitwise_and_raw(Parser *);
+static expr_ty
+bitwise_and_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res);
+ if (tmpvar_3) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = bitwise_and_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+bitwise_and_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // bitwise_and '&' shift_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = bitwise_and_rule(p)) // bitwise_and
+ &&
+ (_literal = _PyPegen_expect_token(p, 19)) // token='&'
+ &&
+ (b = shift_expr_rule(p)) // shift_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , BitAnd , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr"));
+ }
+ { // shift_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr"));
+ expr_ty shift_expr_var;
+ if (
+ (shift_expr_var = shift_expr_rule(p)) // shift_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr"));
+ _res = shift_expr_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum
+static expr_ty shift_expr_raw(Parser *);
+static expr_ty
+shift_expr_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res);
+ if (tmpvar_4) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = shift_expr_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+shift_expr_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // shift_expr '<<' sum
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = shift_expr_rule(p)) // shift_expr
+ &&
+ (_literal = _PyPegen_expect_token(p, 33)) // token='<<'
+ &&
+ (b = sum_rule(p)) // sum
+ )
+ {
+ D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , LShift , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum"));
+ }
+ { // shift_expr '>>' sum
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = shift_expr_rule(p)) // shift_expr
+ &&
+ (_literal = _PyPegen_expect_token(p, 34)) // token='>>'
+ &&
+ (b = sum_rule(p)) // sum
+ )
+ {
+ D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , RShift , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum"));
+ }
+ { // sum
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum"));
+ expr_ty sum_var;
+ if (
+ (sum_var = sum_rule(p)) // sum
+ )
+ {
+ D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum"));
+ _res = sum_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// sum: sum '+' term | sum '-' term | term
+static expr_ty sum_raw(Parser *);
+static expr_ty
+sum_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, sum_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res);
+ if (tmpvar_5) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = sum_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+sum_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // sum '+' term
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = sum_rule(p)) // sum
+ &&
+ (_literal = _PyPegen_expect_token(p, 14)) // token='+'
+ &&
+ (b = term_rule(p)) // term
+ )
+ {
+ D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , Add , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term"));
+ }
+ { // sum '-' term
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = sum_rule(p)) // sum
+ &&
+ (_literal = _PyPegen_expect_token(p, 15)) // token='-'
+ &&
+ (b = term_rule(p)) // term
+ )
+ {
+ D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , Sub , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term"));
+ }
+ { // term
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term"));
+ expr_ty term_var;
+ if (
+ (term_var = term_rule(p)) // term
+ )
+ {
+ D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term"));
+ _res = term_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// term:
+// | term '*' factor
+// | term '/' factor
+// | term '//' factor
+// | term '%' factor
+// | term '@' factor
+// | factor
+static expr_ty term_raw(Parser *);
+static expr_ty
+term_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, term_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res);
+ if (tmpvar_6) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = term_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+term_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // term '*' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = term_rule(p)) // term
+ &&
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (b = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , Mult , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor"));
+ }
+ { // term '/' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = term_rule(p)) // term
+ &&
+ (_literal = _PyPegen_expect_token(p, 17)) // token='/'
+ &&
+ (b = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , Div , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor"));
+ }
+ { // term '//' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = term_rule(p)) // term
+ &&
+ (_literal = _PyPegen_expect_token(p, 47)) // token='//'
+ &&
+ (b = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , FloorDiv , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor"));
+ }
+ { // term '%' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = term_rule(p)) // term
+ &&
+ (_literal = _PyPegen_expect_token(p, 24)) // token='%'
+ &&
+ (b = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , Mod , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor"));
+ }
+ { // term '@' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = term_rule(p)) // term
+ &&
+ (_literal = _PyPegen_expect_token(p, 49)) // token='@'
+ &&
+ (b = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '@' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '@' factor"));
+ }
+ { // factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "factor"));
+ expr_ty factor_var;
+ if (
+ (factor_var = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "factor"));
+ _res = factor_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "factor"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// factor: '+' factor | '-' factor | '~' factor | power
+static expr_ty
+factor_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, factor_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '+' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' factor"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 14)) // token='+'
+ &&
+ (a = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_UnaryOp ( UAdd , a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' factor"));
+ }
+ { // '-' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' factor"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 15)) // token='-'
+ &&
+ (a = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_UnaryOp ( USub , a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' factor"));
+ }
+ { // '~' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~' factor"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 31)) // token='~'
+ &&
+ (a = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_UnaryOp ( Invert , a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~' factor"));
+ }
+ { // power
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "power"));
+ expr_ty power_var;
+ if (
+ (power_var = power_rule(p)) // power
+ )
+ {
+ D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "power"));
+ _res = power_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "power"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, factor_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// power: await_primary '**' factor | await_primary
+static expr_ty
+power_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // await_primary '**' factor
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = await_primary_rule(p)) // await_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (b = factor_rule(p)) // factor
+ )
+ {
+ D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_BinOp ( a , Pow , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary '**' factor"));
+ }
+ { // await_primary
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary"));
+ expr_ty await_primary_var;
+ if (
+ (await_primary_var = await_primary_rule(p)) // await_primary
+ )
+ {
+ D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary"));
+ _res = await_primary_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// await_primary: AWAIT primary | primary
+static expr_ty
+await_primary_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, await_primary_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // AWAIT primary
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "AWAIT primary"));
+ expr_ty a;
+ Token * await_var;
+ if (
+ (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT'
+ &&
+ (a = primary_rule(p)) // primary
+ )
+ {
+ D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "AWAIT primary"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "AWAIT primary"));
+ }
+ { // primary
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary"));
+ expr_ty primary_var;
+ if (
+ (primary_var = primary_rule(p)) // primary
+ )
+ {
+ D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary"));
+ _res = primary_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, await_primary_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// primary:
+// | primary '.' NAME
+// | primary genexp
+// | primary '(' arguments? ')'
+// | primary '[' slices ']'
+// | atom
+static expr_ty primary_raw(Parser *);
+static expr_ty
+primary_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, primary_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res);
+ if (tmpvar_7) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = primary_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+primary_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // primary '.' NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '.' NAME"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = primary_rule(p)) // primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ &&
+ (b = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '.' NAME"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '.' NAME"));
+ }
+ { // primary genexp
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary genexp"));
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = primary_rule(p)) // primary
+ &&
+ (b = genexp_rule(p)) // genexp
+ )
+ {
+ D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary genexp"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary genexp"));
+ }
+ { // primary '(' arguments? ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ void *b;
+ if (
+ (a = primary_rule(p)) // primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (b = arguments_rule(p), 1) // arguments?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '(' arguments? ')'"));
+ }
+ { // primary '[' slices ']'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = primary_rule(p)) // primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (b = slices_rule(p)) // slices
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ )
+ {
+ D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Subscript ( a , b , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '[' slices ']'"));
+ }
+ { // atom
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom"));
+ expr_ty atom_var;
+ if (
+ (atom_var = atom_rule(p)) // atom
+ )
+ {
+ D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom"));
+ _res = atom_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// slices: slice !',' | ','.slice+ ','?
+static expr_ty
+slices_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // slice !','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice !','"));
+ expr_ty a;
+ if (
+ (a = slice_rule(p)) // slice
+ &&
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice !','"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice !','"));
+ }
+ { // ','.slice+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ if (
+ (a = _gather_93_rule(p)) // ','.slice+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( a , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.slice+ ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// slice: expression? ':' expression? [':' expression?] | expression
+static expr_ty
+slice_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // expression? ':' expression? [':' expression?]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]"));
+ Token * _literal;
+ void *a;
+ void *b;
+ void *c;
+ if (
+ (a = expression_rule(p), 1) // expression?
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = expression_rule(p), 1) // expression?
+ &&
+ (c = _tmp_95_rule(p), 1) // [':' expression?]
+ )
+ {
+ D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Slice ( a , b , c , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression? ':' expression? [':' expression?]"));
+ }
+ { // expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression"));
+ expr_ty a;
+ if (
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// atom:
+// | NAME
+// | 'True'
+// | 'False'
+// | 'None'
+// | &STRING strings
+// | NUMBER
+// | &'(' (tuple | group | genexp)
+// | &'[' (list | listcomp)
+// | &'{' (dict | set | dictcomp | setcomp)
+// | '...'
+static expr_ty
+atom_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
+ expr_ty name_var;
+ if (
+ (name_var = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
+ _res = name_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
+ }
+ { // 'True'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 527)) // token='True'
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Constant ( Py_True , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'"));
+ }
+ { // 'False'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 528)) // token='False'
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Constant ( Py_False , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'"));
+ }
+ { // 'None'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 529)) // token='None'
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Constant ( Py_None , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'"));
+ }
+ { // &STRING strings
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&STRING strings"));
+ expr_ty strings_var;
+ if (
+ _PyPegen_lookahead(1, _PyPegen_string_token, p)
+ &&
+ (strings_var = strings_rule(p)) // strings
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&STRING strings"));
+ _res = strings_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&STRING strings"));
+ }
+ { // NUMBER
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER"));
+ expr_ty number_var;
+ if (
+ (number_var = _PyPegen_number_token(p)) // NUMBER
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER"));
+ _res = number_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER"));
+ }
+ { // &'(' (tuple | group | genexp)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)"));
+ void *_tmp_96_var;
+ if (
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='('
+ &&
+ (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)"));
+ _res = _tmp_96_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'(' (tuple | group | genexp)"));
+ }
+ { // &'[' (list | listcomp)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)"));
+ void *_tmp_97_var;
+ if (
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='['
+ &&
+ (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)"));
+ _res = _tmp_97_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'[' (list | listcomp)"));
+ }
+ { // &'{' (dict | set | dictcomp | setcomp)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
+ void *_tmp_98_var;
+ if (
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{'
+ &&
+ (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
+ _res = _tmp_98_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
+ }
+ { // '...'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 52)) // token='...'
+ )
+ {
+ D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// strings: STRING+
+static expr_ty
+strings_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, strings_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ { // STRING+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+"));
+ asdl_seq * a;
+ if (
+ (a = _loop1_99_rule(p)) // STRING+
+ )
+ {
+ D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+"));
+ _res = _PyPegen_concatenate_strings ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s strings[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING+"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, strings_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// list: '[' star_named_expressions? ']'
+static expr_ty
+list_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '[' star_named_expressions? ']'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (a = star_named_expressions_rule(p), 1) // star_named_expressions?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ )
+ {
+ D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_List ( a , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s list[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_named_expressions? ']'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension
+static expr_ty
+listcomp_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '[' named_expression for_if_clauses ']'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ asdl_seq* b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (a = named_expression_rule(p)) // named_expression
+ &&
+ (b = for_if_clauses_rule(p)) // for_if_clauses
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ )
+ {
+ D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_ListComp ( a , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' named_expression for_if_clauses ']'"));
+ }
+ { // invalid_comprehension
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
+ void *invalid_comprehension_var;
+ if (
+ (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
+ )
+ {
+ D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
+ _res = invalid_comprehension_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// tuple: '(' [star_named_expression ',' star_named_expressions?] ')'
+static expr_ty
+tuple_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '(' [star_named_expression ',' star_named_expressions?] ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?]
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( a , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s tuple[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// group: '(' (yield_expr | named_expression) ')'
+static expr_ty
+group_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ { // '(' (yield_expr | named_expression) ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = _tmp_101_rule(p)) // yield_expr | named_expression
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s group[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' (yield_expr | named_expression) ')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// genexp: '(' expression for_if_clauses ')' | invalid_comprehension
+static expr_ty
+genexp_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '(' expression for_if_clauses ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ asdl_seq* b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = expression_rule(p)) // expression
+ &&
+ (b = for_if_clauses_rule(p)) // for_if_clauses
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_GeneratorExp ( a , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' expression for_if_clauses ')'"));
+ }
+ { // invalid_comprehension
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
+ void *invalid_comprehension_var;
+ if (
+ (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
+ )
+ {
+ D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
+ _res = invalid_comprehension_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// set: '{' expressions_list '}'
+static expr_ty
+set_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '{' expressions_list '}'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq* a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 25)) // token='{'
+ &&
+ (a = expressions_list_rule(p)) // expressions_list
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
+ )
+ {
+ D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Set ( a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expressions_list '}'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension
+static expr_ty
+setcomp_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '{' expression for_if_clauses '}'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ asdl_seq* b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 25)) // token='{'
+ &&
+ (a = expression_rule(p)) // expression
+ &&
+ (b = for_if_clauses_rule(p)) // for_if_clauses
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
+ )
+ {
+ D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_SetComp ( a , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expression for_if_clauses '}'"));
+ }
+ { // invalid_comprehension
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
+ void *invalid_comprehension_var;
+ if (
+ (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
+ )
+ {
+ D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
+ _res = invalid_comprehension_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// dict: '{' double_starred_kvpairs? '}'
+static expr_ty
+dict_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '{' double_starred_kvpairs? '}'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> dict[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 25)) // token='{'
+ &&
+ (a = double_starred_kvpairs_rule(p), 1) // double_starred_kvpairs?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
+ )
+ {
+ D(fprintf(stderr, "%*c+ dict[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s dict[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' double_starred_kvpairs? '}'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// dictcomp: '{' kvpair for_if_clauses '}' | invalid_dict_comprehension
+static expr_ty
+dictcomp_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '{' kvpair for_if_clauses '}'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'"));
+ Token * _literal;
+ Token * _literal_1;
+ KeyValuePair* a;
+ asdl_seq* b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 25)) // token='{'
+ &&
+ (a = kvpair_rule(p)) // kvpair
+ &&
+ (b = for_if_clauses_rule(p)) // for_if_clauses
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
+ )
+ {
+ D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' kvpair for_if_clauses '}'"));
+ }
+ { // invalid_dict_comprehension
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension"));
+ void *invalid_dict_comprehension_var;
+ if (
+ (invalid_dict_comprehension_var = invalid_dict_comprehension_rule(p)) // invalid_dict_comprehension
+ )
+ {
+ D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension"));
+ _res = invalid_dict_comprehension_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_dict_comprehension"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// double_starred_kvpairs: ','.double_starred_kvpair+ ','?
+static asdl_seq*
+double_starred_kvpairs_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.double_starred_kvpair+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ if (
+ (a = _gather_102_rule(p)) // ','.double_starred_kvpair+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// double_starred_kvpair: '**' bitwise_or | kvpair
+static KeyValuePair*
+double_starred_kvpair_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ KeyValuePair* _res = NULL;
+ int _mark = p->mark;
+ { // '**' bitwise_or
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (a = bitwise_or_rule(p)) // bitwise_or
+ )
+ {
+ D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or"));
+ _res = _PyPegen_key_value_pair ( p , NULL , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or"));
+ }
+ { // kvpair
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kvpair"));
+ KeyValuePair* kvpair_var;
+ if (
+ (kvpair_var = kvpair_rule(p)) // kvpair
+ )
+ {
+ D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kvpair"));
+ _res = kvpair_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kvpair"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// kvpair: expression ':' expression
+static KeyValuePair*
+kvpair_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ KeyValuePair* _res = NULL;
+ int _mark = p->mark;
+ { // expression ':' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = expression_rule(p)) // expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression"));
+ _res = _PyPegen_key_value_pair ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kvpair[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// for_if_clauses: for_if_clause+
+static asdl_seq*
+for_if_clauses_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // for_if_clause+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+"));
+ asdl_seq * _loop1_104_var;
+ if (
+ (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+
+ )
+ {
+ D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+"));
+ _res = _loop1_104_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s for_if_clauses[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// for_if_clause:
+// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
+// | 'for' star_targets 'in' disjunction (('if' disjunction))*
+static comprehension_ty
+for_if_clause_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ comprehension_ty _res = NULL;
+ int _mark = p->mark;
+ { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*"));
+ Token * _keyword;
+ Token * _keyword_1;
+ expr_ty a;
+ Token * async_var;
+ expr_ty b;
+ asdl_seq * c;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ &&
+ (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
+ &&
+ (a = star_targets_rule(p)) // star_targets
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
+ &&
+ (b = disjunction_rule(p)) // disjunction
+ &&
+ (c = _loop0_105_rule(p)) // (('if' disjunction))*
+ )
+ {
+ D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*"));
+ _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*"));
+ }
+ { // 'for' star_targets 'in' disjunction (('if' disjunction))*
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*"));
+ Token * _keyword;
+ Token * _keyword_1;
+ expr_ty a;
+ expr_ty b;
+ asdl_seq * c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
+ &&
+ (a = star_targets_rule(p)) // star_targets
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
+ &&
+ (b = disjunction_rule(p)) // disjunction
+ &&
+ (c = _loop0_106_rule(p)) // (('if' disjunction))*
+ )
+ {
+ D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*"));
+ _res = _Py_comprehension ( a , b , c , 0 , p -> arena );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// yield_expr: 'yield' 'from' expression | 'yield' star_expressions?
+static expr_ty
+yield_expr_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // 'yield' 'from' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression"));
+ Token * _keyword;
+ Token * _keyword_1;
+ expr_ty a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 504)) // token='yield'
+ &&
+ (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from'
+ &&
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_YieldFrom ( a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' 'from' expression"));
+ }
+ { // 'yield' star_expressions?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?"));
+ Token * _keyword;
+ void *a;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 504)) // token='yield'
+ &&
+ (a = star_expressions_rule(p), 1) // star_expressions?
+ )
+ {
+ D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Yield ( a , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' star_expressions?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// arguments: args ','? &')' | incorrect_arguments
+static expr_ty
+arguments_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, arguments_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ { // args ','? &')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','? &')'"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ expr_ty a;
+ if (
+ (a = args_rule(p)) // args
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ &&
+ _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','? &')'"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','? &')'"));
+ }
+ { // incorrect_arguments
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "incorrect_arguments"));
+ void *incorrect_arguments_var;
+ if (
+ (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments
+ )
+ {
+ D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "incorrect_arguments"));
+ _res = incorrect_arguments_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "incorrect_arguments"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, arguments_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// args: starred_expression [',' args] | kwargs | named_expression [',' args]
+static expr_ty
+args_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // starred_expression [',' args]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]"));
+ expr_ty a;
+ void *b;
+ if (
+ (a = starred_expression_rule(p)) // starred_expression
+ &&
+ (b = _tmp_107_rule(p), 1) // [',' args]
+ )
+ {
+ D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression [',' args]"));
+ }
+ { // kwargs
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs"));
+ asdl_seq* a;
+ if (
+ (a = kwargs_rule(p)) // kwargs
+ )
+ {
+ D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs"));
+ }
+ { // named_expression [',' args]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]"));
+ expr_ty a;
+ void *b;
+ if (
+ (a = named_expression_rule(p)) // named_expression
+ &&
+ (b = _tmp_108_rule(p), 1) // [',' args]
+ )
+ {
+ D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression [',' args]"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// kwargs:
+// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
+// | ','.kwarg_or_starred+
+// | ','.kwarg_or_double_starred+
+static asdl_seq*
+kwargs_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+"));
+ Token * _literal;
+ asdl_seq * a;
+ asdl_seq * b;
+ if (
+ (a = _gather_109_rule(p)) // ','.kwarg_or_starred+
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+"));
+ _res = _PyPegen_join_sequences ( p , a , b );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+"));
+ }
+ { // ','.kwarg_or_starred+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+"));
+ asdl_seq * _gather_113_var;
+ if (
+ (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+"));
+ _res = _gather_113_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+"));
+ }
+ { // ','.kwarg_or_double_starred+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+"));
+ asdl_seq * _gather_115_var;
+ if (
+ (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+"));
+ _res = _gather_115_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_double_starred+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// starred_expression: '*' expression
+static expr_ty
+starred_expression_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '*' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Starred ( a , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s starred_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg
+static KeywordOrStarred*
+kwarg_or_starred_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ KeywordOrStarred* _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME '=' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression"));
+ }
+ { // starred_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression"));
+ expr_ty a;
+ if (
+ (a = starred_expression_rule(p)) // starred_expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression"));
+ _res = _PyPegen_keyword_or_starred ( p , a , 0 );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression"));
+ }
+ { // invalid_kwarg
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
+ void *invalid_kwarg_var;
+ if (
+ (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
+ _res = invalid_kwarg_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg
+static KeywordOrStarred*
+kwarg_or_double_starred_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ KeywordOrStarred* _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME '=' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ &&
+ (b = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression"));
+ }
+ { // '**' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (a = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression"));
+ }
+ { // invalid_kwarg
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
+ void *invalid_kwarg_var;
+ if (
+ (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
+ )
+ {
+ D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
+ _res = invalid_kwarg_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// star_targets: star_target !',' | star_target ((',' star_target))* ','?
+static expr_ty
+star_targets_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // star_target !','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target !','"));
+ expr_ty a;
+ if (
+ (a = star_target_rule(p)) // star_target
+ &&
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target !','"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target !','"));
+ }
+ { // star_target ((',' star_target))* ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ expr_ty a;
+ asdl_seq * b;
+ if (
+ (a = star_target_rule(p)) // star_target
+ &&
+ (b = _loop0_117_rule(p)) // ((',' star_target))*
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))* ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// star_targets_seq: ','.star_target+ ','?
+static asdl_seq*
+star_targets_seq_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.star_target+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_targets_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ if (
+ (a = _gather_118_rule(p)) // ','.star_target+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_targets_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_targets_seq[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_target+ ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// star_target:
+// | '*' (!'*' star_target)
+// | t_primary '.' NAME !t_lookahead
+// | t_primary '[' slices ']' !t_lookahead
+// | star_atom
+static expr_ty
+star_target_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, star_target_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // '*' (!'*' star_target)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)"));
+ Token * _literal;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (a = _tmp_120_rule(p)) // !'*' star_target
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (!'*' star_target)"));
+ }
+ { // t_primary '.' NAME !t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ &&
+ (b = _PyPegen_name_token(p)) // NAME
+ &&
+ _PyPegen_lookahead(0, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ }
+ { // t_primary '[' slices ']' !t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (b = slices_rule(p)) // slices
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ &&
+ _PyPegen_lookahead(0, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Subscript ( a , b , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ }
+ { // star_atom
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_atom"));
+ expr_ty star_atom_var;
+ if (
+ (star_atom_var = star_atom_rule(p)) // star_atom
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_atom"));
+ _res = star_atom_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_atom"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, star_target_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// star_atom:
+// | NAME
+// | '(' star_target ')'
+// | '(' star_targets_seq? ')'
+// | '[' star_targets_seq? ']'
+static expr_ty
+star_atom_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
+ expr_ty a;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
+ _res = _PyPegen_set_expr_context ( p , a , Store );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
+ }
+ { // '(' star_target ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = star_target_rule(p)) // star_target
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'"));
+ _res = _PyPegen_set_expr_context ( p , a , Store );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_target ')'"));
+ }
+ { // '(' star_targets_seq? ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = star_targets_seq_rule(p), 1) // star_targets_seq?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( a , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_targets_seq? ')'"));
+ }
+ { // '[' star_targets_seq? ']'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (a = star_targets_seq_rule(p), 1) // star_targets_seq?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ )
+ {
+ D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_List ( a , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_targets_seq? ']'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// single_target: single_subscript_attribute_target | NAME | '(' single_target ')'
+static expr_ty
+single_target_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ { // single_subscript_attribute_target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
+ expr_ty single_subscript_attribute_target_var;
+ if (
+ (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target
+ )
+ {
+ D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
+ _res = single_subscript_attribute_target_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target"));
+ }
+ { // NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
+ expr_ty a;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
+ _res = _PyPegen_set_expr_context ( p , a , Store );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
+ }
+ { // '(' single_target ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = single_target_rule(p)) // single_target
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// single_subscript_attribute_target:
+// | t_primary '.' NAME !t_lookahead
+// | t_primary '[' slices ']' !t_lookahead
+static expr_ty
+single_subscript_attribute_target_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // t_primary '.' NAME !t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ &&
+ (b = _PyPegen_name_token(p)) // NAME
+ &&
+ _PyPegen_lookahead(0, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ }
+ { // t_primary '[' slices ']' !t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (b = slices_rule(p)) // slices
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ &&
+ _PyPegen_lookahead(0, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Subscript ( a , b , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// del_targets: ','.del_target+ ','?
+static asdl_seq*
+del_targets_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.del_target+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ if (
+ (a = _gather_121_rule(p)) // ','.del_target+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// del_target:
+// | t_primary '.' NAME &del_target_end
+// | t_primary '[' slices ']' &del_target_end
+// | del_t_atom
+static expr_ty
+del_target_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, del_target_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // t_primary '.' NAME &del_target_end
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ &&
+ (b = _PyPegen_name_token(p)) // NAME
+ &&
+ _PyPegen_lookahead(1, del_target_end_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &del_target_end"));
+ }
+ { // t_primary '[' slices ']' &del_target_end
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (b = slices_rule(p)) // slices
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ &&
+ _PyPegen_lookahead(1, del_target_end_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Subscript ( a , b , Del , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &del_target_end"));
+ }
+ { // del_t_atom
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_t_atom"));
+ expr_ty del_t_atom_var;
+ if (
+ (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_t_atom"));
+ _res = del_t_atom_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_t_atom"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, del_target_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// del_t_atom:
+// | NAME &del_target_end
+// | '(' del_target ')'
+// | '(' del_targets? ')'
+// | '[' del_targets? ']'
+// | invalid_del_target
+static expr_ty
+del_t_atom_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME &del_target_end
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end"));
+ expr_ty a;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ &&
+ _PyPegen_lookahead(1, del_target_end_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end"));
+ _res = _PyPegen_set_expr_context ( p , a , Del );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME &del_target_end"));
+ }
+ { // '(' del_target ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = del_target_rule(p)) // del_target
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'"));
+ _res = _PyPegen_set_expr_context ( p , a , Del );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_target ')'"));
+ }
+ { // '(' del_targets? ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = del_targets_rule(p), 1) // del_targets?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( a , Del , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_targets? ')'"));
+ }
+ { // '[' del_targets? ']'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (a = del_targets_rule(p), 1) // del_targets?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_List ( a , Del , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' del_targets? ']'"));
+ }
+ { // invalid_del_target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_del_target"));
+ void *invalid_del_target_var;
+ if (
+ (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_del_target"));
+ _res = invalid_del_target_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_del_target"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// del_target_end: ')' | ']' | ',' | ';' | NEWLINE
+static void *
+del_target_end_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
+ }
+ { // ']'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "']'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 10)) // token=']'
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "']'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "']'"));
+ }
+ { // ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','"));
+ }
+ { // ';'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 13)) // token=';'
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'"));
+ }
+ { // NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
+ Token * newline_var;
+ if (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
+ _res = newline_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// targets: ','.target+ ','?
+static asdl_seq*
+targets_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq* _res = NULL;
+ int _mark = p->mark;
+ { // ','.target+ ','?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.target+ ','?"));
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ asdl_seq * a;
+ if (
+ (a = _gather_123_rule(p)) // ','.target+
+ &&
+ (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
+ )
+ {
+ D(fprintf(stderr, "%*c+ targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.target+ ','?"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.target+ ','?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// target:
+// | t_primary '.' NAME !t_lookahead
+// | t_primary '[' slices ']' !t_lookahead
+// | t_atom
+static expr_ty
+target_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, target_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // t_primary '.' NAME !t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ &&
+ (b = _PyPegen_name_token(p)) // NAME
+ &&
+ _PyPegen_lookahead(0, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
+ }
+ { // t_primary '[' slices ']' !t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (b = slices_rule(p)) // slices
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ &&
+ _PyPegen_lookahead(0, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Subscript ( a , b , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
+ }
+ { // t_atom
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_atom"));
+ expr_ty t_atom_var;
+ if (
+ (t_atom_var = t_atom_rule(p)) // t_atom
+ )
+ {
+ D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_atom"));
+ _res = t_atom_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_atom"));
+ }
+ _res = NULL;
+ done:
+ _PyPegen_insert_memo(p, _mark, target_type, _res);
+ D(p->level--);
+ return _res;
+}
+
+// Left-recursive
+// t_primary:
+// | t_primary '.' NAME &t_lookahead
+// | t_primary '[' slices ']' &t_lookahead
+// | t_primary genexp &t_lookahead
+// | t_primary '(' arguments? ')' &t_lookahead
+// | atom &t_lookahead
+static expr_ty t_primary_raw(Parser *);
+static expr_ty
+t_primary_rule(Parser *p)
+{
+ D(p->level++);
+ expr_ty _res = NULL;
+ if (_PyPegen_is_memoized(p, t_primary_type, &_res)) {
+ D(p->level--);
+ return _res;
+ }
+ int _mark = p->mark;
+ int _resmark = p->mark;
+ while (1) {
+ int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res);
+ if (tmpvar_8) {
+ D(p->level--);
+ return _res;
+ }
+ p->mark = _mark;
+ void *_raw = t_primary_raw(p);
+ if (_raw == NULL || p->mark <= _resmark)
+ break;
+ _resmark = p->mark;
+ _res = _raw;
+ }
+ p->mark = _resmark;
+ D(p->level--);
+ return _res;
+}
+static expr_ty
+t_primary_raw(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // t_primary '.' NAME &t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ &&
+ (b = _PyPegen_name_token(p)) // NAME
+ &&
+ _PyPegen_lookahead(1, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &t_lookahead"));
+ }
+ { // t_primary '[' slices ']' &t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (b = slices_rule(p)) // slices
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ &&
+ _PyPegen_lookahead(1, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Subscript ( a , b , Load , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &t_lookahead"));
+ }
+ { // t_primary genexp &t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead"));
+ expr_ty a;
+ expr_ty b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (b = genexp_rule(p)) // genexp
+ &&
+ _PyPegen_lookahead(1, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary genexp &t_lookahead"));
+ }
+ { // t_primary '(' arguments? ')' &t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ void *b;
+ if (
+ (a = t_primary_rule(p)) // t_primary
+ &&
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (b = arguments_rule(p), 1) // arguments?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ &&
+ _PyPegen_lookahead(1, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead"));
+ }
+ { // atom &t_lookahead
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead"));
+ expr_ty a;
+ if (
+ (a = atom_rule(p)) // atom
+ &&
+ _PyPegen_lookahead(1, t_lookahead_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead"));
+ _res = a;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom &t_lookahead"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// t_lookahead: '(' | '[' | '.'
+static void *
+t_lookahead_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '('
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('"));
+ }
+ { // '['
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['"));
+ }
+ { // '.'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']'
+static expr_ty
+t_atom_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ expr_ty _res = NULL;
+ int _mark = p->mark;
+ if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ int _start_lineno = p->tokens[_mark]->lineno;
+ 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
+ { // NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
+ expr_ty a;
+ if (
+ (a = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
+ _res = _PyPegen_set_expr_context ( p , a , Store );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
+ }
+ { // '(' target ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty a;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (a = target_rule(p)) // target
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target ')'"));
+ _res = _PyPegen_set_expr_context ( p , a , Store );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target ')'"));
+ }
+ { // '(' targets? ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (b = targets_rule(p), 1) // targets?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_Tuple ( b , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' targets? ')'"));
+ }
+ { // '[' targets? ']'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ &&
+ (b = targets_rule(p), 1) // targets?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
+ )
+ {
+ D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'"));
+ Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
+ if (_token == NULL) {
+ D(p->level--);
+ return NULL;
+ }
+ int _end_lineno = _token->end_lineno;
+ UNUSED(_end_lineno); // Only used by EXTRA macro
+ int _end_col_offset = _token->end_col_offset;
+ UNUSED(_end_col_offset); // Only used by EXTRA macro
+ _res = _Py_List ( b , Store , EXTRA );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' targets? ']'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// incorrect_arguments:
+// | args ',' '*'
+// | expression for_if_clauses ',' [args | expression for_if_clauses]
+// | args for_if_clauses
+// | args ',' expression for_if_clauses
+// | args ',' args
+static void *
+incorrect_arguments_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // args ',' '*'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' '*'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty args_var;
+ if (
+ (args_var = args_rule(p)) // args
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
+ )
+ {
+ D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' '*'"));
+ _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' '*'"));
+ }
+ { // expression for_if_clauses ',' [args | expression for_if_clauses]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
+ Token * _literal;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ expr_ty a;
+ asdl_seq* for_if_clauses_var;
+ if (
+ (a = expression_rule(p)) // expression
+ &&
+ (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses]
+ )
+ {
+ D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
+ }
+ { // args for_if_clauses
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses"));
+ expr_ty a;
+ asdl_seq* for_if_clauses_var;
+ if (
+ (a = args_rule(p)) // args
+ &&
+ (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
+ )
+ {
+ D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses"));
+ _res = _PyPegen_nonparen_genexp_in_call ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses"));
+ }
+ { // args ',' expression for_if_clauses
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty args_var;
+ asdl_seq* for_if_clauses_var;
+ if (
+ (args_var = args_rule(p)) // args
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (a = expression_rule(p)) // expression
+ &&
+ (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
+ )
+ {
+ D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses"));
+ }
+ { // args ',' args
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty args_var;
+ if (
+ (a = args_rule(p)) // args
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (args_var = args_rule(p)) // args
+ )
+ {
+ D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args"));
+ _res = _PyPegen_arguments_parsing_error ( p , a );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_kwarg: expression '='
+static void *
+invalid_kwarg_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // expression '='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression '='"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (a = expression_rule(p)) // expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression '='"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression cannot contain assignment, perhaps you meant \"==\"?" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression '='"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_named_expression: expression ':=' expression
+static void *
+invalid_named_expression_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // expression ':=' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression"));
+ Token * _literal;
+ expr_ty a;
+ expr_ty expression_var;
+ if (
+ (a = expression_rule(p)) // expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 53)) // token=':='
+ &&
+ (expression_var = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_assignment:
+// | list ':'
+// | tuple ':'
+// | star_named_expression ',' star_named_expressions* ':'
+// | expression ':' expression ['=' annotated_rhs]
+// | ((star_targets '='))* star_expressions '='
+// | ((star_targets '='))* yield_expr '='
+// | star_expressions augassign (yield_expr | star_expressions)
+static void *
+invalid_assignment_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // list ':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list ':'"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (a = list_rule(p)) // list
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list ':'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not list) can be annotated" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list ':'"));
+ }
+ { // tuple ':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple ':'"));
+ Token * _literal;
+ expr_ty a;
+ if (
+ (a = tuple_rule(p)) // tuple
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple ':'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple ':'"));
+ }
+ { // star_named_expression ',' star_named_expressions* ':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'"));
+ Token * _literal;
+ Token * _literal_1;
+ asdl_seq * _loop0_126_var;
+ expr_ty a;
+ if (
+ (a = star_named_expression_rule(p)) // star_named_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_loop0_126_var = _loop0_126_rule(p)) // star_named_expressions*
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'"));
+ }
+ { // expression ':' expression ['=' annotated_rhs]
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]"));
+ Token * _literal;
+ void *_opt_var;
+ UNUSED(_opt_var); // Silence compiler warnings
+ expr_ty a;
+ expr_ty expression_var;
+ if (
+ (a = expression_rule(p)) // expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (expression_var = expression_rule(p)) // expression
+ &&
+ (_opt_var = _tmp_127_rule(p), 1) // ['=' annotated_rhs]
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression ['=' annotated_rhs]"));
+ }
+ { // ((star_targets '='))* star_expressions '='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='"));
+ Token * _literal;
+ asdl_seq * _loop0_128_var;
+ expr_ty a;
+ if (
+ (_loop0_128_var = _loop0_128_rule(p)) // ((star_targets '='))*
+ &&
+ (a = star_expressions_rule(p)) // star_expressions
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( _PyPegen_get_invalid_target ( a ) , "cannot assign to %s" , _PyPegen_get_expr_name ( _PyPegen_get_invalid_target ( a ) ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* star_expressions '='"));
+ }
+ { // ((star_targets '='))* yield_expr '='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='"));
+ Token * _literal;
+ asdl_seq * _loop0_129_var;
+ expr_ty a;
+ if (
+ (_loop0_129_var = _loop0_129_rule(p)) // ((star_targets '='))*
+ &&
+ (a = yield_expr_rule(p)) // yield_expr
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "assignment to yield expression not possible" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* yield_expr '='"));
+ }
+ { // star_expressions augassign (yield_expr | star_expressions)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
+ void *_tmp_130_var;
+ expr_ty a;
+ AugOperator* augassign_var;
+ if (
+ (a = star_expressions_rule(p)) // star_expressions
+ &&
+ (augassign_var = augassign_rule(p)) // augassign
+ &&
+ (_tmp_130_var = _tmp_130_rule(p)) // yield_expr | star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_block: NEWLINE !INDENT
+static void *
+invalid_block_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // NEWLINE !INDENT
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT"));
+ Token * newline_var;
+ if (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ &&
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT"));
+ _res = RAISE_INDENTATION_ERROR ( "expected an indented block" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_block[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_comprehension: ('[' | '(' | '{') starred_expression for_if_clauses
+static void *
+invalid_comprehension_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ('[' | '(' | '{') starred_expression for_if_clauses
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses"));
+ void *_tmp_131_var;
+ expr_ty a;
+ asdl_seq* for_if_clauses_var;
+ if (
+ (_tmp_131_var = _tmp_131_rule(p)) // '[' | '(' | '{'
+ &&
+ (a = starred_expression_rule(p)) // starred_expression
+ &&
+ (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "iterable unpacking cannot be used in comprehension" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_dict_comprehension: '{' '**' bitwise_or for_if_clauses '}'
+static void *
+invalid_dict_comprehension_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '{' '**' bitwise_or for_if_clauses '}'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_dict_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'"));
+ Token * _literal;
+ Token * _literal_1;
+ Token * a;
+ expr_ty bitwise_or_var;
+ asdl_seq* for_if_clauses_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 25)) // token='{'
+ &&
+ (a = _PyPegen_expect_token(p, 35)) // token='**'
+ &&
+ (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or
+ &&
+ (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_dict_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "dict unpacking cannot be used in dict comprehension" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_dict_comprehension[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_parameters:
+// | param_no_default* (slash_with_default | param_with_default+) param_no_default
+static void *
+invalid_parameters_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // param_no_default* (slash_with_default | param_with_default+) param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default"));
+ asdl_seq * _loop0_132_var;
+ void *_tmp_133_var;
+ arg_ty param_no_default_var;
+ if (
+ (_loop0_132_var = _loop0_132_rule(p)) // param_no_default*
+ &&
+ (_tmp_133_var = _tmp_133_rule(p)) // slash_with_default | param_with_default+
+ &&
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default"));
+ _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_lambda_parameters:
+// | lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default
+static void *
+invalid_lambda_parameters_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default"));
+ asdl_seq * _loop0_134_var;
+ void *_tmp_135_var;
+ arg_ty lambda_param_no_default_var;
+ if (
+ (_loop0_134_var = _loop0_134_rule(p)) // lambda_param_no_default*
+ &&
+ (_tmp_135_var = _tmp_135_rule(p)) // lambda_slash_with_default | lambda_param_with_default+
+ &&
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default"));
+ _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT
+static void *
+invalid_star_etc_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '*' (')' | ',' (')' | '**'))
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
+ Token * _literal;
+ void *_tmp_136_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (_tmp_136_var = _tmp_136_rule(p)) // ')' | ',' (')' | '**')
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
+ _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
+ }
+ { // '*' ',' TYPE_COMMENT
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT"));
+ Token * _literal;
+ Token * _literal_1;
+ Token * type_comment_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT"));
+ _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_lambda_star_etc: '*' (':' | ',' (':' | '**'))
+static void *
+invalid_lambda_star_etc_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '*' (':' | ',' (':' | '**'))
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
+ Token * _literal;
+ void *_tmp_137_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 16)) // token='*'
+ &&
+ (_tmp_137_var = _tmp_137_rule(p)) // ':' | ',' (':' | '**')
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
+ _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
+static void *
+invalid_double_type_comments_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT"));
+ Token * indent_var;
+ Token * newline_var;
+ Token * newline_var_1;
+ Token * type_comment_var;
+ Token * type_comment_var_1;
+ if (
+ (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
+ &&
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ &&
+ (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
+ &&
+ (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ &&
+ (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_double_type_comments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT"));
+ _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_double_type_comments[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_del_target: star_expression &del_target_end
+static void *
+invalid_del_target_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // star_expression &del_target_end
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end"));
+ expr_ty a;
+ if (
+ (a = star_expression_rule(p)) // star_expression
+ &&
+ _PyPegen_lookahead(1, del_target_end_rule, p)
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end"));
+ _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot delete %s" , _PyPegen_get_expr_name ( a ) );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_del_target[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression &del_target_end"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// invalid_import_from_targets: import_from_as_names ','
+static void *
+invalid_import_from_targets_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // import_from_as_names ','
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','"));
+ Token * _literal;
+ asdl_seq* import_from_as_names_var;
+ if (
+ (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ )
+ {
+ D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','"));
+ _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ','"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_1: NEWLINE
+static asdl_seq *
+_loop0_1_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
+ Token * newline_var;
+ while (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ _res = newline_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
}
- return E_OK;
+ _children = _new_children;
}
+ _children[_n++] = _res;
+ _mark = p->mark;
}
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_1[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq);
+ D(p->level--);
+ return _seq;
+}
- if (s->s_accept) {
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
-#if 0
- if (d->d_name[0] == 'i' &&
- strcmp(d->d_name, "import_stmt") == 0)
- future_hack(ps);
-#endif
-#endif
- /* Pop this dfa and try again */
- s_pop(&ps->p_stack);
- D(printf(" Pop ...\n"));
- if (s_empty(&ps->p_stack)) {
- D(printf(" Error: bottom of stack.\n"));
- return E_SYNTAX;
+// _loop0_2: NEWLINE
+static asdl_seq *
+_loop0_2_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
+ Token * newline_var;
+ while (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ _res = newline_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_2[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_4: ',' expression
+static asdl_seq *
+_loop0_4_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = expression_rule(p)) // expression
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_4[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_3: expression _loop0_4
+static asdl_seq *
+_gather_3_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // expression _loop0_4
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_4"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = expression_rule(p)) // expression
+ &&
+ (seq = _loop0_4_rule(p)) // _loop0_4
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_3[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_4"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_3[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_4"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_6: ',' expression
+static asdl_seq *
+_loop0_6_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = expression_rule(p)) // expression
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_6[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_5: expression _loop0_6
+static asdl_seq *
+_gather_5_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // expression _loop0_6
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_6"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = expression_rule(p)) // expression
+ &&
+ (seq = _loop0_6_rule(p)) // _loop0_6
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_6"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_5[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_6"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_8: ',' expression
+static asdl_seq *
+_loop0_8_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = expression_rule(p)) // expression
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_8[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_7: expression _loop0_8
+static asdl_seq *
+_gather_7_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // expression _loop0_8
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_8"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = expression_rule(p)) // expression
+ &&
+ (seq = _loop0_8_rule(p)) // _loop0_8
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_8"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_7[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_8"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_10: ',' expression
+static asdl_seq *
+_loop0_10_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = expression_rule(p)) // expression
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_10[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_9: expression _loop0_10
+static asdl_seq *
+_gather_9_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // expression _loop0_10
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_10"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = expression_rule(p)) // expression
+ &&
+ (seq = _loop0_10_rule(p)) // _loop0_10
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_10"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_9[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_10"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop1_11: statement
+static asdl_seq *
+_loop1_11_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // statement
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement"));
+ asdl_seq* statement_var;
+ while (
+ (statement_var = statement_rule(p)) // statement
+ )
+ {
+ _res = statement_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_11[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_13: ';' small_stmt
+static asdl_seq *
+_loop0_13_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ';' small_stmt
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt"));
+ Token * _literal;
+ stmt_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 13)) // token=';'
+ &&
+ (elem = small_stmt_rule(p)) // small_stmt
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_12: small_stmt _loop0_13
+static asdl_seq *
+_gather_12_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // small_stmt _loop0_13
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
+ stmt_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = small_stmt_rule(p)) // small_stmt
+ &&
+ (seq = _loop0_13_rule(p)) // _loop0_13
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_14: 'import' | 'from'
+static void *
+_tmp_14_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'import'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 513)) // token='import'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'"));
+ _res = _keyword;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'"));
+ }
+ { // 'from'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'"));
+ _res = _keyword;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_15: 'def' | '@' | ASYNC
+static void *
+_tmp_15_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'def'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 522)) // token='def'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'"));
+ _res = _keyword;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'"));
+ }
+ { // '@'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 49)) // token='@'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'"));
+ }
+ { // ASYNC
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC"));
+ Token * async_var;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC"));
+ _res = async_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_16: 'class' | '@'
+static void *
+_tmp_16_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'class'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 523)) // token='class'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'"));
+ _res = _keyword;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'"));
+ }
+ { // '@'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 49)) // token='@'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_17: 'with' | ASYNC
+static void *
+_tmp_17_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'with'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'"));
+ _res = _keyword;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'"));
+ }
+ { // ASYNC
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC"));
+ Token * async_var;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC"));
+ _res = async_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_18: 'for' | ASYNC
+static void *
+_tmp_18_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'for'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'"));
+ Token * _keyword;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'"));
+ _res = _keyword;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'"));
+ }
+ { // ASYNC
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC"));
+ Token * async_var;
+ if (
+ (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC"));
+ _res = async_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_19: '=' annotated_rhs
+static void *
+_tmp_19_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '=' annotated_rhs
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
+ Token * _literal;
+ expr_ty d;
+ if (
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ &&
+ (d = annotated_rhs_rule(p)) // annotated_rhs
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_19[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
+ _res = d;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_19[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_20: '(' single_target ')' | single_subscript_attribute_target
+static void *
+_tmp_20_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '(' single_target ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ expr_ty b;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (b = single_target_rule(p)) // single_target
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
+ _res = b;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'"));
+ }
+ { // single_subscript_attribute_target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
+ expr_ty single_subscript_attribute_target_var;
+ if (
+ (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
+ _res = single_subscript_attribute_target_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_21: '=' annotated_rhs
+static void *
+_tmp_21_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '=' annotated_rhs
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
+ Token * _literal;
+ expr_ty d;
+ if (
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ &&
+ (d = annotated_rhs_rule(p)) // annotated_rhs
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
+ _res = d;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop1_22: (star_targets '=')
+static asdl_seq *
+_loop1_22_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // (star_targets '=')
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
+ void *_tmp_138_var;
+ while (
+ (_tmp_138_var = _tmp_138_rule(p)) // star_targets '='
+ )
+ {
+ _res = _tmp_138_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
}
- continue;
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_22[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_23: yield_expr | star_expressions
+static void *
+_tmp_23_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // yield_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ expr_ty yield_expr_var;
+ if (
+ (yield_expr_var = yield_expr_rule(p)) // yield_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ _res = yield_expr_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
+ }
+ { // star_expressions
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ expr_ty star_expressions_var;
+ if (
+ (star_expressions_var = star_expressions_rule(p)) // star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ _res = star_expressions_var;
+ goto done;
}
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- /* Stuck, report syntax error */
- D(printf(" Error.\n"));
- if (expected_ret) {
- if (s->s_lower == s->s_upper - 1) {
- /* Only one possible expected token */
- *expected_ret = ps->p_grammar->
- g_ll.ll_label[s->s_lower].lb_type;
+// _tmp_24: yield_expr | star_expressions
+static void *
+_tmp_24_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // yield_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ expr_ty yield_expr_var;
+ if (
+ (yield_expr_var = yield_expr_rule(p)) // yield_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ _res = yield_expr_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
+ }
+ { // star_expressions
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ expr_ty star_expressions_var;
+ if (
+ (star_expressions_var = star_expressions_rule(p)) // star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ _res = star_expressions_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_26: ',' NAME
+static asdl_seq *
+_loop0_26_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
}
- else
- *expected_ret = -1;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
}
- return E_SYNTAX;
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_26[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME"));
}
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq);
+ D(p->level--);
+ return _seq;
}
+// _gather_25: NAME _loop0_26
+static asdl_seq *
+_gather_25_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // NAME _loop0_26
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = _PyPegen_name_token(p)) // NAME
+ &&
+ (seq = _loop0_26_rule(p)) // _loop0_26
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-#ifdef Py_DEBUG
+// _loop0_28: ',' NAME
+static asdl_seq *
+_loop0_28_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq);
+ D(p->level--);
+ return _seq;
+}
-/* DEBUG OUTPUT */
+// _gather_27: NAME _loop0_28
+static asdl_seq *
+_gather_27_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // NAME _loop0_28
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = _PyPegen_name_token(p)) // NAME
+ &&
+ (seq = _loop0_28_rule(p)) // _loop0_28
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-void
-dumptree(grammar *g, node *n)
+// _tmp_29: ',' expression
+static void *
+_tmp_29_rule(Parser *p)
{
- int i;
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ',' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ Token * _literal;
+ expr_ty z;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (z = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_29[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
- if (n == NULL)
- printf("NIL");
- else {
- label l;
- l.lb_type = TYPE(n);
- l.lb_str = STR(n);
- printf("%s", PyGrammar_LabelRepr(&l));
- if (ISNONTERMINAL(TYPE(n))) {
- printf("(");
- for (i = 0; i < NCH(n); i++) {
- if (i > 0)
- printf(",");
- dumptree(g, CHILD(n, i));
+// _loop0_30: ('.' | '...')
+static asdl_seq *
+_loop0_30_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ('.' | '...')
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')"));
+ void *_tmp_139_var;
+ while (
+ (_tmp_139_var = _tmp_139_rule(p)) // '.' | '...'
+ )
+ {
+ _res = _tmp_139_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
}
- printf(")");
+ _children[_n++] = _res;
+ _mark = p->mark;
}
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_30[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
}
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq);
+ D(p->level--);
+ return _seq;
}
-void
-showtree(grammar *g, node *n)
+// _loop1_31: ('.' | '...')
+static asdl_seq *
+_loop1_31_rule(Parser *p)
{
- int i;
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ('.' | '...')
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')"));
+ void *_tmp_140_var;
+ while (
+ (_tmp_140_var = _tmp_140_rule(p)) // '.' | '...'
+ )
+ {
+ _res = _tmp_140_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_31[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq);
+ D(p->level--);
+ return _seq;
+}
- if (n == NULL)
- return;
- if (ISNONTERMINAL(TYPE(n))) {
- for (i = 0; i < NCH(n); i++)
- showtree(g, CHILD(n, i));
+// _loop0_33: ',' import_from_as_name
+static asdl_seq *
+_loop0_33_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
}
- else if (ISTERMINAL(TYPE(n))) {
- printf("%s", _PyParser_TokenNames[TYPE(n)]);
- if (TYPE(n) == NUMBER || TYPE(n) == NAME)
- printf("(%s)", STR(n));
- printf(" ");
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
}
- else
- printf("? ");
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' import_from_as_name
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name"));
+ Token * _literal;
+ alias_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = import_from_as_name_rule(p)) // import_from_as_name
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq);
+ D(p->level--);
+ return _seq;
}
-void
-printtree(parser_state *ps)
+// _gather_32: import_from_as_name _loop0_33
+static asdl_seq *
+_gather_32_rule(Parser *p)
{
- if (Py_DebugFlag) {
- printf("Parse tree:\n");
- dumptree(ps->p_grammar, ps->p_tree);
- printf("\n");
- printf("Tokens:\n");
- showtree(ps->p_grammar, ps->p_tree);
- printf("\n");
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
}
- printf("Listing:\n");
- PyNode_ListTree(ps->p_tree);
- printf("\n");
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // import_from_as_name _loop0_33
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33"));
+ alias_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = import_from_as_name_rule(p)) // import_from_as_name
+ &&
+ (seq = _loop0_33_rule(p)) // _loop0_33
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_32[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_32[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_33"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
}
-#endif /* Py_DEBUG */
+// _tmp_34: 'as' NAME
+static void *
+_tmp_34_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'as' NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
+ Token * _keyword;
+ expr_ty z;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
+ &&
+ (z = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_34[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-/*
+// _loop0_36: ',' dotted_as_name
+static asdl_seq *
+_loop0_36_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' dotted_as_name
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name"));
+ Token * _literal;
+ alias_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = dotted_as_name_rule(p)) // dotted_as_name
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_36[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq);
+ D(p->level--);
+ return _seq;
+}
-Description
------------
+// _gather_35: dotted_as_name _loop0_36
+static asdl_seq *
+_gather_35_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // dotted_as_name _loop0_36
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36"));
+ alias_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = dotted_as_name_rule(p)) // dotted_as_name
+ &&
+ (seq = _loop0_36_rule(p)) // _loop0_36
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_35[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_36"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-The parser's interface is different than usual: the function addtoken()
-must be called for each token in the input. This makes it possible to
-turn it into an incremental parsing system later. The parsing system
-constructs a parse tree as it goes.
+// _tmp_37: 'as' NAME
+static void *
+_tmp_37_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'as' NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
+ Token * _keyword;
+ expr_ty z;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
+ &&
+ (z = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_37[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_37[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-A parsing rule is represented as a Deterministic Finite-state Automaton
-(DFA). A node in a DFA represents a state of the parser; an arc represents
-a transition. Transitions are either labeled with terminal symbols or
-with non-terminals. When the parser decides to follow an arc labeled
-with a non-terminal, it is invoked recursively with the DFA representing
-the parsing rule for that as its initial state; when that DFA accepts,
-the parser that invoked it continues. The parse tree constructed by the
-recursively called parser is inserted as a child in the current parse tree.
+// _loop0_39: ',' with_item
+static asdl_seq *
+_loop0_39_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' with_item
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
+ Token * _literal;
+ withitem_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = with_item_rule(p)) // with_item
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq);
+ D(p->level--);
+ return _seq;
+}
-The DFA's can be constructed automatically from a more conventional
-language description. An extended LL(1) grammar (ELL(1)) is suitable.
-Certain restrictions make the parser's life easier: rules that can produce
-the empty string should be outlawed (there are other ways to put loops
-or optional parts in the language). To avoid the need to construct
-FIRST sets, we can require that all but the last alternative of a rule
-(really: arc going out of a DFA's state) must begin with a terminal
-symbol.
+// _gather_38: with_item _loop0_39
+static asdl_seq *
+_gather_38_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // with_item _loop0_39
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39"));
+ withitem_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = with_item_rule(p)) // with_item
+ &&
+ (seq = _loop0_39_rule(p)) // _loop0_39
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_38[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_39"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-As an example, consider this grammar:
+// _loop0_41: ',' with_item
+static asdl_seq *
+_loop0_41_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' with_item
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
+ Token * _literal;
+ withitem_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = with_item_rule(p)) // with_item
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_41[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq);
+ D(p->level--);
+ return _seq;
+}
-expr: term (OP term)*
-term: CONSTANT | '(' expr ')'
+// _gather_40: with_item _loop0_41
+static asdl_seq *
+_gather_40_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // with_item _loop0_41
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41"));
+ withitem_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = with_item_rule(p)) // with_item
+ &&
+ (seq = _loop0_41_rule(p)) // _loop0_41
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_41"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-The DFA corresponding to the rule for expr is:
+// _loop0_43: ',' with_item
+static asdl_seq *
+_loop0_43_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' with_item
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
+ Token * _literal;
+ withitem_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = with_item_rule(p)) // with_item
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_43[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_42: with_item _loop0_43
+static asdl_seq *
+_gather_42_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // with_item _loop0_43
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43"));
+ withitem_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = with_item_rule(p)) // with_item
+ &&
+ (seq = _loop0_43_rule(p)) // _loop0_43
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_42[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_43"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_45: ',' with_item
+static asdl_seq *
+_loop0_45_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' with_item
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
+ Token * _literal;
+ withitem_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = with_item_rule(p)) // with_item
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_45[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_44: with_item _loop0_45
+static asdl_seq *
+_gather_44_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // with_item _loop0_45
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45"));
+ withitem_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = with_item_rule(p)) // with_item
+ &&
+ (seq = _loop0_45_rule(p)) // _loop0_45
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_44[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_44[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_45"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-------->.---term-->.------->
- ^ |
- | |
- \----OP----/
+// _tmp_46: 'as' target
+static void *
+_tmp_46_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'as' target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' target"));
+ Token * _keyword;
+ expr_ty t;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
+ &&
+ (t = target_rule(p)) // target
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_46[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' target"));
+ _res = t;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_46[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' target"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
-The parse tree generated for the input a+b is:
+// _loop1_47: except_block
+static asdl_seq *
+_loop1_47_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // except_block
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block"));
+ excepthandler_ty except_block_var;
+ while (
+ (except_block_var = except_block_rule(p)) // except_block
+ )
+ {
+ _res = except_block_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_47[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq);
+ D(p->level--);
+ return _seq;
+}
-(expr: (term: (NAME: a)), (OP: +), (term: (NAME: b)))
+// _tmp_48: 'as' NAME
+static void *
+_tmp_48_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'as' NAME
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
+ Token * _keyword;
+ expr_ty z;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
+ &&
+ (z = _PyPegen_name_token(p)) // NAME
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_49: 'from' expression
+static void *
+_tmp_49_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'from' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression"));
+ Token * _keyword;
+ expr_ty z;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
+ &&
+ (z = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_49[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_49[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_50: '->' expression
+static void *
+_tmp_50_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '->' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression"));
+ Token * _literal;
+ expr_ty z;
+ if (
+ (_literal = _PyPegen_expect_token(p, 51)) // token='->'
+ &&
+ (z = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_50[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_51: '->' expression
+static void *
+_tmp_51_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '->' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression"));
+ Token * _literal;
+ expr_ty z;
+ if (
+ (_literal = _PyPegen_expect_token(p, 51)) // token='->'
+ &&
+ (z = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_51[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_51[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_52: NEWLINE INDENT
+static void *
+_tmp_52_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // NEWLINE INDENT
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT"));
+ Token * indent_var;
+ Token * newline_var;
+ if (
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ &&
+ (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT"));
+ _res = _PyPegen_dummy_name(p, newline_var, indent_var);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_52[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_53: param_no_default
+static asdl_seq *
+_loop0_53_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
+ while (
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ _res = param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_53[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_53_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_54: param_with_default
+static asdl_seq *
+_loop0_54_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ NameDefaultPair* param_with_default_var;
+ while (
+ (param_with_default_var = param_with_default_rule(p)) // param_with_default
+ )
+ {
+ _res = param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_55: param_with_default
+static asdl_seq *
+_loop0_55_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ NameDefaultPair* param_with_default_var;
+ while (
+ (param_with_default_var = param_with_default_rule(p)) // param_with_default
+ )
+ {
+ _res = param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_56: param_no_default
+static asdl_seq *
+_loop1_56_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
+ while (
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ _res = param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_56[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_56_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_57: param_with_default
+static asdl_seq *
+_loop0_57_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ NameDefaultPair* param_with_default_var;
+ while (
+ (param_with_default_var = param_with_default_rule(p)) // param_with_default
+ )
+ {
+ _res = param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_58: param_with_default
+static asdl_seq *
+_loop1_58_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ NameDefaultPair* param_with_default_var;
+ while (
+ (param_with_default_var = param_with_default_rule(p)) // param_with_default
+ )
+ {
+ _res = param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_58[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_58_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_59: param_no_default
+static asdl_seq *
+_loop1_59_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
+ while (
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ _res = param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_59[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_59_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_60: param_no_default
+static asdl_seq *
+_loop1_60_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
+ while (
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ _res = param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_60[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_60_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_61: param_no_default
+static asdl_seq *
+_loop0_61_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
+ while (
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ _res = param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_62: param_with_default
+static asdl_seq *
+_loop1_62_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ NameDefaultPair* param_with_default_var;
+ while (
+ (param_with_default_var = param_with_default_rule(p)) // param_with_default
+ )
+ {
+ _res = param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_62[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_62_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_63: param_no_default
+static asdl_seq *
+_loop0_63_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
+ while (
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ _res = param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_64: param_with_default
+static asdl_seq *
+_loop1_64_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ NameDefaultPair* param_with_default_var;
+ while (
+ (param_with_default_var = param_with_default_rule(p)) // param_with_default
+ )
+ {
+ _res = param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_64[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_64_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_65: param_maybe_default
+static asdl_seq *
+_loop0_65_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_maybe_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default"));
+ NameDefaultPair* param_maybe_default_var;
+ while (
+ (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
+ )
+ {
+ _res = param_maybe_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_66: param_maybe_default
+static asdl_seq *
+_loop1_66_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_maybe_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default"));
+ NameDefaultPair* param_maybe_default_var;
+ while (
+ (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
+ )
+ {
+ _res = param_maybe_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_66[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_66_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_67: ('@' named_expression NEWLINE)
+static asdl_seq *
+_loop1_67_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ('@' named_expression NEWLINE)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)"));
+ void *_tmp_141_var;
+ while (
+ (_tmp_141_var = _tmp_141_rule(p)) // '@' named_expression NEWLINE
+ )
+ {
+ _res = _tmp_141_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_67[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_67_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_68: '(' arguments? ')'
+static void *
+_tmp_68_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '(' arguments? ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'"));
+ Token * _literal;
+ Token * _literal_1;
+ void *z;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ &&
+ (z = arguments_rule(p), 1) // arguments?
+ &&
+ (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_70: ',' star_expression
+static asdl_seq *
+_loop0_70_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' star_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = star_expression_rule(p)) // star_expression
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_69: star_expression _loop0_70
+static asdl_seq *
+_gather_69_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // star_expression _loop0_70
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = star_expression_rule(p)) // star_expression
+ &&
+ (seq = _loop0_70_rule(p)) // _loop0_70
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_69[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_70"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop1_71: (',' star_expression)
+static asdl_seq *
+_loop1_71_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // (',' star_expression)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)"));
+ void *_tmp_142_var;
+ while (
+ (_tmp_142_var = _tmp_142_rule(p)) // ',' star_expression
+ )
+ {
+ _res = _tmp_142_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_71[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_71_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_73: ',' star_named_expression
+static asdl_seq *
+_loop0_73_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' star_named_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = star_named_expression_rule(p)) // star_named_expression
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_72: star_named_expression _loop0_73
+static asdl_seq *
+_gather_72_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // star_named_expression _loop0_73
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = star_named_expression_rule(p)) // star_named_expression
+ &&
+ (seq = _loop0_73_rule(p)) // _loop0_73
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_73"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop1_74: (',' expression)
+static asdl_seq *
+_loop1_74_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // (',' expression)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)"));
+ void *_tmp_143_var;
+ while (
+ (_tmp_143_var = _tmp_143_rule(p)) // ',' expression
+ )
+ {
+ _res = _tmp_143_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_74[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_75: lambda_param_no_default
+static asdl_seq *
+_loop0_75_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
+ while (
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ _res = lambda_param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_75[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_76: lambda_param_with_default
+static asdl_seq *
+_loop0_76_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ NameDefaultPair* lambda_param_with_default_var;
+ while (
+ (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
+ )
+ {
+ _res = lambda_param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_77: lambda_param_with_default
+static asdl_seq *
+_loop0_77_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ NameDefaultPair* lambda_param_with_default_var;
+ while (
+ (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
+ )
+ {
+ _res = lambda_param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_78: lambda_param_no_default
+static asdl_seq *
+_loop1_78_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
+ while (
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ _res = lambda_param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_78[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_79: lambda_param_with_default
+static asdl_seq *
+_loop0_79_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ NameDefaultPair* lambda_param_with_default_var;
+ while (
+ (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
+ )
+ {
+ _res = lambda_param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_80: lambda_param_with_default
+static asdl_seq *
+_loop1_80_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ NameDefaultPair* lambda_param_with_default_var;
+ while (
+ (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
+ )
+ {
+ _res = lambda_param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_81: lambda_param_no_default
+static asdl_seq *
+_loop1_81_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
+ while (
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ _res = lambda_param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_82: lambda_param_no_default
+static asdl_seq *
+_loop1_82_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
+ while (
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ _res = lambda_param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_83: lambda_param_no_default
+static asdl_seq *
+_loop0_83_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
+ while (
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ _res = lambda_param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_83[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_84: lambda_param_with_default
+static asdl_seq *
+_loop1_84_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ NameDefaultPair* lambda_param_with_default_var;
+ while (
+ (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
+ )
+ {
+ _res = lambda_param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_85: lambda_param_no_default
+static asdl_seq *
+_loop0_85_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
+ while (
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ _res = lambda_param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_86: lambda_param_with_default
+static asdl_seq *
+_loop1_86_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ NameDefaultPair* lambda_param_with_default_var;
+ while (
+ (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
+ )
+ {
+ _res = lambda_param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_87: lambda_param_maybe_default
+static asdl_seq *
+_loop0_87_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_maybe_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
+ NameDefaultPair* lambda_param_maybe_default_var;
+ while (
+ (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
+ )
+ {
+ _res = lambda_param_maybe_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_87[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_88: lambda_param_maybe_default
+static asdl_seq *
+_loop1_88_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_maybe_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
+ NameDefaultPair* lambda_param_maybe_default_var;
+ while (
+ (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
+ )
+ {
+ _res = lambda_param_maybe_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_89: ('or' conjunction)
+static asdl_seq *
+_loop1_89_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ('or' conjunction)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)"));
+ void *_tmp_144_var;
+ while (
+ (_tmp_144_var = _tmp_144_rule(p)) // 'or' conjunction
+ )
+ {
+ _res = _tmp_144_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_90: ('and' inversion)
+static asdl_seq *
+_loop1_90_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ('and' inversion)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)"));
+ void *_tmp_145_var;
+ while (
+ (_tmp_145_var = _tmp_145_rule(p)) // 'and' inversion
+ )
+ {
+ _res = _tmp_145_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_91: compare_op_bitwise_or_pair
+static asdl_seq *
+_loop1_91_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // compare_op_bitwise_or_pair
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair"));
+ CmpopExprPair* compare_op_bitwise_or_pair_var;
+ while (
+ (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair
+ )
+ {
+ _res = compare_op_bitwise_or_pair_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_92: '!='
+static void *
+_tmp_92_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '!='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='"));
+ Token * tok;
+ if (
+ (tok = _PyPegen_expect_token(p, 28)) // token='!='
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='"));
+ _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_94: ',' slice
+static asdl_seq *
+_loop0_94_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' slice
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = slice_rule(p)) // slice
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_93: slice _loop0_94
+static asdl_seq *
+_gather_93_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // slice _loop0_94
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_94"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = slice_rule(p)) // slice
+ &&
+ (seq = _loop0_94_rule(p)) // _loop0_94
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_94"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_94"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_95: ':' expression?
+static void *
+_tmp_95_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ':' expression?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?"));
+ Token * _literal;
+ void *d;
+ if (
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ &&
+ (d = expression_rule(p), 1) // expression?
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?"));
+ _res = d;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_96: tuple | group | genexp
+static void *
+_tmp_96_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // tuple
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple"));
+ expr_ty tuple_var;
+ if (
+ (tuple_var = tuple_rule(p)) // tuple
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple"));
+ _res = tuple_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple"));
+ }
+ { // group
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group"));
+ expr_ty group_var;
+ if (
+ (group_var = group_rule(p)) // group
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group"));
+ _res = group_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group"));
+ }
+ { // genexp
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp"));
+ expr_ty genexp_var;
+ if (
+ (genexp_var = genexp_rule(p)) // genexp
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp"));
+ _res = genexp_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_97: list | listcomp
+static void *
+_tmp_97_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // list
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list"));
+ expr_ty list_var;
+ if (
+ (list_var = list_rule(p)) // list
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list"));
+ _res = list_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list"));
+ }
+ { // listcomp
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp"));
+ expr_ty listcomp_var;
+ if (
+ (listcomp_var = listcomp_rule(p)) // listcomp
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp"));
+ _res = listcomp_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_98: dict | set | dictcomp | setcomp
+static void *
+_tmp_98_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // dict
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict"));
+ expr_ty dict_var;
+ if (
+ (dict_var = dict_rule(p)) // dict
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict"));
+ _res = dict_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict"));
+ }
+ { // set
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set"));
+ expr_ty set_var;
+ if (
+ (set_var = set_rule(p)) // set
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set"));
+ _res = set_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set"));
+ }
+ { // dictcomp
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp"));
+ expr_ty dictcomp_var;
+ if (
+ (dictcomp_var = dictcomp_rule(p)) // dictcomp
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp"));
+ _res = dictcomp_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp"));
+ }
+ { // setcomp
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp"));
+ expr_ty setcomp_var;
+ if (
+ (setcomp_var = setcomp_rule(p)) // setcomp
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp"));
+ _res = setcomp_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop1_99: STRING
+static asdl_seq *
+_loop1_99_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // STRING
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING"));
+ expr_ty string_var;
+ while (
+ (string_var = _PyPegen_string_token(p)) // STRING
+ )
+ {
+ _res = string_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_100: star_named_expression ',' star_named_expressions?
+static void *
+_tmp_100_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // star_named_expression ',' star_named_expressions?
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
+ Token * _literal;
+ expr_ty y;
+ void *z;
+ if (
+ (y = star_named_expression_rule(p)) // star_named_expression
+ &&
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (z = star_named_expressions_rule(p), 1) // star_named_expressions?
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
+ _res = _PyPegen_seq_insert_in_front ( p , y , z );
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_101: yield_expr | named_expression
+static void *
+_tmp_101_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // yield_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ expr_ty yield_expr_var;
+ if (
+ (yield_expr_var = yield_expr_rule(p)) // yield_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ _res = yield_expr_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
+ }
+ { // named_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression"));
+ expr_ty named_expression_var;
+ if (
+ (named_expression_var = named_expression_rule(p)) // named_expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression"));
+ _res = named_expression_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_103: ',' double_starred_kvpair
+static asdl_seq *
+_loop0_103_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' double_starred_kvpair
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair"));
+ Token * _literal;
+ KeyValuePair* elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_102: double_starred_kvpair _loop0_103
+static asdl_seq *
+_gather_102_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // double_starred_kvpair _loop0_103
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103"));
+ KeyValuePair* elem;
+ asdl_seq * seq;
+ if (
+ (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair
+ &&
+ (seq = _loop0_103_rule(p)) // _loop0_103
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_102[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_102[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_103"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop1_104: for_if_clause
+static asdl_seq *
+_loop1_104_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // for_if_clause
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause"));
+ comprehension_ty for_if_clause_var;
+ while (
+ (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause
+ )
+ {
+ _res = for_if_clause_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_105: ('if' disjunction)
+static asdl_seq *
+_loop0_105_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ('if' disjunction)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
+ void *_tmp_146_var;
+ while (
+ (_tmp_146_var = _tmp_146_rule(p)) // 'if' disjunction
+ )
+ {
+ _res = _tmp_146_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_106: ('if' disjunction)
+static asdl_seq *
+_loop0_106_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ('if' disjunction)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
+ void *_tmp_147_var;
+ while (
+ (_tmp_147_var = _tmp_147_rule(p)) // 'if' disjunction
+ )
+ {
+ _res = _tmp_147_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_107: ',' args
+static void *
+_tmp_107_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ',' args
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args"));
+ Token * _literal;
+ expr_ty c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (c = args_rule(p)) // args
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args"));
+ _res = c;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_108: ',' args
+static void *
+_tmp_108_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ',' args
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args"));
+ Token * _literal;
+ expr_ty c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (c = args_rule(p)) // args
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args"));
+ _res = c;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_108[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_110: ',' kwarg_or_starred
+static asdl_seq *
+_loop0_110_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' kwarg_or_starred
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
+ Token * _literal;
+ KeywordOrStarred* elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_109: kwarg_or_starred _loop0_110
+static asdl_seq *
+_gather_109_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // kwarg_or_starred _loop0_110
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110"));
+ KeywordOrStarred* elem;
+ asdl_seq * seq;
+ if (
+ (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
+ &&
+ (seq = _loop0_110_rule(p)) // _loop0_110
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_110"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_112: ',' kwarg_or_double_starred
+static asdl_seq *
+_loop0_112_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' kwarg_or_double_starred
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
+ Token * _literal;
+ KeywordOrStarred* elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_111: kwarg_or_double_starred _loop0_112
+static asdl_seq *
+_gather_111_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // kwarg_or_double_starred _loop0_112
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
+ KeywordOrStarred* elem;
+ asdl_seq * seq;
+ if (
+ (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
+ &&
+ (seq = _loop0_112_rule(p)) // _loop0_112
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_111[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_114: ',' kwarg_or_starred
+static asdl_seq *
+_loop0_114_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' kwarg_or_starred
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
+ Token * _literal;
+ KeywordOrStarred* elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_113: kwarg_or_starred _loop0_114
+static asdl_seq *
+_gather_113_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // kwarg_or_starred _loop0_114
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114"));
+ KeywordOrStarred* elem;
+ asdl_seq * seq;
+ if (
+ (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
+ &&
+ (seq = _loop0_114_rule(p)) // _loop0_114
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_114"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_116: ',' kwarg_or_double_starred
+static asdl_seq *
+_loop0_116_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' kwarg_or_double_starred
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
+ Token * _literal;
+ KeywordOrStarred* elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_115: kwarg_or_double_starred _loop0_116
+static asdl_seq *
+_gather_115_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // kwarg_or_double_starred _loop0_116
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
+ KeywordOrStarred* elem;
+ asdl_seq * seq;
+ if (
+ (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
+ &&
+ (seq = _loop0_116_rule(p)) // _loop0_116
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_115[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_117: (',' star_target)
+static asdl_seq *
+_loop0_117_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // (',' star_target)
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)"));
+ void *_tmp_148_var;
+ while (
+ (_tmp_148_var = _tmp_148_rule(p)) // ',' star_target
+ )
+ {
+ _res = _tmp_148_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_117[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_119: ',' star_target
+static asdl_seq *
+_loop0_119_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' star_target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = star_target_rule(p)) // star_target
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_118: star_target _loop0_119
+static asdl_seq *
+_gather_118_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // star_target _loop0_119
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = star_target_rule(p)) // star_target
+ &&
+ (seq = _loop0_119_rule(p)) // _loop0_119
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_119"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_120: !'*' star_target
+static void *
+_tmp_120_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // !'*' star_target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
+ expr_ty star_target_var;
+ if (
+ _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*'
+ &&
+ (star_target_var = star_target_rule(p)) // star_target
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
+ _res = star_target_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_122: ',' del_target
+static asdl_seq *
+_loop0_122_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' del_target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = del_target_rule(p)) // del_target
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_121: del_target _loop0_122
+static asdl_seq *
+_gather_121_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // del_target _loop0_122
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = del_target_rule(p)) // del_target
+ &&
+ (seq = _loop0_122_rule(p)) // _loop0_122
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_121[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_122"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_124: ',' target
+static asdl_seq *
+_loop0_124_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // ',' target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target"));
+ Token * _literal;
+ expr_ty elem;
+ while (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (elem = target_rule(p)) // target
+ )
+ {
+ _res = elem;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _gather_123: target _loop0_124
+static asdl_seq *
+_gather_123_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq * _res = NULL;
+ int _mark = p->mark;
+ { // target _loop0_124
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_124"));
+ expr_ty elem;
+ asdl_seq * seq;
+ if (
+ (elem = target_rule(p)) // target
+ &&
+ (seq = _loop0_124_rule(p)) // _loop0_124
+ )
+ {
+ D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_124"));
+ _res = _PyPegen_seq_insert_in_front(p, elem, seq);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_124"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_125: args | expression for_if_clauses
+static void *
+_tmp_125_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // args
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args"));
+ expr_ty args_var;
+ if (
+ (args_var = args_rule(p)) // args
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args"));
+ _res = args_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args"));
+ }
+ { // expression for_if_clauses
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
+ expr_ty expression_var;
+ asdl_seq* for_if_clauses_var;
+ if (
+ (expression_var = expression_rule(p)) // expression
+ &&
+ (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
+ _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_126: star_named_expressions
+static asdl_seq *
+_loop0_126_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // star_named_expressions
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions"));
+ asdl_seq* star_named_expressions_var;
+ while (
+ (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions
+ )
+ {
+ _res = star_named_expressions_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_127: '=' annotated_rhs
+static void *
+_tmp_127_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '=' annotated_rhs
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
+ Token * _literal;
+ expr_ty annotated_rhs_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ &&
+ (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
+ _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_128: (star_targets '=')
+static asdl_seq *
+_loop0_128_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // (star_targets '=')
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
+ void *_tmp_149_var;
+ while (
+ (_tmp_149_var = _tmp_149_rule(p)) // star_targets '='
+ )
+ {
+ _res = _tmp_149_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop0_129: (star_targets '=')
+static asdl_seq *
+_loop0_129_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // (star_targets '=')
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
+ void *_tmp_150_var;
+ while (
+ (_tmp_150_var = _tmp_150_rule(p)) // star_targets '='
+ )
+ {
+ _res = _tmp_150_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_129_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_130: yield_expr | star_expressions
+static void *
+_tmp_130_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // yield_expr
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ expr_ty yield_expr_var;
+ if (
+ (yield_expr_var = yield_expr_rule(p)) // yield_expr
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
+ _res = yield_expr_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
+ }
+ { // star_expressions
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ expr_ty star_expressions_var;
+ if (
+ (star_expressions_var = star_expressions_rule(p)) // star_expressions
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
+ _res = star_expressions_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_131: '[' | '(' | '{'
+static void *
+_tmp_131_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '['
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 9)) // token='['
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['"));
+ }
+ { // '('
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 7)) // token='('
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('"));
+ }
+ { // '{'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 25)) // token='{'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_132: param_no_default
+static asdl_seq *
+_loop0_132_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
+ arg_ty param_no_default_var;
+ while (
+ (param_no_default_var = param_no_default_rule(p)) // param_no_default
+ )
+ {
+ _res = param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_133: slash_with_default | param_with_default+
+static void *
+_tmp_133_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // slash_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
+ SlashWithDefault* slash_with_default_var;
+ if (
+ (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
+ _res = slash_with_default_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default"));
+ }
+ { // param_with_default+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
+ asdl_seq * _loop1_151_var;
+ if (
+ (_loop1_151_var = _loop1_151_rule(p)) // param_with_default+
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
+ _res = _loop1_151_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop0_134: lambda_param_no_default
+static asdl_seq *
+_loop0_134_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_no_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
+ arg_ty lambda_param_no_default_var;
+ while (
+ (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
+ )
+ {
+ _res = lambda_param_no_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop0_134_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_135: lambda_slash_with_default | lambda_param_with_default+
+static void *
+_tmp_135_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // lambda_slash_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
+ SlashWithDefault* lambda_slash_with_default_var;
+ if (
+ (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
+ _res = lambda_slash_with_default_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default"));
+ }
+ { // lambda_param_with_default+
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
+ asdl_seq * _loop1_152_var;
+ if (
+ (_loop1_152_var = _loop1_152_rule(p)) // lambda_param_with_default+
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
+ _res = _loop1_152_var;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_136: ')' | ',' (')' | '**')
+static void *
+_tmp_136_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
+ }
+ { // ',' (')' | '**')
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
+ Token * _literal;
+ void *_tmp_153_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_tmp_153_var = _tmp_153_rule(p)) // ')' | '**'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
+ _res = _PyPegen_dummy_name(p, _literal, _tmp_153_var);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_137: ':' | ',' (':' | '**')
+static void *
+_tmp_137_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'"));
+ }
+ { // ',' (':' | '**')
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
+ Token * _literal;
+ void *_tmp_154_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (_tmp_154_var = _tmp_154_rule(p)) // ':' | '**'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
+ _res = _PyPegen_dummy_name(p, _literal, _tmp_154_var);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_138: star_targets '='
+static void *
+_tmp_138_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // star_targets '='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ Token * _literal;
+ expr_ty z;
+ if (
+ (z = star_targets_rule(p)) // star_targets
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_139: '.' | '...'
+static void *
+_tmp_139_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '.'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
+ }
+ { // '...'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 52)) // token='...'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_140: '.' | '...'
+static void *
+_tmp_140_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '.'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 23)) // token='.'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
+ }
+ { // '...'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 52)) // token='...'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_141: '@' named_expression NEWLINE
+static void *
+_tmp_141_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // '@' named_expression NEWLINE
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
+ Token * _literal;
+ expr_ty f;
+ Token * newline_var;
+ if (
+ (_literal = _PyPegen_expect_token(p, 49)) // token='@'
+ &&
+ (f = named_expression_rule(p)) // named_expression
+ &&
+ (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
+ _res = f;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_142: ',' star_expression
+static void *
+_tmp_142_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ',' star_expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
+ Token * _literal;
+ expr_ty c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (c = star_expression_rule(p)) // star_expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
+ _res = c;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_143: ',' expression
+static void *
+_tmp_143_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ',' expression
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ Token * _literal;
+ expr_ty c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (c = expression_rule(p)) // expression
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression"));
+ _res = c;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_144: 'or' conjunction
+static void *
+_tmp_144_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'or' conjunction
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
+ Token * _keyword;
+ expr_ty c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 531)) // token='or'
+ &&
+ (c = conjunction_rule(p)) // conjunction
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
+ _res = c;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_145: 'and' inversion
+static void *
+_tmp_145_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'and' inversion
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
+ Token * _keyword;
+ expr_ty c;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 532)) // token='and'
+ &&
+ (c = inversion_rule(p)) // inversion
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
+ _res = c;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_146: 'if' disjunction
+static void *
+_tmp_146_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'if' disjunction
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ Token * _keyword;
+ expr_ty z;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
+ &&
+ (z = disjunction_rule(p)) // disjunction
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_147: 'if' disjunction
+static void *
+_tmp_147_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // 'if' disjunction
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ Token * _keyword;
+ expr_ty z;
+ if (
+ (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
+ &&
+ (z = disjunction_rule(p)) // disjunction
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
+ _res = z;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_148: ',' star_target
+static void *
+_tmp_148_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ',' star_target
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
+ Token * _literal;
+ expr_ty c;
+ if (
+ (_literal = _PyPegen_expect_token(p, 12)) // token=','
+ &&
+ (c = star_target_rule(p)) // star_target
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target"));
+ _res = c;
+ if (_res == NULL && PyErr_Occurred()) {
+ p->error_indicator = 1;
+ D(p->level--);
+ return NULL;
+ }
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_149: star_targets '='
+static void *
+_tmp_149_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // star_targets '='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ Token * _literal;
+ expr_ty star_targets_var;
+ if (
+ (star_targets_var = star_targets_rule(p)) // star_targets
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ _res = _PyPegen_dummy_name(p, star_targets_var, _literal);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_150: star_targets '='
+static void *
+_tmp_150_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // star_targets '='
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ Token * _literal;
+ expr_ty star_targets_var;
+ if (
+ (star_targets_var = star_targets_rule(p)) // star_targets
+ &&
+ (_literal = _PyPegen_expect_token(p, 22)) // token='='
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
+ _res = _PyPegen_dummy_name(p, star_targets_var, _literal);
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _loop1_151: param_with_default
+static asdl_seq *
+_loop1_151_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
+ NameDefaultPair* param_with_default_var;
+ while (
+ (param_with_default_var = param_with_default_rule(p)) // param_with_default
+ )
+ {
+ _res = param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_151[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_151_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _loop1_152: lambda_param_with_default
+static asdl_seq *
+_loop1_152_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void *_res = NULL;
+ int _mark = p->mark;
+ int _start_mark = p->mark;
+ void **_children = PyMem_Malloc(sizeof(void *));
+ if (!_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ ssize_t _children_capacity = 1;
+ ssize_t _n = 0;
+ { // lambda_param_with_default
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _loop1_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
+ NameDefaultPair* lambda_param_with_default_var;
+ while (
+ (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
+ )
+ {
+ _res = lambda_param_with_default_var;
+ if (_n == _children_capacity) {
+ _children_capacity *= 2;
+ void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
+ if (!_new_children) {
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ _children = _new_children;
+ }
+ _children[_n++] = _res;
+ _mark = p->mark;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _loop1_152[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
+ }
+ if (_n == 0 || p->error_indicator) {
+ PyMem_Free(_children);
+ D(p->level--);
+ return NULL;
+ }
+ asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
+ if (!_seq) {
+ PyMem_Free(_children);
+ p->error_indicator = 1;
+ PyErr_NoMemory();
+ D(p->level--);
+ return NULL;
+ }
+ for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
+ PyMem_Free(_children);
+ _PyPegen_insert_memo(p, _start_mark, _loop1_152_type, _seq);
+ D(p->level--);
+ return _seq;
+}
+
+// _tmp_153: ')' | '**'
+static void *
+_tmp_153_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ')'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 8)) // token=')'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
+ }
+ { // '**'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+// _tmp_154: ':' | '**'
+static void *
+_tmp_154_rule(Parser *p)
+{
+ D(p->level++);
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ void * _res = NULL;
+ int _mark = p->mark;
+ { // ':'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 11)) // token=':'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'"));
+ }
+ { // '**'
+ if (p->error_indicator) {
+ D(p->level--);
+ return NULL;
+ }
+ D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
+ Token * _literal;
+ if (
+ (_literal = _PyPegen_expect_token(p, 35)) // token='**'
+ )
+ {
+ D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
+ _res = _literal;
+ goto done;
+ }
+ p->mark = _mark;
+ D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ',
+ p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'"));
+ }
+ _res = NULL;
+ done:
+ D(p->level--);
+ return _res;
+}
+
+void *
+_PyPegen_parse(Parser *p)
+{
+ // Initialize keywords
+ p->keywords = reserved_keywords;
+ p->n_keyword_lists = n_keyword_lists;
+
+ // Run parser
+ void *result = NULL;
+ if (p->start_rule == Py_file_input) {
+ result = file_rule(p);
+ } else if (p->start_rule == Py_single_input) {
+ result = interactive_rule(p);
+ } else if (p->start_rule == Py_eval_input) {
+ result = eval_rule(p);
+ } else if (p->start_rule == Py_func_type_input) {
+ result = func_type_rule(p);
+ } else if (p->start_rule == Py_fstring_input) {
+ result = fstring_rule(p);
+ }
+
+ return result;
+}
-*/
+// The end
diff --git a/Parser/parser.h b/Parser/parser.h
deleted file mode 100644
index b16075e..0000000
--- a/Parser/parser.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef Py_PARSER_H
-#define Py_PARSER_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Parser interface */
-
-#define MAXSTACK 1700
-
-typedef struct {
- int s_state; /* State in current DFA */
- const dfa *s_dfa; /* Current DFA */
- struct _node *s_parent; /* Where to add next node */
-} stackentry;
-
-typedef struct {
- stackentry *s_top; /* Top entry */
- stackentry s_base[MAXSTACK];/* Array of stack entries */
- /* NB The stack grows down */
-} stack;
-
-typedef struct {
- stack p_stack; /* Stack of parser states */
- grammar *p_grammar; /* Grammar to use */
- node *p_tree; /* Top of parse tree */
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
- unsigned long p_flags; /* see co_flags in Include/code.h */
-#endif
-} parser_state;
-
-parser_state *PyParser_New(grammar *g, int start);
-void PyParser_Delete(parser_state *ps);
-int PyParser_AddToken(parser_state *ps, int type, char *str,
- int lineno, int col_offset,
- int end_lineno, int end_col_offset,
- int *expected_ret);
-void PyGrammar_AddAccelerators(grammar *g);
-
-
-#define showtree _Py_showtree
-#define printtree _Py_printtree
-#define dumptree _Py_dumptree
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* !Py_PARSER_H */
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
deleted file mode 100644
index 1ecb2c4..0000000
--- a/Parser/parsetok.c
+++ /dev/null
@@ -1,486 +0,0 @@
-
-/* Parser-tokenizer link implementation */
-
-#include "Python.h"
-#include "tokenizer.h"
-#include "node.h"
-#include "grammar.h"
-#include "parser.h"
-#include "parsetok.h"
-#include "errcode.h"
-#include "graminit.h"
-
-
-/* Forward */
-static node *parsetok(struct tok_state *, grammar *, int, perrdetail *, int *);
-static int initerr(perrdetail *err_ret, PyObject * filename);
-
-typedef struct {
- struct {
- int lineno;
- char *comment;
- } *items;
- size_t size;
- size_t num_items;
-} growable_comment_array;
-
-static int
-growable_comment_array_init(growable_comment_array *arr, size_t initial_size) {
- assert(initial_size > 0);
- arr->items = malloc(initial_size * sizeof(*arr->items));
- arr->size = initial_size;
- arr->num_items = 0;
-
- return arr->items != NULL;
-}
-
-static int
-growable_comment_array_add(growable_comment_array *arr, int lineno, char *comment) {
- if (arr->num_items >= arr->size) {
- size_t new_size = arr->size * 2;
- void *new_items_array = realloc(arr->items, new_size * sizeof(*arr->items));
- if (!new_items_array) {
- return 0;
- }
- arr->items = new_items_array;
- arr->size = new_size;
- }
-
- arr->items[arr->num_items].lineno = lineno;
- arr->items[arr->num_items].comment = comment;
- arr->num_items++;
- return 1;
-}
-
-static void
-growable_comment_array_deallocate(growable_comment_array *arr) {
- for (unsigned i = 0; i < arr->num_items; i++) {
- PyObject_FREE(arr->items[i].comment);
- }
- free(arr->items);
-}
-
-/* Parse input coming from a string. Return error code, print some errors. */
-node *
-PyParser_ParseString(const char *s, grammar *g, int start, perrdetail *err_ret)
-{
- return PyParser_ParseStringFlagsFilename(s, NULL, g, start, err_ret, 0);
-}
-
-node *
-PyParser_ParseStringFlags(const char *s, grammar *g, int start,
- perrdetail *err_ret, int flags)
-{
- return PyParser_ParseStringFlagsFilename(s, NULL,
- g, start, err_ret, flags);
-}
-
-node *
-PyParser_ParseStringFlagsFilename(const char *s, const char *filename,
- grammar *g, int start,
- perrdetail *err_ret, int flags)
-{
- int iflags = flags;
- return PyParser_ParseStringFlagsFilenameEx(s, filename, g, start,
- err_ret, &iflags);
-}
-
-node *
-PyParser_ParseStringObject(const char *s, PyObject *filename,
- grammar *g, int start,
- perrdetail *err_ret, int *flags)
-{
- struct tok_state *tok;
- int exec_input = start == file_input;
-
- if (initerr(err_ret, filename) < 0)
- return NULL;
-
- if (PySys_Audit("compile", "yO", s, err_ret->filename) < 0) {
- err_ret->error = E_ERROR;
- return NULL;
- }
-
- if (*flags & PyPARSE_IGNORE_COOKIE)
- tok = PyTokenizer_FromUTF8(s, exec_input);
- else
- tok = PyTokenizer_FromString(s, exec_input);
- if (tok == NULL) {
- err_ret->error = PyErr_Occurred() ? E_DECODE : E_NOMEM;
- return NULL;
- }
- if (*flags & PyPARSE_TYPE_COMMENTS) {
- tok->type_comments = 1;
- }
-
- Py_INCREF(err_ret->filename);
- tok->filename = err_ret->filename;
- if (*flags & PyPARSE_ASYNC_HACKS)
- tok->async_hacks = 1;
- return parsetok(tok, g, start, err_ret, flags);
-}
-
-node *
-PyParser_ParseStringFlagsFilenameEx(const char *s, const char *filename_str,
- grammar *g, int start,
- perrdetail *err_ret, int *flags)
-{
- node *n;
- PyObject *filename = NULL;
- if (filename_str != NULL) {
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL) {
- err_ret->error = E_ERROR;
- return NULL;
- }
- }
- n = PyParser_ParseStringObject(s, filename, g, start, err_ret, flags);
- Py_XDECREF(filename);
- return n;
-}
-
-/* Parse input coming from a file. Return error code, print some errors. */
-
-node *
-PyParser_ParseFile(FILE *fp, const char *filename, grammar *g, int start,
- const char *ps1, const char *ps2,
- perrdetail *err_ret)
-{
- return PyParser_ParseFileFlags(fp, filename, NULL,
- g, start, ps1, ps2, err_ret, 0);
-}
-
-node *
-PyParser_ParseFileFlags(FILE *fp, const char *filename, const char *enc,
- grammar *g, int start,
- const char *ps1, const char *ps2,
- perrdetail *err_ret, int flags)
-{
- int iflags = flags;
- return PyParser_ParseFileFlagsEx(fp, filename, enc, g, start, ps1,
- ps2, err_ret, &iflags);
-}
-
-node *
-PyParser_ParseFileObject(FILE *fp, PyObject *filename,
- const char *enc, grammar *g, int start,
- const char *ps1, const char *ps2,
- perrdetail *err_ret, int *flags)
-{
- struct tok_state *tok;
-
- if (initerr(err_ret, filename) < 0)
- return NULL;
-
- if (PySys_Audit("compile", "OO", Py_None, err_ret->filename) < 0) {
- return NULL;
- }
-
- if ((tok = PyTokenizer_FromFile(fp, enc, ps1, ps2)) == NULL) {
- err_ret->error = E_NOMEM;
- return NULL;
- }
- if (*flags & PyPARSE_TYPE_COMMENTS) {
- tok->type_comments = 1;
- }
- Py_INCREF(err_ret->filename);
- tok->filename = err_ret->filename;
- return parsetok(tok, g, start, err_ret, flags);
-}
-
-node *
-PyParser_ParseFileFlagsEx(FILE *fp, const char *filename,
- const char *enc, grammar *g, int start,
- const char *ps1, const char *ps2,
- perrdetail *err_ret, int *flags)
-{
- node *n;
- PyObject *fileobj = NULL;
- if (filename != NULL) {
- fileobj = PyUnicode_DecodeFSDefault(filename);
- if (fileobj == NULL) {
- err_ret->error = E_ERROR;
- return NULL;
- }
- }
- n = PyParser_ParseFileObject(fp, fileobj, enc, g,
- start, ps1, ps2, err_ret, flags);
- Py_XDECREF(fileobj);
- return n;
-}
-
-/* Parse input coming from the given tokenizer structure.
- Return error code. */
-
-static node *
-parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
- int *flags)
-{
- parser_state *ps;
- node *n;
- int started = 0;
- int col_offset, end_col_offset;
- growable_comment_array type_ignores;
-
- if (!growable_comment_array_init(&type_ignores, 10)) {
- err_ret->error = E_NOMEM;
- PyTokenizer_Free(tok);
- return NULL;
- }
-
- if ((ps = PyParser_New(g, start)) == NULL) {
- err_ret->error = E_NOMEM;
- growable_comment_array_deallocate(&type_ignores);
- PyTokenizer_Free(tok);
- return NULL;
- }
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
- if (*flags & PyPARSE_BARRY_AS_BDFL)
- ps->p_flags |= CO_FUTURE_BARRY_AS_BDFL;
- if (*flags & PyPARSE_TYPE_COMMENTS)
- ps->p_flags |= PyCF_TYPE_COMMENTS;
-#endif
-
- for (;;) {
- const char *a, *b;
- int type;
- size_t len;
- char *str;
- col_offset = -1;
- int lineno;
- const char *line_start;
-
- type = PyTokenizer_Get(tok, &a, &b);
-
- len = (a != NULL && b != NULL) ? b - a : 0;
- str = (char *) PyObject_MALLOC(len + 1);
- if (str == NULL) {
- err_ret->error = E_NOMEM;
- break;
- }
- if (len > 0)
- strncpy(str, a, len);
- str[len] = '\0';
-
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
- if (type == NOTEQUAL) {
- if (!(ps->p_flags & CO_FUTURE_BARRY_AS_BDFL) &&
- strcmp(str, "!=")) {
- PyObject_FREE(str);
- err_ret->error = E_SYNTAX;
- break;
- }
- else if ((ps->p_flags & CO_FUTURE_BARRY_AS_BDFL) &&
- strcmp(str, "<>")) {
- PyObject_FREE(str);
- err_ret->expected = NOTEQUAL;
- err_ret->error = E_SYNTAX;
- break;
- }
- }
-#endif
-
- /* Nodes of type STRING, especially multi line strings
- must be handled differently in order to get both
- the starting line number and the column offset right.
- (cf. issue 16806) */
- lineno = type == STRING ? tok->first_lineno : tok->lineno;
- line_start = type == STRING ? tok->multi_line_start : tok->line_start;
- if (a != NULL && a >= line_start) {
- col_offset = Py_SAFE_DOWNCAST(a - line_start,
- intptr_t, int);
- }
- else {
- col_offset = -1;
- }
-
- if (b != NULL && b >= tok->line_start) {
- end_col_offset = Py_SAFE_DOWNCAST(b - tok->line_start,
- intptr_t, int);
- }
- else {
- end_col_offset = -1;
- }
-
- if (type == TYPE_IGNORE) {
- if (!growable_comment_array_add(&type_ignores, tok->lineno, str)) {
- err_ret->error = E_NOMEM;
- break;
- }
- continue;
- }
-
- if (type == ERRORTOKEN) {
- err_ret->error = tok->done;
- break;
- }
- if (type == ENDMARKER && started) {
- type = NEWLINE; /* Add an extra newline */
- started = 0;
- /* Add the right number of dedent tokens,
- except if a certain flag is given --
- codeop.py uses this. */
- if (tok->indent &&
- !(*flags & PyPARSE_DONT_IMPLY_DEDENT))
- {
- tok->pendin = -tok->indent;
- tok->indent = 0;
- }
- }
- else {
- started = 1;
- }
-
- if ((err_ret->error =
- PyParser_AddToken(ps, (int)type, str,
- lineno, col_offset, tok->lineno, end_col_offset,
- &(err_ret->expected))) != E_OK) {
- if (tok->done == E_EOF && !ISWHITESPACE(type)) {
- tok->done = E_SYNTAX;
- }
- if (err_ret->error != E_DONE) {
- PyObject_FREE(str);
- err_ret->token = type;
- }
- break;
- }
- }
-
- if (err_ret->error == E_DONE) {
- n = ps->p_tree;
- ps->p_tree = NULL;
-
- if (n->n_type == file_input) {
- /* Put type_ignore nodes in the ENDMARKER of file_input. */
- int num;
- node *ch;
- size_t i;
-
- num = NCH(n);
- ch = CHILD(n, num - 1);
- REQ(ch, ENDMARKER);
-
- for (i = 0; i < type_ignores.num_items; i++) {
- int res = PyNode_AddChild(ch, TYPE_IGNORE, type_ignores.items[i].comment,
- type_ignores.items[i].lineno, 0,
- type_ignores.items[i].lineno, 0);
- if (res != 0) {
- err_ret->error = res;
- PyNode_Free(n);
- n = NULL;
- break;
- }
- type_ignores.items[i].comment = NULL;
- }
- }
-
- /* Check that the source for a single input statement really
- is a single statement by looking at what is left in the
- buffer after parsing. Trailing whitespace and comments
- are OK. */
- if (err_ret->error == E_DONE && start == single_input) {
- const char *cur = tok->cur;
- char c = *tok->cur;
-
- for (;;) {
- while (c == ' ' || c == '\t' || c == '\n' || c == '\014')
- c = *++cur;
-
- if (!c)
- break;
-
- if (c != '#') {
- err_ret->error = E_BADSINGLE;
- PyNode_Free(n);
- n = NULL;
- break;
- }
-
- /* Suck up comment. */
- while (c && c != '\n')
- c = *++cur;
- }
- }
- }
- else
- n = NULL;
-
- growable_comment_array_deallocate(&type_ignores);
-
-#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
- *flags = ps->p_flags;
-#endif
- PyParser_Delete(ps);
-
- if (n == NULL) {
- if (tok->done == E_EOF)
- err_ret->error = E_EOF;
- err_ret->lineno = tok->lineno;
- if (tok->buf != NULL) {
- size_t len;
- assert(tok->cur - tok->buf < INT_MAX);
- /* if we've managed to parse a token, point the offset to its start,
- * else use the current reading position of the tokenizer
- */
- err_ret->offset = col_offset != -1 ? col_offset + 1 : ((int)(tok->cur - tok->buf));
- len = tok->inp - tok->buf;
- err_ret->text = (char *) PyObject_MALLOC(len + 1);
- if (err_ret->text != NULL) {
- if (len > 0)
- strncpy(err_ret->text, tok->buf, len);
- err_ret->text[len] = '\0';
- }
- }
- } else if (tok->encoding != NULL) {
- /* 'nodes->n_str' uses PyObject_*, while 'tok->encoding' was
- * allocated using PyMem_
- */
- node* r = PyNode_New(encoding_decl);
- if (r)
- r->n_str = PyObject_MALLOC(strlen(tok->encoding)+1);
- if (!r || !r->n_str) {
- err_ret->error = E_NOMEM;
- if (r)
- PyObject_FREE(r);
- n = NULL;
- goto done;
- }
- strcpy(r->n_str, tok->encoding);
- PyMem_FREE(tok->encoding);
- tok->encoding = NULL;
- r->n_nchildren = 1;
- r->n_child = n;
- n = r;
- }
-
-done:
- PyTokenizer_Free(tok);
-
- if (n != NULL) {
- _PyNode_FinalizeEndPos(n);
- }
- return n;
-}
-
-static int
-initerr(perrdetail *err_ret, PyObject *filename)
-{
- err_ret->error = E_OK;
- err_ret->lineno = 0;
- err_ret->offset = 0;
- err_ret->text = NULL;
- err_ret->token = -1;
- err_ret->expected = -1;
- if (filename) {
- Py_INCREF(filename);
- err_ret->filename = filename;
- }
- else {
- err_ret->filename = PyUnicode_FromString("<string>");
- if (err_ret->filename == NULL) {
- err_ret->error = E_ERROR;
- return -1;
- }
- }
- return 0;
-}
diff --git a/Parser/pegen/peg_api.c b/Parser/peg_api.c
index 5e71ecd..b947c78 100644
--- a/Parser/pegen/peg_api.c
+++ b/Parser/peg_api.c
@@ -1,6 +1,6 @@
#include "pegen_interface.h"
-#include "../tokenizer.h"
+#include "tokenizer.h"
#include "pegen.h"
mod_ty
diff --git a/Parser/pegen/pegen.c b/Parser/pegen.c
index 7b581ca..e29910b 100644
--- a/Parser/pegen/pegen.c
+++ b/Parser/pegen.c
@@ -1,9 +1,9 @@
#include <Python.h>
#include <errcode.h>
-#include "../tokenizer.h"
+#include "tokenizer.h"
#include "pegen.h"
-#include "parse_string.h"
+#include "string_parser.h"
PyObject *
_PyPegen_new_type_comment(Parser *p, char *s)
diff --git a/Parser/pegen/pegen.h b/Parser/pegen.h
index 64cf0ec..64cf0ec 100644
--- a/Parser/pegen/pegen.h
+++ b/Parser/pegen.h
diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c
deleted file mode 100644
index d28e6c8..0000000
--- a/Parser/pegen/parse.c
+++ /dev/null
@@ -1,24415 +0,0 @@
-// @generated by pegen.py from ./Grammar/python.gram
-#include "pegen.h"
-
-#if defined(Py_DEBUG) && defined(Py_BUILD_CORE)
-extern int Py_DebugFlag;
-#define D(x) if (Py_DebugFlag) x;
-#else
-#define D(x)
-#endif
-static const int n_keyword_lists = 9;
-static KeywordToken *reserved_keywords[] = {
- NULL,
- NULL,
- (KeywordToken[]) {
- {"if", 510},
- {"in", 518},
- {"is", 526},
- {"as", 530},
- {"or", 531},
- {NULL, -1},
- },
- (KeywordToken[]) {
- {"del", 503},
- {"try", 511},
- {"for", 517},
- {"def", 522},
- {"not", 525},
- {"and", 532},
- {NULL, -1},
- },
- (KeywordToken[]) {
- {"pass", 502},
- {"from", 514},
- {"elif", 515},
- {"else", 516},
- {"with", 519},
- {"True", 527},
- {"None", 529},
- {NULL, -1},
- },
- (KeywordToken[]) {
- {"raise", 501},
- {"yield", 504},
- {"break", 506},
- {"while", 512},
- {"class", 523},
- {"False", 528},
- {NULL, -1},
- },
- (KeywordToken[]) {
- {"return", 500},
- {"assert", 505},
- {"global", 508},
- {"import", 513},
- {"except", 520},
- {"lambda", 524},
- {NULL, -1},
- },
- (KeywordToken[]) {
- {"finally", 521},
- {NULL, -1},
- },
- (KeywordToken[]) {
- {"continue", 507},
- {"nonlocal", 509},
- {NULL, -1},
- },
-};
-#define file_type 1000
-#define interactive_type 1001
-#define eval_type 1002
-#define func_type_type 1003
-#define fstring_type 1004
-#define type_expressions_type 1005
-#define statements_type 1006
-#define statement_type 1007
-#define statement_newline_type 1008
-#define simple_stmt_type 1009
-#define small_stmt_type 1010
-#define compound_stmt_type 1011
-#define assignment_type 1012
-#define augassign_type 1013
-#define global_stmt_type 1014
-#define nonlocal_stmt_type 1015
-#define yield_stmt_type 1016
-#define assert_stmt_type 1017
-#define del_stmt_type 1018
-#define import_stmt_type 1019
-#define import_name_type 1020
-#define import_from_type 1021
-#define import_from_targets_type 1022
-#define import_from_as_names_type 1023
-#define import_from_as_name_type 1024
-#define dotted_as_names_type 1025
-#define dotted_as_name_type 1026
-#define dotted_name_type 1027 // Left-recursive
-#define if_stmt_type 1028
-#define elif_stmt_type 1029
-#define else_block_type 1030
-#define while_stmt_type 1031
-#define for_stmt_type 1032
-#define with_stmt_type 1033
-#define with_item_type 1034
-#define try_stmt_type 1035
-#define except_block_type 1036
-#define finally_block_type 1037
-#define return_stmt_type 1038
-#define raise_stmt_type 1039
-#define function_def_type 1040
-#define function_def_raw_type 1041
-#define func_type_comment_type 1042
-#define params_type 1043
-#define parameters_type 1044
-#define slash_no_default_type 1045
-#define slash_with_default_type 1046
-#define star_etc_type 1047
-#define kwds_type 1048
-#define param_no_default_type 1049
-#define param_with_default_type 1050
-#define param_maybe_default_type 1051
-#define param_type 1052
-#define annotation_type 1053
-#define default_type 1054
-#define decorators_type 1055
-#define class_def_type 1056
-#define class_def_raw_type 1057
-#define block_type 1058
-#define expressions_list_type 1059
-#define star_expressions_type 1060
-#define star_expression_type 1061
-#define star_named_expressions_type 1062
-#define star_named_expression_type 1063
-#define named_expression_type 1064
-#define annotated_rhs_type 1065
-#define expressions_type 1066
-#define expression_type 1067
-#define lambdef_type 1068
-#define lambda_params_type 1069
-#define lambda_parameters_type 1070
-#define lambda_slash_no_default_type 1071
-#define lambda_slash_with_default_type 1072
-#define lambda_star_etc_type 1073
-#define lambda_kwds_type 1074
-#define lambda_param_no_default_type 1075
-#define lambda_param_with_default_type 1076
-#define lambda_param_maybe_default_type 1077
-#define lambda_param_type 1078
-#define disjunction_type 1079
-#define conjunction_type 1080
-#define inversion_type 1081
-#define comparison_type 1082
-#define compare_op_bitwise_or_pair_type 1083
-#define eq_bitwise_or_type 1084
-#define noteq_bitwise_or_type 1085
-#define lte_bitwise_or_type 1086
-#define lt_bitwise_or_type 1087
-#define gte_bitwise_or_type 1088
-#define gt_bitwise_or_type 1089
-#define notin_bitwise_or_type 1090
-#define in_bitwise_or_type 1091
-#define isnot_bitwise_or_type 1092
-#define is_bitwise_or_type 1093
-#define bitwise_or_type 1094 // Left-recursive
-#define bitwise_xor_type 1095 // Left-recursive
-#define bitwise_and_type 1096 // Left-recursive
-#define shift_expr_type 1097 // Left-recursive
-#define sum_type 1098 // Left-recursive
-#define term_type 1099 // Left-recursive
-#define factor_type 1100
-#define power_type 1101
-#define await_primary_type 1102
-#define primary_type 1103 // Left-recursive
-#define slices_type 1104
-#define slice_type 1105
-#define atom_type 1106
-#define strings_type 1107
-#define list_type 1108
-#define listcomp_type 1109
-#define tuple_type 1110
-#define group_type 1111
-#define genexp_type 1112
-#define set_type 1113
-#define setcomp_type 1114
-#define dict_type 1115
-#define dictcomp_type 1116
-#define double_starred_kvpairs_type 1117
-#define double_starred_kvpair_type 1118
-#define kvpair_type 1119
-#define for_if_clauses_type 1120
-#define for_if_clause_type 1121
-#define yield_expr_type 1122
-#define arguments_type 1123
-#define args_type 1124
-#define kwargs_type 1125
-#define starred_expression_type 1126
-#define kwarg_or_starred_type 1127
-#define kwarg_or_double_starred_type 1128
-#define star_targets_type 1129
-#define star_targets_seq_type 1130
-#define star_target_type 1131
-#define star_atom_type 1132
-#define single_target_type 1133
-#define single_subscript_attribute_target_type 1134
-#define del_targets_type 1135
-#define del_target_type 1136
-#define del_t_atom_type 1137
-#define del_target_end_type 1138
-#define targets_type 1139
-#define target_type 1140
-#define t_primary_type 1141 // Left-recursive
-#define t_lookahead_type 1142
-#define t_atom_type 1143
-#define incorrect_arguments_type 1144
-#define invalid_kwarg_type 1145
-#define invalid_named_expression_type 1146
-#define invalid_assignment_type 1147
-#define invalid_block_type 1148
-#define invalid_comprehension_type 1149
-#define invalid_dict_comprehension_type 1150
-#define invalid_parameters_type 1151
-#define invalid_lambda_parameters_type 1152
-#define invalid_star_etc_type 1153
-#define invalid_lambda_star_etc_type 1154
-#define invalid_double_type_comments_type 1155
-#define invalid_del_target_type 1156
-#define invalid_import_from_targets_type 1157
-#define _loop0_1_type 1158
-#define _loop0_2_type 1159
-#define _loop0_4_type 1160
-#define _gather_3_type 1161
-#define _loop0_6_type 1162
-#define _gather_5_type 1163
-#define _loop0_8_type 1164
-#define _gather_7_type 1165
-#define _loop0_10_type 1166
-#define _gather_9_type 1167
-#define _loop1_11_type 1168
-#define _loop0_13_type 1169
-#define _gather_12_type 1170
-#define _tmp_14_type 1171
-#define _tmp_15_type 1172
-#define _tmp_16_type 1173
-#define _tmp_17_type 1174
-#define _tmp_18_type 1175
-#define _tmp_19_type 1176
-#define _tmp_20_type 1177
-#define _tmp_21_type 1178
-#define _loop1_22_type 1179
-#define _tmp_23_type 1180
-#define _tmp_24_type 1181
-#define _loop0_26_type 1182
-#define _gather_25_type 1183
-#define _loop0_28_type 1184
-#define _gather_27_type 1185
-#define _tmp_29_type 1186
-#define _loop0_30_type 1187
-#define _loop1_31_type 1188
-#define _loop0_33_type 1189
-#define _gather_32_type 1190
-#define _tmp_34_type 1191
-#define _loop0_36_type 1192
-#define _gather_35_type 1193
-#define _tmp_37_type 1194
-#define _loop0_39_type 1195
-#define _gather_38_type 1196
-#define _loop0_41_type 1197
-#define _gather_40_type 1198
-#define _loop0_43_type 1199
-#define _gather_42_type 1200
-#define _loop0_45_type 1201
-#define _gather_44_type 1202
-#define _tmp_46_type 1203
-#define _loop1_47_type 1204
-#define _tmp_48_type 1205
-#define _tmp_49_type 1206
-#define _tmp_50_type 1207
-#define _tmp_51_type 1208
-#define _tmp_52_type 1209
-#define _loop0_53_type 1210
-#define _loop0_54_type 1211
-#define _loop0_55_type 1212
-#define _loop1_56_type 1213
-#define _loop0_57_type 1214
-#define _loop1_58_type 1215
-#define _loop1_59_type 1216
-#define _loop1_60_type 1217
-#define _loop0_61_type 1218
-#define _loop1_62_type 1219
-#define _loop0_63_type 1220
-#define _loop1_64_type 1221
-#define _loop0_65_type 1222
-#define _loop1_66_type 1223
-#define _loop1_67_type 1224
-#define _tmp_68_type 1225
-#define _loop0_70_type 1226
-#define _gather_69_type 1227
-#define _loop1_71_type 1228
-#define _loop0_73_type 1229
-#define _gather_72_type 1230
-#define _loop1_74_type 1231
-#define _loop0_75_type 1232
-#define _loop0_76_type 1233
-#define _loop0_77_type 1234
-#define _loop1_78_type 1235
-#define _loop0_79_type 1236
-#define _loop1_80_type 1237
-#define _loop1_81_type 1238
-#define _loop1_82_type 1239
-#define _loop0_83_type 1240
-#define _loop1_84_type 1241
-#define _loop0_85_type 1242
-#define _loop1_86_type 1243
-#define _loop0_87_type 1244
-#define _loop1_88_type 1245
-#define _loop1_89_type 1246
-#define _loop1_90_type 1247
-#define _loop1_91_type 1248
-#define _tmp_92_type 1249
-#define _loop0_94_type 1250
-#define _gather_93_type 1251
-#define _tmp_95_type 1252
-#define _tmp_96_type 1253
-#define _tmp_97_type 1254
-#define _tmp_98_type 1255
-#define _loop1_99_type 1256
-#define _tmp_100_type 1257
-#define _tmp_101_type 1258
-#define _loop0_103_type 1259
-#define _gather_102_type 1260
-#define _loop1_104_type 1261
-#define _loop0_105_type 1262
-#define _loop0_106_type 1263
-#define _tmp_107_type 1264
-#define _tmp_108_type 1265
-#define _loop0_110_type 1266
-#define _gather_109_type 1267
-#define _loop0_112_type 1268
-#define _gather_111_type 1269
-#define _loop0_114_type 1270
-#define _gather_113_type 1271
-#define _loop0_116_type 1272
-#define _gather_115_type 1273
-#define _loop0_117_type 1274
-#define _loop0_119_type 1275
-#define _gather_118_type 1276
-#define _tmp_120_type 1277
-#define _loop0_122_type 1278
-#define _gather_121_type 1279
-#define _loop0_124_type 1280
-#define _gather_123_type 1281
-#define _tmp_125_type 1282
-#define _loop0_126_type 1283
-#define _tmp_127_type 1284
-#define _loop0_128_type 1285
-#define _loop0_129_type 1286
-#define _tmp_130_type 1287
-#define _tmp_131_type 1288
-#define _loop0_132_type 1289
-#define _tmp_133_type 1290
-#define _loop0_134_type 1291
-#define _tmp_135_type 1292
-#define _tmp_136_type 1293
-#define _tmp_137_type 1294
-#define _tmp_138_type 1295
-#define _tmp_139_type 1296
-#define _tmp_140_type 1297
-#define _tmp_141_type 1298
-#define _tmp_142_type 1299
-#define _tmp_143_type 1300
-#define _tmp_144_type 1301
-#define _tmp_145_type 1302
-#define _tmp_146_type 1303
-#define _tmp_147_type 1304
-#define _tmp_148_type 1305
-#define _tmp_149_type 1306
-#define _tmp_150_type 1307
-#define _loop1_151_type 1308
-#define _loop1_152_type 1309
-#define _tmp_153_type 1310
-#define _tmp_154_type 1311
-
-static mod_ty file_rule(Parser *p);
-static mod_ty interactive_rule(Parser *p);
-static mod_ty eval_rule(Parser *p);
-static mod_ty func_type_rule(Parser *p);
-static expr_ty fstring_rule(Parser *p);
-static asdl_seq* type_expressions_rule(Parser *p);
-static asdl_seq* statements_rule(Parser *p);
-static asdl_seq* statement_rule(Parser *p);
-static asdl_seq* statement_newline_rule(Parser *p);
-static asdl_seq* simple_stmt_rule(Parser *p);
-static stmt_ty small_stmt_rule(Parser *p);
-static stmt_ty compound_stmt_rule(Parser *p);
-static stmt_ty assignment_rule(Parser *p);
-static AugOperator* augassign_rule(Parser *p);
-static stmt_ty global_stmt_rule(Parser *p);
-static stmt_ty nonlocal_stmt_rule(Parser *p);
-static stmt_ty yield_stmt_rule(Parser *p);
-static stmt_ty assert_stmt_rule(Parser *p);
-static stmt_ty del_stmt_rule(Parser *p);
-static stmt_ty import_stmt_rule(Parser *p);
-static stmt_ty import_name_rule(Parser *p);
-static stmt_ty import_from_rule(Parser *p);
-static asdl_seq* import_from_targets_rule(Parser *p);
-static asdl_seq* import_from_as_names_rule(Parser *p);
-static alias_ty import_from_as_name_rule(Parser *p);
-static asdl_seq* dotted_as_names_rule(Parser *p);
-static alias_ty dotted_as_name_rule(Parser *p);
-static expr_ty dotted_name_rule(Parser *p);
-static stmt_ty if_stmt_rule(Parser *p);
-static stmt_ty elif_stmt_rule(Parser *p);
-static asdl_seq* else_block_rule(Parser *p);
-static stmt_ty while_stmt_rule(Parser *p);
-static stmt_ty for_stmt_rule(Parser *p);
-static stmt_ty with_stmt_rule(Parser *p);
-static withitem_ty with_item_rule(Parser *p);
-static stmt_ty try_stmt_rule(Parser *p);
-static excepthandler_ty except_block_rule(Parser *p);
-static asdl_seq* finally_block_rule(Parser *p);
-static stmt_ty return_stmt_rule(Parser *p);
-static stmt_ty raise_stmt_rule(Parser *p);
-static stmt_ty function_def_rule(Parser *p);
-static stmt_ty function_def_raw_rule(Parser *p);
-static Token* func_type_comment_rule(Parser *p);
-static arguments_ty params_rule(Parser *p);
-static arguments_ty parameters_rule(Parser *p);
-static asdl_seq* slash_no_default_rule(Parser *p);
-static SlashWithDefault* slash_with_default_rule(Parser *p);
-static StarEtc* star_etc_rule(Parser *p);
-static arg_ty kwds_rule(Parser *p);
-static arg_ty param_no_default_rule(Parser *p);
-static NameDefaultPair* param_with_default_rule(Parser *p);
-static NameDefaultPair* param_maybe_default_rule(Parser *p);
-static arg_ty param_rule(Parser *p);
-static expr_ty annotation_rule(Parser *p);
-static expr_ty default_rule(Parser *p);
-static asdl_seq* decorators_rule(Parser *p);
-static stmt_ty class_def_rule(Parser *p);
-static stmt_ty class_def_raw_rule(Parser *p);
-static asdl_seq* block_rule(Parser *p);
-static asdl_seq* expressions_list_rule(Parser *p);
-static expr_ty star_expressions_rule(Parser *p);
-static expr_ty star_expression_rule(Parser *p);
-static asdl_seq* star_named_expressions_rule(Parser *p);
-static expr_ty star_named_expression_rule(Parser *p);
-static expr_ty named_expression_rule(Parser *p);
-static expr_ty annotated_rhs_rule(Parser *p);
-static expr_ty expressions_rule(Parser *p);
-static expr_ty expression_rule(Parser *p);
-static expr_ty lambdef_rule(Parser *p);
-static arguments_ty lambda_params_rule(Parser *p);
-static arguments_ty lambda_parameters_rule(Parser *p);
-static asdl_seq* lambda_slash_no_default_rule(Parser *p);
-static SlashWithDefault* lambda_slash_with_default_rule(Parser *p);
-static StarEtc* lambda_star_etc_rule(Parser *p);
-static arg_ty lambda_kwds_rule(Parser *p);
-static arg_ty lambda_param_no_default_rule(Parser *p);
-static NameDefaultPair* lambda_param_with_default_rule(Parser *p);
-static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p);
-static arg_ty lambda_param_rule(Parser *p);
-static expr_ty disjunction_rule(Parser *p);
-static expr_ty conjunction_rule(Parser *p);
-static expr_ty inversion_rule(Parser *p);
-static expr_ty comparison_rule(Parser *p);
-static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p);
-static CmpopExprPair* eq_bitwise_or_rule(Parser *p);
-static CmpopExprPair* noteq_bitwise_or_rule(Parser *p);
-static CmpopExprPair* lte_bitwise_or_rule(Parser *p);
-static CmpopExprPair* lt_bitwise_or_rule(Parser *p);
-static CmpopExprPair* gte_bitwise_or_rule(Parser *p);
-static CmpopExprPair* gt_bitwise_or_rule(Parser *p);
-static CmpopExprPair* notin_bitwise_or_rule(Parser *p);
-static CmpopExprPair* in_bitwise_or_rule(Parser *p);
-static CmpopExprPair* isnot_bitwise_or_rule(Parser *p);
-static CmpopExprPair* is_bitwise_or_rule(Parser *p);
-static expr_ty bitwise_or_rule(Parser *p);
-static expr_ty bitwise_xor_rule(Parser *p);
-static expr_ty bitwise_and_rule(Parser *p);
-static expr_ty shift_expr_rule(Parser *p);
-static expr_ty sum_rule(Parser *p);
-static expr_ty term_rule(Parser *p);
-static expr_ty factor_rule(Parser *p);
-static expr_ty power_rule(Parser *p);
-static expr_ty await_primary_rule(Parser *p);
-static expr_ty primary_rule(Parser *p);
-static expr_ty slices_rule(Parser *p);
-static expr_ty slice_rule(Parser *p);
-static expr_ty atom_rule(Parser *p);
-static expr_ty strings_rule(Parser *p);
-static expr_ty list_rule(Parser *p);
-static expr_ty listcomp_rule(Parser *p);
-static expr_ty tuple_rule(Parser *p);
-static expr_ty group_rule(Parser *p);
-static expr_ty genexp_rule(Parser *p);
-static expr_ty set_rule(Parser *p);
-static expr_ty setcomp_rule(Parser *p);
-static expr_ty dict_rule(Parser *p);
-static expr_ty dictcomp_rule(Parser *p);
-static asdl_seq* double_starred_kvpairs_rule(Parser *p);
-static KeyValuePair* double_starred_kvpair_rule(Parser *p);
-static KeyValuePair* kvpair_rule(Parser *p);
-static asdl_seq* for_if_clauses_rule(Parser *p);
-static comprehension_ty for_if_clause_rule(Parser *p);
-static expr_ty yield_expr_rule(Parser *p);
-static expr_ty arguments_rule(Parser *p);
-static expr_ty args_rule(Parser *p);
-static asdl_seq* kwargs_rule(Parser *p);
-static expr_ty starred_expression_rule(Parser *p);
-static KeywordOrStarred* kwarg_or_starred_rule(Parser *p);
-static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p);
-static expr_ty star_targets_rule(Parser *p);
-static asdl_seq* star_targets_seq_rule(Parser *p);
-static expr_ty star_target_rule(Parser *p);
-static expr_ty star_atom_rule(Parser *p);
-static expr_ty single_target_rule(Parser *p);
-static expr_ty single_subscript_attribute_target_rule(Parser *p);
-static asdl_seq* del_targets_rule(Parser *p);
-static expr_ty del_target_rule(Parser *p);
-static expr_ty del_t_atom_rule(Parser *p);
-static void *del_target_end_rule(Parser *p);
-static asdl_seq* targets_rule(Parser *p);
-static expr_ty target_rule(Parser *p);
-static expr_ty t_primary_rule(Parser *p);
-static void *t_lookahead_rule(Parser *p);
-static expr_ty t_atom_rule(Parser *p);
-static void *incorrect_arguments_rule(Parser *p);
-static void *invalid_kwarg_rule(Parser *p);
-static void *invalid_named_expression_rule(Parser *p);
-static void *invalid_assignment_rule(Parser *p);
-static void *invalid_block_rule(Parser *p);
-static void *invalid_comprehension_rule(Parser *p);
-static void *invalid_dict_comprehension_rule(Parser *p);
-static void *invalid_parameters_rule(Parser *p);
-static void *invalid_lambda_parameters_rule(Parser *p);
-static void *invalid_star_etc_rule(Parser *p);
-static void *invalid_lambda_star_etc_rule(Parser *p);
-static void *invalid_double_type_comments_rule(Parser *p);
-static void *invalid_del_target_rule(Parser *p);
-static void *invalid_import_from_targets_rule(Parser *p);
-static asdl_seq *_loop0_1_rule(Parser *p);
-static asdl_seq *_loop0_2_rule(Parser *p);
-static asdl_seq *_loop0_4_rule(Parser *p);
-static asdl_seq *_gather_3_rule(Parser *p);
-static asdl_seq *_loop0_6_rule(Parser *p);
-static asdl_seq *_gather_5_rule(Parser *p);
-static asdl_seq *_loop0_8_rule(Parser *p);
-static asdl_seq *_gather_7_rule(Parser *p);
-static asdl_seq *_loop0_10_rule(Parser *p);
-static asdl_seq *_gather_9_rule(Parser *p);
-static asdl_seq *_loop1_11_rule(Parser *p);
-static asdl_seq *_loop0_13_rule(Parser *p);
-static asdl_seq *_gather_12_rule(Parser *p);
-static void *_tmp_14_rule(Parser *p);
-static void *_tmp_15_rule(Parser *p);
-static void *_tmp_16_rule(Parser *p);
-static void *_tmp_17_rule(Parser *p);
-static void *_tmp_18_rule(Parser *p);
-static void *_tmp_19_rule(Parser *p);
-static void *_tmp_20_rule(Parser *p);
-static void *_tmp_21_rule(Parser *p);
-static asdl_seq *_loop1_22_rule(Parser *p);
-static void *_tmp_23_rule(Parser *p);
-static void *_tmp_24_rule(Parser *p);
-static asdl_seq *_loop0_26_rule(Parser *p);
-static asdl_seq *_gather_25_rule(Parser *p);
-static asdl_seq *_loop0_28_rule(Parser *p);
-static asdl_seq *_gather_27_rule(Parser *p);
-static void *_tmp_29_rule(Parser *p);
-static asdl_seq *_loop0_30_rule(Parser *p);
-static asdl_seq *_loop1_31_rule(Parser *p);
-static asdl_seq *_loop0_33_rule(Parser *p);
-static asdl_seq *_gather_32_rule(Parser *p);
-static void *_tmp_34_rule(Parser *p);
-static asdl_seq *_loop0_36_rule(Parser *p);
-static asdl_seq *_gather_35_rule(Parser *p);
-static void *_tmp_37_rule(Parser *p);
-static asdl_seq *_loop0_39_rule(Parser *p);
-static asdl_seq *_gather_38_rule(Parser *p);
-static asdl_seq *_loop0_41_rule(Parser *p);
-static asdl_seq *_gather_40_rule(Parser *p);
-static asdl_seq *_loop0_43_rule(Parser *p);
-static asdl_seq *_gather_42_rule(Parser *p);
-static asdl_seq *_loop0_45_rule(Parser *p);
-static asdl_seq *_gather_44_rule(Parser *p);
-static void *_tmp_46_rule(Parser *p);
-static asdl_seq *_loop1_47_rule(Parser *p);
-static void *_tmp_48_rule(Parser *p);
-static void *_tmp_49_rule(Parser *p);
-static void *_tmp_50_rule(Parser *p);
-static void *_tmp_51_rule(Parser *p);
-static void *_tmp_52_rule(Parser *p);
-static asdl_seq *_loop0_53_rule(Parser *p);
-static asdl_seq *_loop0_54_rule(Parser *p);
-static asdl_seq *_loop0_55_rule(Parser *p);
-static asdl_seq *_loop1_56_rule(Parser *p);
-static asdl_seq *_loop0_57_rule(Parser *p);
-static asdl_seq *_loop1_58_rule(Parser *p);
-static asdl_seq *_loop1_59_rule(Parser *p);
-static asdl_seq *_loop1_60_rule(Parser *p);
-static asdl_seq *_loop0_61_rule(Parser *p);
-static asdl_seq *_loop1_62_rule(Parser *p);
-static asdl_seq *_loop0_63_rule(Parser *p);
-static asdl_seq *_loop1_64_rule(Parser *p);
-static asdl_seq *_loop0_65_rule(Parser *p);
-static asdl_seq *_loop1_66_rule(Parser *p);
-static asdl_seq *_loop1_67_rule(Parser *p);
-static void *_tmp_68_rule(Parser *p);
-static asdl_seq *_loop0_70_rule(Parser *p);
-static asdl_seq *_gather_69_rule(Parser *p);
-static asdl_seq *_loop1_71_rule(Parser *p);
-static asdl_seq *_loop0_73_rule(Parser *p);
-static asdl_seq *_gather_72_rule(Parser *p);
-static asdl_seq *_loop1_74_rule(Parser *p);
-static asdl_seq *_loop0_75_rule(Parser *p);
-static asdl_seq *_loop0_76_rule(Parser *p);
-static asdl_seq *_loop0_77_rule(Parser *p);
-static asdl_seq *_loop1_78_rule(Parser *p);
-static asdl_seq *_loop0_79_rule(Parser *p);
-static asdl_seq *_loop1_80_rule(Parser *p);
-static asdl_seq *_loop1_81_rule(Parser *p);
-static asdl_seq *_loop1_82_rule(Parser *p);
-static asdl_seq *_loop0_83_rule(Parser *p);
-static asdl_seq *_loop1_84_rule(Parser *p);
-static asdl_seq *_loop0_85_rule(Parser *p);
-static asdl_seq *_loop1_86_rule(Parser *p);
-static asdl_seq *_loop0_87_rule(Parser *p);
-static asdl_seq *_loop1_88_rule(Parser *p);
-static asdl_seq *_loop1_89_rule(Parser *p);
-static asdl_seq *_loop1_90_rule(Parser *p);
-static asdl_seq *_loop1_91_rule(Parser *p);
-static void *_tmp_92_rule(Parser *p);
-static asdl_seq *_loop0_94_rule(Parser *p);
-static asdl_seq *_gather_93_rule(Parser *p);
-static void *_tmp_95_rule(Parser *p);
-static void *_tmp_96_rule(Parser *p);
-static void *_tmp_97_rule(Parser *p);
-static void *_tmp_98_rule(Parser *p);
-static asdl_seq *_loop1_99_rule(Parser *p);
-static void *_tmp_100_rule(Parser *p);
-static void *_tmp_101_rule(Parser *p);
-static asdl_seq *_loop0_103_rule(Parser *p);
-static asdl_seq *_gather_102_rule(Parser *p);
-static asdl_seq *_loop1_104_rule(Parser *p);
-static asdl_seq *_loop0_105_rule(Parser *p);
-static asdl_seq *_loop0_106_rule(Parser *p);
-static void *_tmp_107_rule(Parser *p);
-static void *_tmp_108_rule(Parser *p);
-static asdl_seq *_loop0_110_rule(Parser *p);
-static asdl_seq *_gather_109_rule(Parser *p);
-static asdl_seq *_loop0_112_rule(Parser *p);
-static asdl_seq *_gather_111_rule(Parser *p);
-static asdl_seq *_loop0_114_rule(Parser *p);
-static asdl_seq *_gather_113_rule(Parser *p);
-static asdl_seq *_loop0_116_rule(Parser *p);
-static asdl_seq *_gather_115_rule(Parser *p);
-static asdl_seq *_loop0_117_rule(Parser *p);
-static asdl_seq *_loop0_119_rule(Parser *p);
-static asdl_seq *_gather_118_rule(Parser *p);
-static void *_tmp_120_rule(Parser *p);
-static asdl_seq *_loop0_122_rule(Parser *p);
-static asdl_seq *_gather_121_rule(Parser *p);
-static asdl_seq *_loop0_124_rule(Parser *p);
-static asdl_seq *_gather_123_rule(Parser *p);
-static void *_tmp_125_rule(Parser *p);
-static asdl_seq *_loop0_126_rule(Parser *p);
-static void *_tmp_127_rule(Parser *p);
-static asdl_seq *_loop0_128_rule(Parser *p);
-static asdl_seq *_loop0_129_rule(Parser *p);
-static void *_tmp_130_rule(Parser *p);
-static void *_tmp_131_rule(Parser *p);
-static asdl_seq *_loop0_132_rule(Parser *p);
-static void *_tmp_133_rule(Parser *p);
-static asdl_seq *_loop0_134_rule(Parser *p);
-static void *_tmp_135_rule(Parser *p);
-static void *_tmp_136_rule(Parser *p);
-static void *_tmp_137_rule(Parser *p);
-static void *_tmp_138_rule(Parser *p);
-static void *_tmp_139_rule(Parser *p);
-static void *_tmp_140_rule(Parser *p);
-static void *_tmp_141_rule(Parser *p);
-static void *_tmp_142_rule(Parser *p);
-static void *_tmp_143_rule(Parser *p);
-static void *_tmp_144_rule(Parser *p);
-static void *_tmp_145_rule(Parser *p);
-static void *_tmp_146_rule(Parser *p);
-static void *_tmp_147_rule(Parser *p);
-static void *_tmp_148_rule(Parser *p);
-static void *_tmp_149_rule(Parser *p);
-static void *_tmp_150_rule(Parser *p);
-static asdl_seq *_loop1_151_rule(Parser *p);
-static asdl_seq *_loop1_152_rule(Parser *p);
-static void *_tmp_153_rule(Parser *p);
-static void *_tmp_154_rule(Parser *p);
-
-
-// file: statements? $
-static mod_ty
-file_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- mod_ty _res = NULL;
- int _mark = p->mark;
- { // statements? $
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> file[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statements? $"));
- void *a;
- Token * endmarker_var;
- if (
- (a = statements_rule(p), 1) // statements?
- &&
- (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
- )
- {
- D(fprintf(stderr, "%*c+ file[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statements? $"));
- _res = _PyPegen_make_module ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s file[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statements? $"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// interactive: statement_newline
-static mod_ty
-interactive_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- mod_ty _res = NULL;
- int _mark = p->mark;
- { // statement_newline
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> interactive[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement_newline"));
- asdl_seq* a;
- if (
- (a = statement_newline_rule(p)) // statement_newline
- )
- {
- D(fprintf(stderr, "%*c+ interactive[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement_newline"));
- _res = Interactive ( a , p -> arena );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s interactive[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement_newline"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// eval: expressions NEWLINE* $
-static mod_ty
-eval_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- mod_ty _res = NULL;
- int _mark = p->mark;
- { // expressions NEWLINE* $
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> eval[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $"));
- asdl_seq * _loop0_1_var;
- expr_ty a;
- Token * endmarker_var;
- if (
- (a = expressions_rule(p)) // expressions
- &&
- (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE*
- &&
- (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
- )
- {
- D(fprintf(stderr, "%*c+ eval[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $"));
- _res = Expression ( a , p -> arena );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s eval[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions NEWLINE* $"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// func_type: '(' type_expressions? ')' '->' expression NEWLINE* $
-static mod_ty
-func_type_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- mod_ty _res = NULL;
- int _mark = p->mark;
- { // '(' type_expressions? ')' '->' expression NEWLINE* $
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> func_type[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $"));
- Token * _literal;
- Token * _literal_1;
- Token * _literal_2;
- asdl_seq * _loop0_2_var;
- void *a;
- expr_ty b;
- Token * endmarker_var;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = type_expressions_rule(p), 1) // type_expressions?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- &&
- (_literal_2 = _PyPegen_expect_token(p, 51)) // token='->'
- &&
- (b = expression_rule(p)) // expression
- &&
- (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE*
- &&
- (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
- )
- {
- D(fprintf(stderr, "%*c+ func_type[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $"));
- _res = FunctionType ( a , b , p -> arena );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s func_type[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// fstring: star_expressions
-static expr_ty
-fstring_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- { // star_expressions
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> fstring[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- expr_ty star_expressions_var;
- if (
- (star_expressions_var = star_expressions_rule(p)) // star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ fstring[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- _res = star_expressions_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s fstring[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// type_expressions:
-// | ','.expression+ ',' '*' expression ',' '**' expression
-// | ','.expression+ ',' '*' expression
-// | ','.expression+ ',' '**' expression
-// | '*' expression ',' '**' expression
-// | '*' expression
-// | '**' expression
-// | ','.expression+
-static asdl_seq*
-type_expressions_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.expression+ ',' '*' expression ',' '**' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression"));
- Token * _literal;
- Token * _literal_1;
- Token * _literal_2;
- Token * _literal_3;
- asdl_seq * a;
- expr_ty b;
- expr_ty c;
- if (
- (a = _gather_3_rule(p)) // ','.expression+
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (b = expression_rule(p)) // expression
- &&
- (_literal_2 = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (c = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression"));
- _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression"));
- }
- { // ','.expression+ ',' '*' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * a;
- expr_ty b;
- if (
- (a = _gather_5_rule(p)) // ','.expression+
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression"));
- _res = _PyPegen_seq_append_to_end ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression"));
- }
- { // ','.expression+ ',' '**' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * a;
- expr_ty b;
- if (
- (a = _gather_7_rule(p)) // ','.expression+
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression"));
- _res = _PyPegen_seq_append_to_end ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '**' expression"));
- }
- { // '*' expression ',' '**' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression"));
- Token * _literal;
- Token * _literal_1;
- Token * _literal_2;
- expr_ty a;
- expr_ty b;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = expression_rule(p)) // expression
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression"));
- _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression ',' '**' expression"));
- }
- { // '*' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression"));
- _res = _PyPegen_singleton_seq ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression"));
- }
- { // '**' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression"));
- _res = _PyPegen_singleton_seq ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression"));
- }
- { // ','.expression+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+"));
- asdl_seq * _gather_9_var;
- if (
- (_gather_9_var = _gather_9_rule(p)) // ','.expression+
- )
- {
- D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+"));
- _res = _gather_9_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// statements: statement+
-static asdl_seq*
-statements_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // statement+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> statements[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement+"));
- asdl_seq * a;
- if (
- (a = _loop1_11_rule(p)) // statement+
- )
- {
- D(fprintf(stderr, "%*c+ statements[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement+"));
- _res = _PyPegen_seq_flatten ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s statements[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// statement: compound_stmt | simple_stmt
-static asdl_seq*
-statement_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // compound_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt"));
- stmt_ty a;
- if (
- (a = compound_stmt_rule(p)) // compound_stmt
- )
- {
- D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt"));
- _res = _PyPegen_singleton_seq ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt"));
- }
- { // simple_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- asdl_seq* simple_stmt_var;
- if (
- (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
- )
- {
- D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- _res = simple_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
-static asdl_seq*
-statement_newline_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // compound_stmt NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE"));
- stmt_ty a;
- Token * newline_var;
- if (
- (a = compound_stmt_rule(p)) // compound_stmt
- &&
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE"));
- _res = _PyPegen_singleton_seq ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE"));
- }
- { // simple_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- asdl_seq* simple_stmt_var;
- if (
- (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
- )
- {
- D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- _res = simple_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
- }
- { // NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
- Token * newline_var;
- if (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
- }
- { // $
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "$"));
- Token * endmarker_var;
- if (
- (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER'
- )
- {
- D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "$"));
- _res = _PyPegen_interactive_exit ( p );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "$"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
-static asdl_seq*
-simple_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // small_stmt !';' NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
- stmt_ty a;
- Token * newline_var;
- if (
- (a = small_stmt_rule(p)) // small_stmt
- &&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
- &&
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
- _res = _PyPegen_singleton_seq ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt !';' NEWLINE"));
- }
- { // ';'.small_stmt+ ';'? NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- Token * newline_var;
- if (
- (a = _gather_12_rule(p)) // ';'.small_stmt+
- &&
- (_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
- &&
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// small_stmt:
-// | assignment
-// | star_expressions
-// | &'return' return_stmt
-// | &('import' | 'from') import_stmt
-// | &'raise' raise_stmt
-// | 'pass'
-// | &'del' del_stmt
-// | &'yield' yield_stmt
-// | &'assert' assert_stmt
-// | 'break'
-// | 'continue'
-// | &'global' global_stmt
-// | &'nonlocal' nonlocal_stmt
-static stmt_ty
-small_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // assignment
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
- stmt_ty assignment_var;
- if (
- (assignment_var = assignment_rule(p)) // assignment
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
- _res = assignment_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment"));
- }
- { // star_expressions
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- expr_ty e;
- if (
- (e = star_expressions_rule(p)) // star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Expr ( e , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
- }
- { // &'return' return_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
- stmt_ty return_stmt_var;
- if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
- &&
- (return_stmt_var = return_stmt_rule(p)) // return_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
- _res = return_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt"));
- }
- { // &('import' | 'from') import_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
- stmt_ty import_stmt_var;
- if (
- _PyPegen_lookahead(1, _tmp_14_rule, p)
- &&
- (import_stmt_var = import_stmt_rule(p)) // import_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
- _res = import_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt"));
- }
- { // &'raise' raise_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_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, 501) // token='raise'
- &&
- (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
- _res = raise_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt"));
- }
- { // 'pass'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 502)) // token='pass'
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Pass ( EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'"));
- }
- { // &'del' del_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_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, 503) // token='del'
- &&
- (del_stmt_var = del_stmt_rule(p)) // del_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
- _res = del_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt"));
- }
- { // &'yield' yield_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
- stmt_ty yield_stmt_var;
- if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
- &&
- (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
- _res = yield_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt"));
- }
- { // &'assert' assert_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_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, 505) // token='assert'
- &&
- (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
- _res = assert_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt"));
- }
- { // 'break'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 506)) // token='break'
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Break ( EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'"));
- }
- { // 'continue'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 507)) // token='continue'
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Continue ( EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'"));
- }
- { // &'global' global_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
- stmt_ty global_stmt_var;
- if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
- &&
- (global_stmt_var = global_stmt_rule(p)) // global_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
- _res = global_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt"));
- }
- { // &'nonlocal' nonlocal_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
- stmt_ty nonlocal_stmt_var;
- if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
- &&
- (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
- )
- {
- D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
- _res = nonlocal_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, small_stmt_type, _res);
- D(p->level--);
- return _res;
-}
-
-// compound_stmt:
-// | &('def' | '@' | ASYNC) function_def
-// | &'if' if_stmt
-// | &('class' | '@') class_def
-// | &('with' | ASYNC) with_stmt
-// | &('for' | ASYNC) for_stmt
-// | &'try' try_stmt
-// | &'while' while_stmt
-static stmt_ty
-compound_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- { // &('def' | '@' | ASYNC) function_def
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def"));
- stmt_ty function_def_var;
- if (
- _PyPegen_lookahead(1, _tmp_15_rule, p)
- &&
- (function_def_var = function_def_rule(p)) // function_def
- )
- {
- D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def"));
- _res = function_def_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('def' | '@' | ASYNC) function_def"));
- }
- { // &'if' if_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- 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, 510) // token='if'
- &&
- (if_stmt_var = if_stmt_rule(p)) // if_stmt
- )
- {
- D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt"));
- _res = if_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'if' if_stmt"));
- }
- { // &('class' | '@') class_def
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def"));
- stmt_ty class_def_var;
- if (
- _PyPegen_lookahead(1, _tmp_16_rule, p)
- &&
- (class_def_var = class_def_rule(p)) // class_def
- )
- {
- D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def"));
- _res = class_def_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('class' | '@') class_def"));
- }
- { // &('with' | ASYNC) with_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt"));
- stmt_ty with_stmt_var;
- if (
- _PyPegen_lookahead(1, _tmp_17_rule, p)
- &&
- (with_stmt_var = with_stmt_rule(p)) // with_stmt
- )
- {
- D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt"));
- _res = with_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('with' | ASYNC) with_stmt"));
- }
- { // &('for' | ASYNC) for_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt"));
- stmt_ty for_stmt_var;
- if (
- _PyPegen_lookahead(1, _tmp_18_rule, p)
- &&
- (for_stmt_var = for_stmt_rule(p)) // for_stmt
- )
- {
- D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt"));
- _res = for_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('for' | ASYNC) for_stmt"));
- }
- { // &'try' try_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- 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, 511) // token='try'
- &&
- (try_stmt_var = try_stmt_rule(p)) // try_stmt
- )
- {
- D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt"));
- _res = try_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'try' try_stmt"));
- }
- { // &'while' while_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- 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, 512) // token='while'
- &&
- (while_stmt_var = while_stmt_rule(p)) // while_stmt
- )
- {
- D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt"));
- _res = while_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'while' while_stmt"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// assignment:
-// | NAME ':' expression ['=' annotated_rhs]
-// | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]
-// | ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?
-// | single_target augassign (yield_expr | star_expressions)
-// | invalid_assignment
-static stmt_ty
-assignment_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME ':' expression ['=' annotated_rhs]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- void *c;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = expression_rule(p)) // expression
- &&
- (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs]
- )
- {
- D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]"));
- }
- { // ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]"));
- Token * _literal;
- void *a;
- expr_ty b;
- void *c;
- if (
- (a = _tmp_20_rule(p)) // '(' single_target ')' | single_subscript_attribute_target
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = expression_rule(p)) // expression
- &&
- (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs]
- )
- {
- D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]"));
- }
- { // ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?"));
- asdl_seq * a;
- void *b;
- void *tc;
- if (
- (a = _loop1_22_rule(p)) // ((star_targets '='))+
- &&
- (b = _tmp_23_rule(p)) // yield_expr | star_expressions
- &&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='='
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- )
- {
- D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?"));
- }
- { // single_target augassign (yield_expr | star_expressions)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_target augassign (yield_expr | star_expressions)"));
- expr_ty a;
- AugOperator* b;
- void *c;
- if (
- (a = single_target_rule(p)) // single_target
- &&
- (b = augassign_rule(p)) // augassign
- &&
- (c = _tmp_24_rule(p)) // yield_expr | star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_target augassign (yield_expr | star_expressions)"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_AugAssign ( a , b -> kind , c , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_target augassign (yield_expr | star_expressions)"));
- }
- { // invalid_assignment
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_assignment"));
- void *invalid_assignment_var;
- if (
- (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment
- )
- {
- D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_assignment"));
- _res = invalid_assignment_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_assignment"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// augassign:
-// | '+='
-// | '-='
-// | '*='
-// | '@='
-// | '/='
-// | '%='
-// | '&='
-// | '|='
-// | '^='
-// | '<<='
-// | '>>='
-// | '**='
-// | '//='
-static AugOperator*
-augassign_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- AugOperator* _res = NULL;
- int _mark = p->mark;
- { // '+='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 36)) // token='+='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+='"));
- _res = _PyPegen_augoperator ( p , Add );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+='"));
- }
- { // '-='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 37)) // token='-='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-='"));
- _res = _PyPegen_augoperator ( p , Sub );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-='"));
- }
- { // '*='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 38)) // token='*='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*='"));
- _res = _PyPegen_augoperator ( p , Mult );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*='"));
- }
- { // '@='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 50)) // token='@='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@='"));
- _res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@='"));
- }
- { // '/='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 39)) // token='/='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/='"));
- _res = _PyPegen_augoperator ( p , Div );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/='"));
- }
- { // '%='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'%='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 40)) // token='%='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'%='"));
- _res = _PyPegen_augoperator ( p , Mod );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'%='"));
- }
- { // '&='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'&='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 41)) // token='&='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'&='"));
- _res = _PyPegen_augoperator ( p , BitAnd );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'&='"));
- }
- { // '|='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 42)) // token='|='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|='"));
- _res = _PyPegen_augoperator ( p , BitOr );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|='"));
- }
- { // '^='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'^='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 43)) // token='^='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'^='"));
- _res = _PyPegen_augoperator ( p , BitXor );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'^='"));
- }
- { // '<<='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<<='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 44)) // token='<<='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<<='"));
- _res = _PyPegen_augoperator ( p , LShift );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<<='"));
- }
- { // '>>='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>>='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 45)) // token='>>='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>>='"));
- _res = _PyPegen_augoperator ( p , RShift );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>>='"));
- }
- { // '**='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 46)) // token='**='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**='"));
- _res = _PyPegen_augoperator ( p , Pow );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**='"));
- }
- { // '//='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'//='"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 48)) // token='//='
- )
- {
- D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'//='"));
- _res = _PyPegen_augoperator ( p , FloorDiv );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'//='"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// global_stmt: 'global' ','.NAME+
-static stmt_ty
-global_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'global' ','.NAME+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> global_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+"));
- Token * _keyword;
- asdl_seq * a;
- if (
- (_keyword = _PyPegen_expect_token(p, 508)) // token='global'
- &&
- (a = _gather_25_rule(p)) // ','.NAME+
- )
- {
- D(fprintf(stderr, "%*c+ global_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s global_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'global' ','.NAME+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// nonlocal_stmt: 'nonlocal' ','.NAME+
-static stmt_ty
-nonlocal_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'nonlocal' ','.NAME+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> nonlocal_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+"));
- Token * _keyword;
- asdl_seq * a;
- if (
- (_keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal'
- &&
- (a = _gather_27_rule(p)) // ','.NAME+
- )
- {
- D(fprintf(stderr, "%*c+ nonlocal_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s nonlocal_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'nonlocal' ','.NAME+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// yield_stmt: yield_expr
-static stmt_ty
-yield_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // yield_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> yield_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- expr_ty y;
- if (
- (y = yield_expr_rule(p)) // yield_expr
- )
- {
- D(fprintf(stderr, "%*c+ yield_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Expr ( y , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s yield_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// assert_stmt: 'assert' expression [',' expression]
-static stmt_ty
-assert_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'assert' expression [',' expression]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]"));
- Token * _keyword;
- expr_ty a;
- void *b;
- if (
- (_keyword = _PyPegen_expect_token(p, 505)) // token='assert'
- &&
- (a = expression_rule(p)) // expression
- &&
- (b = _tmp_29_rule(p), 1) // [',' expression]
- )
- {
- D(fprintf(stderr, "%*c+ assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Assert ( a , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s assert_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression [',' expression]"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// del_stmt: 'del' del_targets
-static stmt_ty
-del_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'del' del_targets
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'del' del_targets"));
- Token * _keyword;
- asdl_seq* a;
- if (
- (_keyword = _PyPegen_expect_token(p, 503)) // token='del'
- &&
- (a = del_targets_rule(p)) // del_targets
- )
- {
- D(fprintf(stderr, "%*c+ del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'del' del_targets"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Delete ( a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'del' del_targets"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// import_stmt: import_name | import_from
-static stmt_ty
-import_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- { // import_name
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_name"));
- stmt_ty import_name_var;
- if (
- (import_name_var = import_name_rule(p)) // import_name
- )
- {
- D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_name"));
- _res = import_name_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_name"));
- }
- { // import_from
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from"));
- stmt_ty import_from_var;
- if (
- (import_from_var = import_from_rule(p)) // import_from
- )
- {
- D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from"));
- _res = import_from_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// import_name: 'import' dotted_as_names
-static stmt_ty
-import_name_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'import' dotted_as_names
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names"));
- Token * _keyword;
- asdl_seq* a;
- if (
- (_keyword = _PyPegen_expect_token(p, 513)) // token='import'
- &&
- (a = dotted_as_names_rule(p)) // dotted_as_names
- )
- {
- D(fprintf(stderr, "%*c+ import_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Import ( a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_name[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' dotted_as_names"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// import_from:
-// | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
-// | 'from' (('.' | '...'))+ 'import' import_from_targets
-static stmt_ty
-import_from_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets"));
- Token * _keyword;
- Token * _keyword_1;
- asdl_seq * a;
- expr_ty b;
- asdl_seq* c;
- if (
- (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
- &&
- (a = _loop0_30_rule(p)) // (('.' | '...'))*
- &&
- (b = dotted_name_rule(p)) // dotted_name
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
- &&
- (c = import_from_targets_rule(p)) // import_from_targets
- )
- {
- D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets"));
- }
- { // 'from' (('.' | '...'))+ 'import' import_from_targets
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets"));
- Token * _keyword;
- Token * _keyword_1;
- asdl_seq * a;
- asdl_seq* b;
- if (
- (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
- &&
- (a = _loop1_31_rule(p)) // (('.' | '...'))+
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import'
- &&
- (b = import_from_targets_rule(p)) // import_from_targets
- )
- {
- D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// import_from_targets:
-// | '(' import_from_as_names ','? ')'
-// | import_from_as_names !','
-// | '*'
-// | invalid_import_from_targets
-static asdl_seq*
-import_from_targets_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // '(' import_from_as_names ','? ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'"));
- Token * _literal;
- Token * _literal_1;
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq* a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = import_from_as_names_rule(p)) // import_from_as_names
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' import_from_as_names ','? ')'"));
- }
- { // import_from_as_names !','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','"));
- asdl_seq* import_from_as_names_var;
- if (
- (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names
- &&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','"));
- _res = import_from_as_names_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names !','"));
- }
- { // '*'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- )
- {
- D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'"));
- _res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'"));
- }
- { // invalid_import_from_targets
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets"));
- void *invalid_import_from_targets_var;
- if (
- (invalid_import_from_targets_var = invalid_import_from_targets_rule(p)) // invalid_import_from_targets
- )
- {
- D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets"));
- _res = invalid_import_from_targets_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_import_from_targets"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// import_from_as_names: ','.import_from_as_name+
-static asdl_seq*
-import_from_as_names_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.import_from_as_name+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+"));
- asdl_seq * a;
- if (
- (a = _gather_32_rule(p)) // ','.import_from_as_name+
- )
- {
- D(fprintf(stderr, "%*c+ import_from_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from_as_names[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.import_from_as_name+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// import_from_as_name: NAME ['as' NAME]
-static alias_ty
-import_from_as_name_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- alias_ty _res = NULL;
- int _mark = p->mark;
- { // NAME ['as' NAME]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> import_from_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]"));
- expr_ty a;
- void *b;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- &&
- (b = _tmp_34_rule(p), 1) // ['as' NAME]
- )
- {
- D(fprintf(stderr, "%*c+ import_from_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]"));
- _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s import_from_as_name[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ['as' NAME]"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// dotted_as_names: ','.dotted_as_name+
-static asdl_seq*
-dotted_as_names_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.dotted_as_name+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> dotted_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+"));
- asdl_seq * a;
- if (
- (a = _gather_35_rule(p)) // ','.dotted_as_name+
- )
- {
- D(fprintf(stderr, "%*c+ dotted_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s dotted_as_names[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.dotted_as_name+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// dotted_as_name: dotted_name ['as' NAME]
-static alias_ty
-dotted_as_name_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- alias_ty _res = NULL;
- int _mark = p->mark;
- { // dotted_name ['as' NAME]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> dotted_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]"));
- expr_ty a;
- void *b;
- if (
- (a = dotted_name_rule(p)) // dotted_name
- &&
- (b = _tmp_37_rule(p), 1) // ['as' NAME]
- )
- {
- D(fprintf(stderr, "%*c+ dotted_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]"));
- _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s dotted_as_name[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name ['as' NAME]"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// dotted_name: dotted_name '.' NAME | NAME
-static expr_ty dotted_name_raw(Parser *);
-static expr_ty
-dotted_name_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, dotted_name_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res);
- if (tmpvar_0) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = dotted_name_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-dotted_name_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- { // dotted_name '.' NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = dotted_name_rule(p)) // dotted_name
- &&
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- &&
- (b = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME"));
- _res = _PyPegen_join_names_with_dot ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name '.' NAME"));
- }
- { // NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
- expr_ty name_var;
- if (
- (name_var = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
- _res = name_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// if_stmt:
-// | 'if' named_expression ':' block elif_stmt
-// | 'if' named_expression ':' block else_block?
-static stmt_ty
-if_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'if' named_expression ':' block elif_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt"));
- Token * _keyword;
- Token * _literal;
- expr_ty a;
- asdl_seq* b;
- stmt_ty c;
- if (
- (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
- &&
- (a = named_expression_rule(p)) // named_expression
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- &&
- (c = elif_stmt_rule(p)) // elif_stmt
- )
- {
- D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block elif_stmt"));
- }
- { // 'if' named_expression ':' block else_block?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?"));
- Token * _keyword;
- Token * _literal;
- expr_ty a;
- asdl_seq* b;
- void *c;
- if (
- (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
- &&
- (a = named_expression_rule(p)) // named_expression
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- &&
- (c = else_block_rule(p), 1) // else_block?
- )
- {
- D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_If ( a , b , c , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block else_block?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// elif_stmt:
-// | 'elif' named_expression ':' block elif_stmt
-// | 'elif' named_expression ':' block else_block?
-static stmt_ty
-elif_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'elif' named_expression ':' block elif_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt"));
- Token * _keyword;
- Token * _literal;
- expr_ty a;
- asdl_seq* b;
- stmt_ty c;
- if (
- (_keyword = _PyPegen_expect_token(p, 515)) // token='elif'
- &&
- (a = named_expression_rule(p)) // named_expression
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- &&
- (c = elif_stmt_rule(p)) // elif_stmt
- )
- {
- D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block elif_stmt"));
- }
- { // 'elif' named_expression ':' block else_block?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?"));
- Token * _keyword;
- Token * _literal;
- expr_ty a;
- asdl_seq* b;
- void *c;
- if (
- (_keyword = _PyPegen_expect_token(p, 515)) // token='elif'
- &&
- (a = named_expression_rule(p)) // named_expression
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- &&
- (c = else_block_rule(p), 1) // else_block?
- )
- {
- D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_If ( a , b , c , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block else_block?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// else_block: 'else' ':' block
-static asdl_seq*
-else_block_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // 'else' ':' block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> else_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' ':' block"));
- Token * _keyword;
- Token * _literal;
- asdl_seq* b;
- if (
- (_keyword = _PyPegen_expect_token(p, 516)) // token='else'
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ else_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' block"));
- _res = b;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s else_block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' ':' block"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// while_stmt: 'while' named_expression ':' block else_block?
-static stmt_ty
-while_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'while' named_expression ':' block else_block?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?"));
- Token * _keyword;
- Token * _literal;
- expr_ty a;
- asdl_seq* b;
- void *c;
- if (
- (_keyword = _PyPegen_expect_token(p, 512)) // token='while'
- &&
- (a = named_expression_rule(p)) // named_expression
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- &&
- (c = else_block_rule(p), 1) // else_block?
- )
- {
- D(fprintf(stderr, "%*c+ while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_While ( a , b , c , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s while_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression ':' block else_block?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// for_stmt:
-// | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
-// | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
-static stmt_ty
-for_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
- Token * _keyword;
- Token * _keyword_1;
- Token * _literal;
- asdl_seq* b;
- void *el;
- expr_ty ex;
- expr_ty t;
- void *tc;
- if (
- (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
- &&
- (t = star_targets_rule(p)) // star_targets
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
- &&
- (ex = star_expressions_rule(p)) // star_expressions
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- &&
- (b = block_rule(p)) // block
- &&
- (el = else_block_rule(p), 1) // else_block?
- )
- {
- D(fprintf(stderr, "%*c+ for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
- }
- { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
- Token * _keyword;
- Token * _keyword_1;
- Token * _literal;
- Token * async_var;
- asdl_seq* b;
- void *el;
- expr_ty ex;
- expr_ty t;
- void *tc;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- &&
- (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
- &&
- (t = star_targets_rule(p)) // star_targets
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
- &&
- (ex = star_expressions_rule(p)) // star_expressions
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- &&
- (b = block_rule(p)) // block
- &&
- (el = else_block_rule(p), 1) // else_block?
- )
- {
- D(fprintf(stderr, "%*c+ for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// with_stmt:
-// | 'with' '(' ','.with_item+ ','? ')' ':' block
-// | 'with' ','.with_item+ ':' TYPE_COMMENT? block
-// | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
-// | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
-static stmt_ty
-with_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'with' '(' ','.with_item+ ','? ')' ':' block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block"));
- Token * _keyword;
- Token * _literal;
- Token * _literal_1;
- Token * _literal_2;
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- asdl_seq* b;
- if (
- (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
- &&
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = _gather_38_rule(p)) // ','.with_item+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- &&
- (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_With ( a , b , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block"));
- }
- { // 'with' ','.with_item+ ':' TYPE_COMMENT? block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block"));
- Token * _keyword;
- Token * _literal;
- asdl_seq * a;
- asdl_seq* b;
- void *tc;
- if (
- (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
- &&
- (a = _gather_40_rule(p)) // ','.with_item+
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block"));
- }
- { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block"));
- Token * _keyword;
- Token * _literal;
- Token * _literal_1;
- Token * _literal_2;
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- Token * async_var;
- asdl_seq* b;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- &&
- (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
- &&
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = _gather_42_rule(p)) // ','.with_item+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- &&
- (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block"));
- }
- { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block"));
- Token * _keyword;
- Token * _literal;
- asdl_seq * a;
- Token * async_var;
- asdl_seq* b;
- void *tc;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- &&
- (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
- &&
- (a = _gather_44_rule(p)) // ','.with_item+
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// with_item: expression ['as' target]
-static withitem_ty
-with_item_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- withitem_ty _res = NULL;
- int _mark = p->mark;
- { // expression ['as' target]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' target]"));
- expr_ty e;
- void *o;
- if (
- (e = expression_rule(p)) // expression
- &&
- (o = _tmp_46_rule(p), 1) // ['as' target]
- )
- {
- D(fprintf(stderr, "%*c+ with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' target]"));
- _res = _Py_withitem ( e , o , p -> arena );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s with_item[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' target]"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// try_stmt:
-// | 'try' ':' block finally_block
-// | 'try' ':' block except_block+ else_block? finally_block?
-static stmt_ty
-try_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'try' ':' block finally_block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block finally_block"));
- Token * _keyword;
- Token * _literal;
- asdl_seq* b;
- asdl_seq* f;
- if (
- (_keyword = _PyPegen_expect_token(p, 511)) // token='try'
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- &&
- (f = finally_block_rule(p)) // finally_block
- )
- {
- D(fprintf(stderr, "%*c+ try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block finally_block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Try ( b , NULL , NULL , f , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block finally_block"));
- }
- { // 'try' ':' block except_block+ else_block? finally_block?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block except_block+ else_block? finally_block?"));
- Token * _keyword;
- Token * _literal;
- asdl_seq* b;
- void *el;
- asdl_seq * ex;
- void *f;
- if (
- (_keyword = _PyPegen_expect_token(p, 511)) // token='try'
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- &&
- (ex = _loop1_47_rule(p)) // except_block+
- &&
- (el = else_block_rule(p), 1) // else_block?
- &&
- (f = finally_block_rule(p), 1) // finally_block?
- )
- {
- D(fprintf(stderr, "%*c+ try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block except_block+ else_block? finally_block?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Try ( b , ex , el , f , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block except_block+ else_block? finally_block?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// except_block: 'except' expression ['as' NAME] ':' block | 'except' ':' block
-static excepthandler_ty
-except_block_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- excepthandler_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'except' expression ['as' NAME] ':' block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block"));
- Token * _keyword;
- Token * _literal;
- asdl_seq* b;
- expr_ty e;
- void *t;
- if (
- (_keyword = _PyPegen_expect_token(p, 520)) // token='except'
- &&
- (e = expression_rule(p)) // expression
- &&
- (t = _tmp_48_rule(p), 1) // ['as' NAME]
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] ':' block"));
- }
- { // 'except' ':' block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' ':' block"));
- Token * _keyword;
- Token * _literal;
- asdl_seq* b;
- if (
- (_keyword = _PyPegen_expect_token(p, 520)) // token='except'
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' ':' block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' ':' block"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// finally_block: 'finally' ':' block
-static asdl_seq*
-finally_block_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // 'finally' ':' block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> finally_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally' ':' block"));
- Token * _keyword;
- Token * _literal;
- asdl_seq* a;
- if (
- (_keyword = _PyPegen_expect_token(p, 521)) // token='finally'
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (a = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ finally_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally' ':' block"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s finally_block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally' ':' block"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// return_stmt: 'return' star_expressions?
-static stmt_ty
-return_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'return' star_expressions?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?"));
- Token * _keyword;
- void *a;
- if (
- (_keyword = _PyPegen_expect_token(p, 500)) // token='return'
- &&
- (a = star_expressions_rule(p), 1) // star_expressions?
- )
- {
- D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Return ( a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// raise_stmt: 'raise' expression ['from' expression] | 'raise'
-static stmt_ty
-raise_stmt_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'raise' expression ['from' expression]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]"));
- Token * _keyword;
- expr_ty a;
- void *b;
- if (
- (_keyword = _PyPegen_expect_token(p, 501)) // token='raise'
- &&
- (a = expression_rule(p)) // expression
- &&
- (b = _tmp_49_rule(p), 1) // ['from' expression]
- )
- {
- D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Raise ( a , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]"));
- }
- { // 'raise'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 501)) // token='raise'
- )
- {
- D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Raise ( NULL , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// function_def: decorators function_def_raw | function_def_raw
-static stmt_ty
-function_def_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- { // decorators function_def_raw
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw"));
- asdl_seq* d;
- stmt_ty f;
- if (
- (d = decorators_rule(p)) // decorators
- &&
- (f = function_def_raw_rule(p)) // function_def_raw
- )
- {
- D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw"));
- _res = _PyPegen_function_def_decorators ( p , d , f );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators function_def_raw"));
- }
- { // function_def_raw
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "function_def_raw"));
- stmt_ty function_def_raw_var;
- if (
- (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw
- )
- {
- D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "function_def_raw"));
- _res = function_def_raw_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "function_def_raw"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// function_def_raw:
-// | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
-// | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
-static stmt_ty
-function_def_raw_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
- Token * _keyword;
- Token * _literal;
- Token * _literal_1;
- Token * _literal_2;
- void *a;
- asdl_seq* b;
- expr_ty n;
- void *params;
- void *tc;
- if (
- (_keyword = _PyPegen_expect_token(p, 522)) // token='def'
- &&
- (n = _PyPegen_name_token(p)) // NAME
- &&
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (params = params_rule(p), 1) // params?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- &&
- (a = _tmp_50_rule(p), 1) // ['->' expression]
- &&
- (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (tc = func_type_comment_rule(p), 1) // func_type_comment?
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
- }
- { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
- Token * _keyword;
- Token * _literal;
- Token * _literal_1;
- Token * _literal_2;
- void *a;
- Token * async_var;
- asdl_seq* b;
- expr_ty n;
- void *params;
- void *tc;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- &&
- (_keyword = _PyPegen_expect_token(p, 522)) // token='def'
- &&
- (n = _PyPegen_name_token(p)) // NAME
- &&
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (params = params_rule(p), 1) // params?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- &&
- (a = _tmp_51_rule(p), 1) // ['->' expression]
- &&
- (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (tc = func_type_comment_rule(p), 1) // func_type_comment?
- &&
- (b = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// func_type_comment:
-// | NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
-// | invalid_double_type_comments
-// | TYPE_COMMENT
-static Token*
-func_type_comment_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- Token* _res = NULL;
- int _mark = p->mark;
- { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)"));
- Token * newline_var;
- Token * t;
- if (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- &&
- (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
- &&
- _PyPegen_lookahead(1, _tmp_52_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)"));
- _res = t;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)"));
- }
- { // invalid_double_type_comments
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments"));
- void *invalid_double_type_comments_var;
- if (
- (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments
- )
- {
- D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments"));
- _res = invalid_double_type_comments_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments"));
- }
- { // TYPE_COMMENT
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT"));
- Token * type_comment_var;
- if (
- (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
- )
- {
- D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT"));
- _res = type_comment_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// params: invalid_parameters | parameters
-static arguments_ty
-params_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arguments_ty _res = NULL;
- int _mark = p->mark;
- { // invalid_parameters
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_parameters"));
- void *invalid_parameters_var;
- if (
- (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters
- )
- {
- D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_parameters"));
- _res = invalid_parameters_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_parameters"));
- }
- { // parameters
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "parameters"));
- arguments_ty parameters_var;
- if (
- (parameters_var = parameters_rule(p)) // parameters
- )
- {
- D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "parameters"));
- _res = parameters_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "parameters"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// parameters:
-// | slash_no_default param_no_default* param_with_default* star_etc?
-// | slash_with_default param_with_default* star_etc?
-// | param_no_default+ param_with_default* star_etc?
-// | param_with_default+ star_etc?
-// | star_etc
-static arguments_ty
-parameters_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arguments_ty _res = NULL;
- int _mark = p->mark;
- { // slash_no_default param_no_default* param_with_default* star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?"));
- asdl_seq* a;
- asdl_seq * b;
- asdl_seq * c;
- void *d;
- if (
- (a = slash_no_default_rule(p)) // slash_no_default
- &&
- (b = _loop0_53_rule(p)) // param_no_default*
- &&
- (c = _loop0_54_rule(p)) // param_with_default*
- &&
- (d = star_etc_rule(p), 1) // star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?"));
- _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?"));
- }
- { // slash_with_default param_with_default* star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?"));
- SlashWithDefault* a;
- asdl_seq * b;
- void *c;
- if (
- (a = slash_with_default_rule(p)) // slash_with_default
- &&
- (b = _loop0_55_rule(p)) // param_with_default*
- &&
- (c = star_etc_rule(p), 1) // star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?"));
- _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default param_with_default* star_etc?"));
- }
- { // param_no_default+ param_with_default* star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?"));
- asdl_seq * a;
- asdl_seq * b;
- void *c;
- if (
- (a = _loop1_56_rule(p)) // param_no_default+
- &&
- (b = _loop0_57_rule(p)) // param_with_default*
- &&
- (c = star_etc_rule(p), 1) // star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?"));
- _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ param_with_default* star_etc?"));
- }
- { // param_with_default+ star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?"));
- asdl_seq * a;
- void *b;
- if (
- (a = _loop1_58_rule(p)) // param_with_default+
- &&
- (b = star_etc_rule(p), 1) // star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?"));
- _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+ star_etc?"));
- }
- { // star_etc
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_etc"));
- StarEtc* a;
- if (
- (a = star_etc_rule(p)) // star_etc
- )
- {
- D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_etc"));
- _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_etc"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')'
-static asdl_seq*
-slash_no_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // param_no_default+ '/' ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * a;
- if (
- (a = _loop1_59_rule(p)) // param_no_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' ','"));
- }
- { // param_no_default+ '/' &')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'"));
- Token * _literal;
- asdl_seq * a;
- if (
- (a = _loop1_60_rule(p)) // param_no_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' &')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// slash_with_default:
-// | param_no_default* param_with_default+ '/' ','
-// | param_no_default* param_with_default+ '/' &')'
-static SlashWithDefault*
-slash_with_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- SlashWithDefault* _res = NULL;
- int _mark = p->mark;
- { // param_no_default* param_with_default+ '/' ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * a;
- asdl_seq * b;
- if (
- (a = _loop0_61_rule(p)) // param_no_default*
- &&
- (b = _loop1_62_rule(p)) // param_with_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','"));
- _res = _PyPegen_slash_with_default ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' ','"));
- }
- { // param_no_default* param_with_default+ '/' &')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'"));
- Token * _literal;
- asdl_seq * a;
- asdl_seq * b;
- if (
- (a = _loop0_63_rule(p)) // param_no_default*
- &&
- (b = _loop1_64_rule(p)) // param_with_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'"));
- _res = _PyPegen_slash_with_default ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' &')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// star_etc:
-// | '*' param_no_default param_maybe_default* kwds?
-// | '*' ',' param_maybe_default+ kwds?
-// | kwds
-// | invalid_star_etc
-static StarEtc*
-star_etc_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- StarEtc* _res = NULL;
- int _mark = p->mark;
- { // '*' param_no_default param_maybe_default* kwds?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?"));
- Token * _literal;
- arg_ty a;
- asdl_seq * b;
- void *c;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = param_no_default_rule(p)) // param_no_default
- &&
- (b = _loop0_65_rule(p)) // param_maybe_default*
- &&
- (c = kwds_rule(p), 1) // kwds?
- )
- {
- D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?"));
- _res = _PyPegen_star_etc ( p , a , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?"));
- }
- { // '*' ',' param_maybe_default+ kwds?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * b;
- void *c;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (b = _loop1_66_rule(p)) // param_maybe_default+
- &&
- (c = kwds_rule(p), 1) // kwds?
- )
- {
- D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?"));
- _res = _PyPegen_star_etc ( p , NULL , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' param_maybe_default+ kwds?"));
- }
- { // kwds
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwds"));
- arg_ty a;
- if (
- (a = kwds_rule(p)) // kwds
- )
- {
- D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwds"));
- _res = _PyPegen_star_etc ( p , NULL , NULL , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwds"));
- }
- { // invalid_star_etc
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_star_etc"));
- void *invalid_star_etc_var;
- if (
- (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc
- )
- {
- D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_star_etc"));
- _res = invalid_star_etc_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_star_etc"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// kwds: '**' param_no_default
-static arg_ty
-kwds_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arg_ty _res = NULL;
- int _mark = p->mark;
- { // '**' param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param_no_default"));
- Token * _literal;
- arg_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (a = param_no_default_rule(p)) // param_no_default
- )
- {
- D(fprintf(stderr, "%*c+ kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param_no_default"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwds[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param_no_default"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')'
-static arg_ty
-param_no_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arg_ty _res = NULL;
- int _mark = p->mark;
- { // param ',' TYPE_COMMENT?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?"));
- Token * _literal;
- arg_ty a;
- void *tc;
- if (
- (a = param_rule(p)) // param
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- )
- {
- D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?"));
- _res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param ',' TYPE_COMMENT?"));
- }
- { // param TYPE_COMMENT? &')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'"));
- arg_ty a;
- void *tc;
- if (
- (a = param_rule(p)) // param
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'"));
- _res = _PyPegen_add_type_comment_to_arg ( p , a , tc );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param TYPE_COMMENT? &')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')'
-static NameDefaultPair*
-param_with_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- NameDefaultPair* _res = NULL;
- int _mark = p->mark;
- { // param default ',' TYPE_COMMENT?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?"));
- Token * _literal;
- arg_ty a;
- expr_ty c;
- void *tc;
- if (
- (a = param_rule(p)) // param
- &&
- (c = default_rule(p)) // default
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- )
- {
- D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?"));
- _res = _PyPegen_name_default_pair ( p , a , c , tc );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default ',' TYPE_COMMENT?"));
- }
- { // param default TYPE_COMMENT? &')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'"));
- arg_ty a;
- expr_ty c;
- void *tc;
- if (
- (a = param_rule(p)) // param
- &&
- (c = default_rule(p)) // default
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'"));
- _res = _PyPegen_name_default_pair ( p , a , c , tc );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default TYPE_COMMENT? &')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// param_maybe_default:
-// | param default? ',' TYPE_COMMENT?
-// | param default? TYPE_COMMENT? &')'
-static NameDefaultPair*
-param_maybe_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- NameDefaultPair* _res = NULL;
- int _mark = p->mark;
- { // param default? ',' TYPE_COMMENT?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?"));
- Token * _literal;
- arg_ty a;
- void *c;
- void *tc;
- if (
- (a = param_rule(p)) // param
- &&
- (c = default_rule(p), 1) // default?
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- )
- {
- D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?"));
- _res = _PyPegen_name_default_pair ( p , a , c , tc );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? ',' TYPE_COMMENT?"));
- }
- { // param default? TYPE_COMMENT? &')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'"));
- arg_ty a;
- void *c;
- void *tc;
- if (
- (a = param_rule(p)) // param
- &&
- (c = default_rule(p), 1) // default?
- &&
- (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT?
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'"));
- _res = _PyPegen_name_default_pair ( p , a , c , tc );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? TYPE_COMMENT? &')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// param: NAME annotation?
-static arg_ty
-param_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arg_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME annotation?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME annotation?"));
- expr_ty a;
- void *b;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- &&
- (b = annotation_rule(p), 1) // annotation?
- )
- {
- D(fprintf(stderr, "%*c+ param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME annotation?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s param[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME annotation?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// annotation: ':' expression
-static expr_ty
-annotation_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- { // ':' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> annotation[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ annotation[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s annotation[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// default: '=' expression
-static expr_ty
-default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- { // '=' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' expression"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- &&
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' expression"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// decorators: (('@' named_expression NEWLINE))+
-static asdl_seq*
-decorators_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // (('@' named_expression NEWLINE))+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+"));
- asdl_seq * a;
- if (
- (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+
- )
- {
- D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s decorators[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(('@' named_expression NEWLINE))+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// class_def: decorators class_def_raw | class_def_raw
-static stmt_ty
-class_def_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- { // decorators class_def_raw
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw"));
- asdl_seq* a;
- stmt_ty b;
- if (
- (a = decorators_rule(p)) // decorators
- &&
- (b = class_def_raw_rule(p)) // class_def_raw
- )
- {
- D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw"));
- _res = _PyPegen_class_def_decorators ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators class_def_raw"));
- }
- { // class_def_raw
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_def_raw"));
- stmt_ty class_def_raw_var;
- if (
- (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw
- )
- {
- D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_def_raw"));
- _res = class_def_raw_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_def_raw"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block
-static stmt_ty
-class_def_raw_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- stmt_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'class' NAME ['(' arguments? ')'] ':' block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block"));
- Token * _keyword;
- Token * _literal;
- expr_ty a;
- void *b;
- asdl_seq* c;
- if (
- (_keyword = _PyPegen_expect_token(p, 523)) // token='class'
- &&
- (a = _PyPegen_name_token(p)) // NAME
- &&
- (b = _tmp_68_rule(p), 1) // ['(' arguments? ')']
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (c = block_rule(p)) // block
- )
- {
- D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
-static asdl_seq*
-block_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- if (_PyPegen_is_memoized(p, block_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- { // NEWLINE INDENT statements DEDENT
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
- asdl_seq* a;
- Token * dedent_var;
- Token * indent_var;
- Token * newline_var;
- if (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- &&
- (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
- &&
- (a = statements_rule(p)) // statements
- &&
- (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT'
- )
- {
- D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
- }
- { // simple_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- asdl_seq* simple_stmt_var;
- if (
- (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
- )
- {
- D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
- _res = simple_stmt_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
- }
- { // invalid_block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_block"));
- void *invalid_block_var;
- if (
- (invalid_block_var = invalid_block_rule(p)) // invalid_block
- )
- {
- D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_block"));
- _res = invalid_block_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_block"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, block_type, _res);
- D(p->level--);
- return _res;
-}
-
-// expressions_list: ','.star_expression+ ','?
-static asdl_seq*
-expressions_list_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.star_expression+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expressions_list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- if (
- (a = _gather_69_rule(p)) // ','.star_expression+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ expressions_list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expressions_list[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_expression+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// star_expressions:
-// | star_expression ((',' star_expression))+ ','?
-// | star_expression ','
-// | star_expression
-static expr_ty
-star_expressions_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // star_expression ((',' star_expression))+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- expr_ty a;
- asdl_seq * b;
- if (
- (a = star_expression_rule(p)) // star_expression
- &&
- (b = _loop1_71_rule(p)) // ((',' star_expression))+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ((',' star_expression))+ ','?"));
- }
- { // star_expression ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ','"));
- Token * _literal;
- expr_ty a;
- if (
- (a = star_expression_rule(p)) // star_expression
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ','"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ','"));
- }
- { // star_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression"));
- expr_ty star_expression_var;
- if (
- (star_expression_var = star_expression_rule(p)) // star_expression
- )
- {
- D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression"));
- _res = star_expression_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// star_expression: '*' bitwise_or | expression
-static expr_ty
-star_expression_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, star_expression_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '*' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Starred ( a , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or"));
- }
- { // expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression"));
- expr_ty expression_var;
- if (
- (expression_var = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression"));
- _res = expression_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, star_expression_type, _res);
- D(p->level--);
- return _res;
-}
-
-// star_named_expressions: ','.star_named_expression+ ','?
-static asdl_seq*
-star_named_expressions_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.star_named_expression+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_named_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- if (
- (a = _gather_72_rule(p)) // ','.star_named_expression+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ star_named_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_named_expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_named_expression+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// star_named_expression: '*' bitwise_or | named_expression
-static expr_ty
-star_named_expression_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '*' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Starred ( a , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or"));
- }
- { // named_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression"));
- expr_ty named_expression_var;
- if (
- (named_expression_var = named_expression_rule(p)) // named_expression
- )
- {
- D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression"));
- _res = named_expression_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression
-static expr_ty
-named_expression_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME ':=' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- &&
- (_literal = _PyPegen_expect_token(p, 53)) // token=':='
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' expression"));
- }
- { // expression !':='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='"));
- expr_ty expression_var;
- if (
- (expression_var = expression_rule(p)) // expression
- &&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':='
- )
- {
- D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='"));
- _res = expression_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='"));
- }
- { // invalid_named_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_named_expression"));
- void *invalid_named_expression_var;
- if (
- (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression
- )
- {
- D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_named_expression"));
- _res = invalid_named_expression_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_named_expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// annotated_rhs: yield_expr | star_expressions
-static expr_ty
-annotated_rhs_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- { // yield_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- expr_ty yield_expr_var;
- if (
- (yield_expr_var = yield_expr_rule(p)) // yield_expr
- )
- {
- D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- _res = yield_expr_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
- }
- { // star_expressions
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- expr_ty star_expressions_var;
- if (
- (star_expressions_var = star_expressions_rule(p)) // star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- _res = star_expressions_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// expressions: expression ((',' expression))+ ','? | expression ',' | expression
-static expr_ty
-expressions_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // expression ((',' expression))+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- expr_ty a;
- asdl_seq * b;
- if (
- (a = expression_rule(p)) // expression
- &&
- (b = _loop1_74_rule(p)) // ((',' expression))+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ((',' expression))+ ','?"));
- }
- { // expression ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ','"));
- Token * _literal;
- expr_ty a;
- if (
- (a = expression_rule(p)) // expression
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ','"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ','"));
- }
- { // expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression"));
- expr_ty expression_var;
- if (
- (expression_var = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression"));
- _res = expression_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef
-static expr_ty
-expression_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, expression_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // disjunction 'if' disjunction 'else' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression"));
- Token * _keyword;
- Token * _keyword_1;
- expr_ty a;
- expr_ty b;
- expr_ty c;
- if (
- (a = disjunction_rule(p)) // disjunction
- &&
- (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
- &&
- (b = disjunction_rule(p)) // disjunction
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else'
- &&
- (c = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_IfExp ( b , a , c , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression"));
- }
- { // disjunction
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction"));
- expr_ty disjunction_var;
- if (
- (disjunction_var = disjunction_rule(p)) // disjunction
- )
- {
- D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction"));
- _res = disjunction_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction"));
- }
- { // lambdef
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef"));
- expr_ty lambdef_var;
- if (
- (lambdef_var = lambdef_rule(p)) // lambdef
- )
- {
- D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef"));
- _res = lambdef_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, expression_type, _res);
- D(p->level--);
- return _res;
-}
-
-// lambdef: 'lambda' lambda_params? ':' expression
-static expr_ty
-lambdef_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'lambda' lambda_params? ':' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambdef[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression"));
- Token * _keyword;
- Token * _literal;
- void *a;
- expr_ty b;
- if (
- (_keyword = _PyPegen_expect_token(p, 524)) // token='lambda'
- &&
- (a = lambda_params_rule(p), 1) // lambda_params?
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ lambdef[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambdef[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_params: invalid_lambda_parameters | lambda_parameters
-static arguments_ty
-lambda_params_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arguments_ty _res = NULL;
- int _mark = p->mark;
- { // invalid_lambda_parameters
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters"));
- void *invalid_lambda_parameters_var;
- if (
- (invalid_lambda_parameters_var = invalid_lambda_parameters_rule(p)) // invalid_lambda_parameters
- )
- {
- D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters"));
- _res = invalid_lambda_parameters_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_parameters"));
- }
- { // lambda_parameters
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_parameters"));
- arguments_ty lambda_parameters_var;
- if (
- (lambda_parameters_var = lambda_parameters_rule(p)) // lambda_parameters
- )
- {
- D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_parameters"));
- _res = lambda_parameters_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_parameters"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_parameters:
-// | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
-// | lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
-// | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
-// | lambda_param_with_default+ lambda_star_etc?
-// | lambda_star_etc
-static arguments_ty
-lambda_parameters_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arguments_ty _res = NULL;
- int _mark = p->mark;
- { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?"));
- asdl_seq* a;
- asdl_seq * b;
- asdl_seq * c;
- void *d;
- if (
- (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default
- &&
- (b = _loop0_75_rule(p)) // lambda_param_no_default*
- &&
- (c = _loop0_76_rule(p)) // lambda_param_with_default*
- &&
- (d = lambda_star_etc_rule(p), 1) // lambda_star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?"));
- _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?"));
- }
- { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?"));
- SlashWithDefault* a;
- asdl_seq * b;
- void *c;
- if (
- (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
- &&
- (b = _loop0_77_rule(p)) // lambda_param_with_default*
- &&
- (c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?"));
- _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?"));
- }
- { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?"));
- asdl_seq * a;
- asdl_seq * b;
- void *c;
- if (
- (a = _loop1_78_rule(p)) // lambda_param_no_default+
- &&
- (b = _loop0_79_rule(p)) // lambda_param_with_default*
- &&
- (c = lambda_star_etc_rule(p), 1) // lambda_star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?"));
- _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?"));
- }
- { // lambda_param_with_default+ lambda_star_etc?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?"));
- asdl_seq * a;
- void *b;
- if (
- (a = _loop1_80_rule(p)) // lambda_param_with_default+
- &&
- (b = lambda_star_etc_rule(p), 1) // lambda_star_etc?
- )
- {
- D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?"));
- _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?"));
- }
- { // lambda_star_etc
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_star_etc"));
- StarEtc* a;
- if (
- (a = lambda_star_etc_rule(p)) // lambda_star_etc
- )
- {
- D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_star_etc"));
- _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_star_etc"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_slash_no_default:
-// | lambda_param_no_default+ '/' ','
-// | lambda_param_no_default+ '/' &':'
-static asdl_seq*
-lambda_slash_no_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // lambda_param_no_default+ '/' ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * a;
- if (
- (a = _loop1_81_rule(p)) // lambda_param_no_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' ','"));
- }
- { // lambda_param_no_default+ '/' &':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'"));
- Token * _literal;
- asdl_seq * a;
- if (
- (a = _loop1_82_rule(p)) // lambda_param_no_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' &':'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_slash_with_default:
-// | lambda_param_no_default* lambda_param_with_default+ '/' ','
-// | lambda_param_no_default* lambda_param_with_default+ '/' &':'
-static SlashWithDefault*
-lambda_slash_with_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- SlashWithDefault* _res = NULL;
- int _mark = p->mark;
- { // lambda_param_no_default* lambda_param_with_default+ '/' ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * a;
- asdl_seq * b;
- if (
- (a = _loop0_83_rule(p)) // lambda_param_no_default*
- &&
- (b = _loop1_84_rule(p)) // lambda_param_with_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','"));
- _res = _PyPegen_slash_with_default ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','"));
- }
- { // lambda_param_no_default* lambda_param_with_default+ '/' &':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'"));
- Token * _literal;
- asdl_seq * a;
- asdl_seq * b;
- if (
- (a = _loop0_85_rule(p)) // lambda_param_no_default*
- &&
- (b = _loop1_86_rule(p)) // lambda_param_with_default+
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'"));
- _res = _PyPegen_slash_with_default ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_star_etc:
-// | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
-// | '*' ',' lambda_param_maybe_default+ lambda_kwds?
-// | lambda_kwds
-// | invalid_lambda_star_etc
-static StarEtc*
-lambda_star_etc_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- StarEtc* _res = NULL;
- int _mark = p->mark;
- { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?"));
- Token * _literal;
- arg_ty a;
- asdl_seq * b;
- void *c;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
- &&
- (b = _loop0_87_rule(p)) // lambda_param_maybe_default*
- &&
- (c = lambda_kwds_rule(p), 1) // lambda_kwds?
- )
- {
- D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?"));
- _res = _PyPegen_star_etc ( p , a , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?"));
- }
- { // '*' ',' lambda_param_maybe_default+ lambda_kwds?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * b;
- void *c;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (b = _loop1_88_rule(p)) // lambda_param_maybe_default+
- &&
- (c = lambda_kwds_rule(p), 1) // lambda_kwds?
- )
- {
- D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?"));
- _res = _PyPegen_star_etc ( p , NULL , b , c );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?"));
- }
- { // lambda_kwds
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_kwds"));
- arg_ty a;
- if (
- (a = lambda_kwds_rule(p)) // lambda_kwds
- )
- {
- D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_kwds"));
- _res = _PyPegen_star_etc ( p , NULL , NULL , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_kwds"));
- }
- { // invalid_lambda_star_etc
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc"));
- void *invalid_lambda_star_etc_var;
- if (
- (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc
- )
- {
- D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc"));
- _res = invalid_lambda_star_etc_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_star_etc"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_kwds: '**' lambda_param_no_default
-static arg_ty
-lambda_kwds_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arg_ty _res = NULL;
- int _mark = p->mark;
- { // '**' lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default"));
- Token * _literal;
- arg_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (a = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- D(fprintf(stderr, "%*c+ lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param_no_default"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_param_no_default: lambda_param ',' | lambda_param &':'
-static arg_ty
-lambda_param_no_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arg_ty _res = NULL;
- int _mark = p->mark;
- { // lambda_param ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param ','"));
- Token * _literal;
- arg_ty a;
- if (
- (a = lambda_param_rule(p)) // lambda_param
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param ','"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param ','"));
- }
- { // lambda_param &':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param &':'"));
- arg_ty a;
- if (
- (a = lambda_param_rule(p)) // lambda_param
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param &':'"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param &':'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_param_with_default: lambda_param default ',' | lambda_param default &':'
-static NameDefaultPair*
-lambda_param_with_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- NameDefaultPair* _res = NULL;
- int _mark = p->mark;
- { // lambda_param default ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default ','"));
- Token * _literal;
- arg_ty a;
- expr_ty c;
- if (
- (a = lambda_param_rule(p)) // lambda_param
- &&
- (c = default_rule(p)) // default
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default ','"));
- _res = _PyPegen_name_default_pair ( p , a , c , NULL );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default ','"));
- }
- { // lambda_param default &':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'"));
- arg_ty a;
- expr_ty c;
- if (
- (a = lambda_param_rule(p)) // lambda_param
- &&
- (c = default_rule(p)) // default
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'"));
- _res = _PyPegen_name_default_pair ( p , a , c , NULL );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default &':'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':'
-static NameDefaultPair*
-lambda_param_maybe_default_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- NameDefaultPair* _res = NULL;
- int _mark = p->mark;
- { // lambda_param default? ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','"));
- Token * _literal;
- arg_ty a;
- void *c;
- if (
- (a = lambda_param_rule(p)) // lambda_param
- &&
- (c = default_rule(p), 1) // default?
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','"));
- _res = _PyPegen_name_default_pair ( p , a , c , NULL );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? ','"));
- }
- { // lambda_param default? &':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'"));
- arg_ty a;
- void *c;
- if (
- (a = lambda_param_rule(p)) // lambda_param
- &&
- (c = default_rule(p), 1) // default?
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'"));
- _res = _PyPegen_name_default_pair ( p , a , c , NULL );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? &':'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lambda_param: NAME
-static arg_ty
-lambda_param_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- arg_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lambda_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
- expr_ty a;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ lambda_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lambda_param[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// disjunction: conjunction (('or' conjunction))+ | conjunction
-static expr_ty
-disjunction_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, disjunction_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // conjunction (('or' conjunction))+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+"));
- expr_ty a;
- asdl_seq * b;
- if (
- (a = conjunction_rule(p)) // conjunction
- &&
- (b = _loop1_89_rule(p)) // (('or' conjunction))+
- )
- {
- D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction (('or' conjunction))+"));
- }
- { // conjunction
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction"));
- expr_ty conjunction_var;
- if (
- (conjunction_var = conjunction_rule(p)) // conjunction
- )
- {
- D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction"));
- _res = conjunction_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, disjunction_type, _res);
- D(p->level--);
- return _res;
-}
-
-// conjunction: inversion (('and' inversion))+ | inversion
-static expr_ty
-conjunction_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, conjunction_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // inversion (('and' inversion))+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+"));
- expr_ty a;
- asdl_seq * b;
- if (
- (a = inversion_rule(p)) // inversion
- &&
- (b = _loop1_90_rule(p)) // (('and' inversion))+
- )
- {
- D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion (('and' inversion))+"));
- }
- { // inversion
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion"));
- expr_ty inversion_var;
- if (
- (inversion_var = inversion_rule(p)) // inversion
- )
- {
- D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion"));
- _res = inversion_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, conjunction_type, _res);
- D(p->level--);
- return _res;
-}
-
-// inversion: 'not' inversion | comparison
-static expr_ty
-inversion_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, inversion_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'not' inversion
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' inversion"));
- Token * _keyword;
- expr_ty a;
- if (
- (_keyword = _PyPegen_expect_token(p, 525)) // token='not'
- &&
- (a = inversion_rule(p)) // inversion
- )
- {
- D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' inversion"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_UnaryOp ( Not , a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' inversion"));
- }
- { // comparison
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "comparison"));
- expr_ty comparison_var;
- if (
- (comparison_var = comparison_rule(p)) // comparison
- )
- {
- D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "comparison"));
- _res = comparison_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "comparison"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, inversion_type, _res);
- D(p->level--);
- return _res;
-}
-
-// comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or
-static expr_ty
-comparison_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // bitwise_or compare_op_bitwise_or_pair+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+"));
- expr_ty a;
- asdl_seq * b;
- if (
- (a = bitwise_or_rule(p)) // bitwise_or
- &&
- (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+
- )
- {
- D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+"));
- }
- { // bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or"));
- expr_ty bitwise_or_var;
- if (
- (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or"));
- _res = bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// compare_op_bitwise_or_pair:
-// | eq_bitwise_or
-// | noteq_bitwise_or
-// | lte_bitwise_or
-// | lt_bitwise_or
-// | gte_bitwise_or
-// | gt_bitwise_or
-// | notin_bitwise_or
-// | in_bitwise_or
-// | isnot_bitwise_or
-// | is_bitwise_or
-static CmpopExprPair*
-compare_op_bitwise_or_pair_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // eq_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or"));
- CmpopExprPair* eq_bitwise_or_var;
- if (
- (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or"));
- _res = eq_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "eq_bitwise_or"));
- }
- { // noteq_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or"));
- CmpopExprPair* noteq_bitwise_or_var;
- if (
- (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or"));
- _res = noteq_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "noteq_bitwise_or"));
- }
- { // lte_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or"));
- CmpopExprPair* lte_bitwise_or_var;
- if (
- (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or"));
- _res = lte_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lte_bitwise_or"));
- }
- { // lt_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or"));
- CmpopExprPair* lt_bitwise_or_var;
- if (
- (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or"));
- _res = lt_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lt_bitwise_or"));
- }
- { // gte_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or"));
- CmpopExprPair* gte_bitwise_or_var;
- if (
- (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or"));
- _res = gte_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gte_bitwise_or"));
- }
- { // gt_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or"));
- CmpopExprPair* gt_bitwise_or_var;
- if (
- (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or"));
- _res = gt_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gt_bitwise_or"));
- }
- { // notin_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or"));
- CmpopExprPair* notin_bitwise_or_var;
- if (
- (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or"));
- _res = notin_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "notin_bitwise_or"));
- }
- { // in_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "in_bitwise_or"));
- CmpopExprPair* in_bitwise_or_var;
- if (
- (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "in_bitwise_or"));
- _res = in_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "in_bitwise_or"));
- }
- { // isnot_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or"));
- CmpopExprPair* isnot_bitwise_or_var;
- if (
- (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or"));
- _res = isnot_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "isnot_bitwise_or"));
- }
- { // is_bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "is_bitwise_or"));
- CmpopExprPair* is_bitwise_or_var;
- if (
- (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "is_bitwise_or"));
- _res = is_bitwise_or_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "is_bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// eq_bitwise_or: '==' bitwise_or
-static CmpopExprPair*
-eq_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // '==' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> eq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 27)) // token='=='
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ eq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , Eq , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s eq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// noteq_bitwise_or: ('!=') bitwise_or
-static CmpopExprPair*
-noteq_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // ('!=') bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or"));
- void *_tmp_92_var;
- expr_ty a;
- if (
- (_tmp_92_var = _tmp_92_rule(p)) // '!='
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ noteq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s noteq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lte_bitwise_or: '<=' bitwise_or
-static CmpopExprPair*
-lte_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // '<=' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 29)) // token='<='
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ lte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , LtE , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// lt_bitwise_or: '<' bitwise_or
-static CmpopExprPair*
-lt_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // '<' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> lt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 20)) // token='<'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ lt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , Lt , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s lt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// gte_bitwise_or: '>=' bitwise_or
-static CmpopExprPair*
-gte_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // '>=' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> gte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 30)) // token='>='
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ gte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , GtE , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s gte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// gt_bitwise_or: '>' bitwise_or
-static CmpopExprPair*
-gt_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // '>' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> gt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 21)) // token='>'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ gt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , Gt , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s gt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// notin_bitwise_or: 'not' 'in' bitwise_or
-static CmpopExprPair*
-notin_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // 'not' 'in' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> notin_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or"));
- Token * _keyword;
- Token * _keyword_1;
- expr_ty a;
- if (
- (_keyword = _PyPegen_expect_token(p, 525)) // token='not'
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ notin_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s notin_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// in_bitwise_or: 'in' bitwise_or
-static CmpopExprPair*
-in_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // 'in' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> in_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or"));
- Token * _keyword;
- expr_ty a;
- if (
- (_keyword = _PyPegen_expect_token(p, 518)) // token='in'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ in_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , In , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s in_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// isnot_bitwise_or: 'is' 'not' bitwise_or
-static CmpopExprPair*
-isnot_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // 'is' 'not' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> isnot_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or"));
- Token * _keyword;
- Token * _keyword_1;
- expr_ty a;
- if (
- (_keyword = _PyPegen_expect_token(p, 526)) // token='is'
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 525)) // token='not'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ isnot_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s isnot_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// is_bitwise_or: 'is' bitwise_or
-static CmpopExprPair*
-is_bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- CmpopExprPair* _res = NULL;
- int _mark = p->mark;
- { // 'is' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> is_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or"));
- Token * _keyword;
- expr_ty a;
- if (
- (_keyword = _PyPegen_expect_token(p, 526)) // token='is'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ is_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or"));
- _res = _PyPegen_cmpop_expr_pair ( p , Is , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s is_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor
-static expr_ty bitwise_or_raw(Parser *);
-static expr_ty
-bitwise_or_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res);
- if (tmpvar_1) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = bitwise_or_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-bitwise_or_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // bitwise_or '|' bitwise_xor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = bitwise_or_rule(p)) // bitwise_or
- &&
- (_literal = _PyPegen_expect_token(p, 18)) // token='|'
- &&
- (b = bitwise_xor_rule(p)) // bitwise_xor
- )
- {
- D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , BitOr , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor"));
- }
- { // bitwise_xor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor"));
- expr_ty bitwise_xor_var;
- if (
- (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor
- )
- {
- D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor"));
- _res = bitwise_xor_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and
-static expr_ty bitwise_xor_raw(Parser *);
-static expr_ty
-bitwise_xor_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res);
- if (tmpvar_2) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = bitwise_xor_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-bitwise_xor_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // bitwise_xor '^' bitwise_and
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = bitwise_xor_rule(p)) // bitwise_xor
- &&
- (_literal = _PyPegen_expect_token(p, 32)) // token='^'
- &&
- (b = bitwise_and_rule(p)) // bitwise_and
- )
- {
- D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , BitXor , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and"));
- }
- { // bitwise_and
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and"));
- expr_ty bitwise_and_var;
- if (
- (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and
- )
- {
- D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and"));
- _res = bitwise_and_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// bitwise_and: bitwise_and '&' shift_expr | shift_expr
-static expr_ty bitwise_and_raw(Parser *);
-static expr_ty
-bitwise_and_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res);
- if (tmpvar_3) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = bitwise_and_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-bitwise_and_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // bitwise_and '&' shift_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = bitwise_and_rule(p)) // bitwise_and
- &&
- (_literal = _PyPegen_expect_token(p, 19)) // token='&'
- &&
- (b = shift_expr_rule(p)) // shift_expr
- )
- {
- D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , BitAnd , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr"));
- }
- { // shift_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr"));
- expr_ty shift_expr_var;
- if (
- (shift_expr_var = shift_expr_rule(p)) // shift_expr
- )
- {
- D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr"));
- _res = shift_expr_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum
-static expr_ty shift_expr_raw(Parser *);
-static expr_ty
-shift_expr_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res);
- if (tmpvar_4) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = shift_expr_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-shift_expr_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // shift_expr '<<' sum
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = shift_expr_rule(p)) // shift_expr
- &&
- (_literal = _PyPegen_expect_token(p, 33)) // token='<<'
- &&
- (b = sum_rule(p)) // sum
- )
- {
- D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , LShift , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum"));
- }
- { // shift_expr '>>' sum
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = shift_expr_rule(p)) // shift_expr
- &&
- (_literal = _PyPegen_expect_token(p, 34)) // token='>>'
- &&
- (b = sum_rule(p)) // sum
- )
- {
- D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , RShift , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum"));
- }
- { // sum
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum"));
- expr_ty sum_var;
- if (
- (sum_var = sum_rule(p)) // sum
- )
- {
- D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum"));
- _res = sum_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// sum: sum '+' term | sum '-' term | term
-static expr_ty sum_raw(Parser *);
-static expr_ty
-sum_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, sum_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res);
- if (tmpvar_5) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = sum_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-sum_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // sum '+' term
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = sum_rule(p)) // sum
- &&
- (_literal = _PyPegen_expect_token(p, 14)) // token='+'
- &&
- (b = term_rule(p)) // term
- )
- {
- D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , Add , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term"));
- }
- { // sum '-' term
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = sum_rule(p)) // sum
- &&
- (_literal = _PyPegen_expect_token(p, 15)) // token='-'
- &&
- (b = term_rule(p)) // term
- )
- {
- D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , Sub , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term"));
- }
- { // term
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term"));
- expr_ty term_var;
- if (
- (term_var = term_rule(p)) // term
- )
- {
- D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term"));
- _res = term_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// term:
-// | term '*' factor
-// | term '/' factor
-// | term '//' factor
-// | term '%' factor
-// | term '@' factor
-// | factor
-static expr_ty term_raw(Parser *);
-static expr_ty
-term_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, term_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res);
- if (tmpvar_6) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = term_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-term_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // term '*' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = term_rule(p)) // term
- &&
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (b = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , Mult , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor"));
- }
- { // term '/' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = term_rule(p)) // term
- &&
- (_literal = _PyPegen_expect_token(p, 17)) // token='/'
- &&
- (b = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , Div , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor"));
- }
- { // term '//' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = term_rule(p)) // term
- &&
- (_literal = _PyPegen_expect_token(p, 47)) // token='//'
- &&
- (b = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , FloorDiv , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor"));
- }
- { // term '%' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = term_rule(p)) // term
- &&
- (_literal = _PyPegen_expect_token(p, 24)) // token='%'
- &&
- (b = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , Mod , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor"));
- }
- { // term '@' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = term_rule(p)) // term
- &&
- (_literal = _PyPegen_expect_token(p, 49)) // token='@'
- &&
- (b = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '@' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '@' factor"));
- }
- { // factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "factor"));
- expr_ty factor_var;
- if (
- (factor_var = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "factor"));
- _res = factor_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "factor"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// factor: '+' factor | '-' factor | '~' factor | power
-static expr_ty
-factor_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, factor_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '+' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' factor"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 14)) // token='+'
- &&
- (a = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_UnaryOp ( UAdd , a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' factor"));
- }
- { // '-' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' factor"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 15)) // token='-'
- &&
- (a = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_UnaryOp ( USub , a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' factor"));
- }
- { // '~' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~' factor"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 31)) // token='~'
- &&
- (a = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_UnaryOp ( Invert , a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~' factor"));
- }
- { // power
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "power"));
- expr_ty power_var;
- if (
- (power_var = power_rule(p)) // power
- )
- {
- D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "power"));
- _res = power_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "power"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, factor_type, _res);
- D(p->level--);
- return _res;
-}
-
-// power: await_primary '**' factor | await_primary
-static expr_ty
-power_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // await_primary '**' factor
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = await_primary_rule(p)) // await_primary
- &&
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (b = factor_rule(p)) // factor
- )
- {
- D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_BinOp ( a , Pow , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary '**' factor"));
- }
- { // await_primary
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary"));
- expr_ty await_primary_var;
- if (
- (await_primary_var = await_primary_rule(p)) // await_primary
- )
- {
- D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary"));
- _res = await_primary_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// await_primary: AWAIT primary | primary
-static expr_ty
-await_primary_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, await_primary_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // AWAIT primary
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "AWAIT primary"));
- expr_ty a;
- Token * await_var;
- if (
- (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT'
- &&
- (a = primary_rule(p)) // primary
- )
- {
- D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "AWAIT primary"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "AWAIT primary"));
- }
- { // primary
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary"));
- expr_ty primary_var;
- if (
- (primary_var = primary_rule(p)) // primary
- )
- {
- D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary"));
- _res = primary_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, await_primary_type, _res);
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// primary:
-// | primary '.' NAME
-// | primary genexp
-// | primary '(' arguments? ')'
-// | primary '[' slices ']'
-// | atom
-static expr_ty primary_raw(Parser *);
-static expr_ty
-primary_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, primary_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res);
- if (tmpvar_7) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = primary_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-primary_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // primary '.' NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '.' NAME"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = primary_rule(p)) // primary
- &&
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- &&
- (b = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '.' NAME"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '.' NAME"));
- }
- { // primary genexp
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary genexp"));
- expr_ty a;
- expr_ty b;
- if (
- (a = primary_rule(p)) // primary
- &&
- (b = genexp_rule(p)) // genexp
- )
- {
- D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary genexp"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary genexp"));
- }
- { // primary '(' arguments? ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- void *b;
- if (
- (a = primary_rule(p)) // primary
- &&
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (b = arguments_rule(p), 1) // arguments?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '(' arguments? ')'"));
- }
- { // primary '[' slices ']'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- expr_ty b;
- if (
- (a = primary_rule(p)) // primary
- &&
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (b = slices_rule(p)) // slices
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- )
- {
- D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Subscript ( a , b , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '[' slices ']'"));
- }
- { // atom
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom"));
- expr_ty atom_var;
- if (
- (atom_var = atom_rule(p)) // atom
- )
- {
- D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom"));
- _res = atom_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// slices: slice !',' | ','.slice+ ','?
-static expr_ty
-slices_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // slice !','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice !','"));
- expr_ty a;
- if (
- (a = slice_rule(p)) // slice
- &&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice !','"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice !','"));
- }
- { // ','.slice+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- if (
- (a = _gather_93_rule(p)) // ','.slice+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( a , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.slice+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// slice: expression? ':' expression? [':' expression?] | expression
-static expr_ty
-slice_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // expression? ':' expression? [':' expression?]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]"));
- Token * _literal;
- void *a;
- void *b;
- void *c;
- if (
- (a = expression_rule(p), 1) // expression?
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = expression_rule(p), 1) // expression?
- &&
- (c = _tmp_95_rule(p), 1) // [':' expression?]
- )
- {
- D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Slice ( a , b , c , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression? ':' expression? [':' expression?]"));
- }
- { // expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression"));
- expr_ty a;
- if (
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// atom:
-// | NAME
-// | 'True'
-// | 'False'
-// | 'None'
-// | &STRING strings
-// | NUMBER
-// | &'(' (tuple | group | genexp)
-// | &'[' (list | listcomp)
-// | &'{' (dict | set | dictcomp | setcomp)
-// | '...'
-static expr_ty
-atom_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
- expr_ty name_var;
- if (
- (name_var = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
- _res = name_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
- }
- { // 'True'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 527)) // token='True'
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Constant ( Py_True , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'"));
- }
- { // 'False'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 528)) // token='False'
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Constant ( Py_False , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'"));
- }
- { // 'None'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 529)) // token='None'
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Constant ( Py_None , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'"));
- }
- { // &STRING strings
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&STRING strings"));
- expr_ty strings_var;
- if (
- _PyPegen_lookahead(1, _PyPegen_string_token, p)
- &&
- (strings_var = strings_rule(p)) // strings
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&STRING strings"));
- _res = strings_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&STRING strings"));
- }
- { // NUMBER
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER"));
- expr_ty number_var;
- if (
- (number_var = _PyPegen_number_token(p)) // NUMBER
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER"));
- _res = number_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER"));
- }
- { // &'(' (tuple | group | genexp)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)"));
- void *_tmp_96_var;
- if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='('
- &&
- (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)"));
- _res = _tmp_96_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'(' (tuple | group | genexp)"));
- }
- { // &'[' (list | listcomp)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)"));
- void *_tmp_97_var;
- if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='['
- &&
- (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)"));
- _res = _tmp_97_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'[' (list | listcomp)"));
- }
- { // &'{' (dict | set | dictcomp | setcomp)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
- void *_tmp_98_var;
- if (
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{'
- &&
- (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
- _res = _tmp_98_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)"));
- }
- { // '...'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 52)) // token='...'
- )
- {
- D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// strings: STRING+
-static expr_ty
-strings_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, strings_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- { // STRING+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+"));
- asdl_seq * a;
- if (
- (a = _loop1_99_rule(p)) // STRING+
- )
- {
- D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+"));
- _res = _PyPegen_concatenate_strings ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s strings[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING+"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, strings_type, _res);
- D(p->level--);
- return _res;
-}
-
-// list: '[' star_named_expressions? ']'
-static expr_ty
-list_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '[' star_named_expressions? ']'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (a = star_named_expressions_rule(p), 1) // star_named_expressions?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- )
- {
- D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_List ( a , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s list[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_named_expressions? ']'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension
-static expr_ty
-listcomp_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '[' named_expression for_if_clauses ']'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- asdl_seq* b;
- if (
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (a = named_expression_rule(p)) // named_expression
- &&
- (b = for_if_clauses_rule(p)) // for_if_clauses
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- )
- {
- D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_ListComp ( a , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' named_expression for_if_clauses ']'"));
- }
- { // invalid_comprehension
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
- void *invalid_comprehension_var;
- if (
- (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
- )
- {
- D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
- _res = invalid_comprehension_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// tuple: '(' [star_named_expression ',' star_named_expressions?] ')'
-static expr_ty
-tuple_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '(' [star_named_expression ',' star_named_expressions?] ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?]
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( a , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s tuple[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// group: '(' (yield_expr | named_expression) ')'
-static expr_ty
-group_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- { // '(' (yield_expr | named_expression) ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = _tmp_101_rule(p)) // yield_expr | named_expression
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s group[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' (yield_expr | named_expression) ')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// genexp: '(' expression for_if_clauses ')' | invalid_comprehension
-static expr_ty
-genexp_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '(' expression for_if_clauses ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- asdl_seq* b;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = expression_rule(p)) // expression
- &&
- (b = for_if_clauses_rule(p)) // for_if_clauses
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_GeneratorExp ( a , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' expression for_if_clauses ')'"));
- }
- { // invalid_comprehension
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
- void *invalid_comprehension_var;
- if (
- (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
- )
- {
- D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
- _res = invalid_comprehension_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// set: '{' expressions_list '}'
-static expr_ty
-set_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '{' expressions_list '}'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq* a;
- if (
- (_literal = _PyPegen_expect_token(p, 25)) // token='{'
- &&
- (a = expressions_list_rule(p)) // expressions_list
- &&
- (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
- )
- {
- D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Set ( a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expressions_list '}'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// setcomp: '{' expression for_if_clauses '}' | invalid_comprehension
-static expr_ty
-setcomp_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '{' expression for_if_clauses '}'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- asdl_seq* b;
- if (
- (_literal = _PyPegen_expect_token(p, 25)) // token='{'
- &&
- (a = expression_rule(p)) // expression
- &&
- (b = for_if_clauses_rule(p)) // for_if_clauses
- &&
- (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
- )
- {
- D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_SetComp ( a , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expression for_if_clauses '}'"));
- }
- { // invalid_comprehension
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
- void *invalid_comprehension_var;
- if (
- (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension
- )
- {
- D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension"));
- _res = invalid_comprehension_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// dict: '{' double_starred_kvpairs? '}'
-static expr_ty
-dict_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '{' double_starred_kvpairs? '}'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> dict[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 25)) // token='{'
- &&
- (a = double_starred_kvpairs_rule(p), 1) // double_starred_kvpairs?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
- )
- {
- D(fprintf(stderr, "%*c+ dict[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s dict[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' double_starred_kvpairs? '}'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// dictcomp: '{' kvpair for_if_clauses '}' | invalid_dict_comprehension
-static expr_ty
-dictcomp_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '{' kvpair for_if_clauses '}'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'"));
- Token * _literal;
- Token * _literal_1;
- KeyValuePair* a;
- asdl_seq* b;
- if (
- (_literal = _PyPegen_expect_token(p, 25)) // token='{'
- &&
- (a = kvpair_rule(p)) // kvpair
- &&
- (b = for_if_clauses_rule(p)) // for_if_clauses
- &&
- (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
- )
- {
- D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' kvpair for_if_clauses '}'"));
- }
- { // invalid_dict_comprehension
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension"));
- void *invalid_dict_comprehension_var;
- if (
- (invalid_dict_comprehension_var = invalid_dict_comprehension_rule(p)) // invalid_dict_comprehension
- )
- {
- D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension"));
- _res = invalid_dict_comprehension_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_dict_comprehension"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// double_starred_kvpairs: ','.double_starred_kvpair+ ','?
-static asdl_seq*
-double_starred_kvpairs_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.double_starred_kvpair+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- if (
- (a = _gather_102_rule(p)) // ','.double_starred_kvpair+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// double_starred_kvpair: '**' bitwise_or | kvpair
-static KeyValuePair*
-double_starred_kvpair_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- KeyValuePair* _res = NULL;
- int _mark = p->mark;
- { // '**' bitwise_or
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (a = bitwise_or_rule(p)) // bitwise_or
- )
- {
- D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or"));
- _res = _PyPegen_key_value_pair ( p , NULL , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or"));
- }
- { // kvpair
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kvpair"));
- KeyValuePair* kvpair_var;
- if (
- (kvpair_var = kvpair_rule(p)) // kvpair
- )
- {
- D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kvpair"));
- _res = kvpair_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kvpair"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// kvpair: expression ':' expression
-static KeyValuePair*
-kvpair_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- KeyValuePair* _res = NULL;
- int _mark = p->mark;
- { // expression ':' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = expression_rule(p)) // expression
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression"));
- _res = _PyPegen_key_value_pair ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kvpair[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// for_if_clauses: for_if_clause+
-static asdl_seq*
-for_if_clauses_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // for_if_clause+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+"));
- asdl_seq * _loop1_104_var;
- if (
- (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+
- )
- {
- D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+"));
- _res = _loop1_104_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s for_if_clauses[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// for_if_clause:
-// | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
-// | 'for' star_targets 'in' disjunction (('if' disjunction))*
-static comprehension_ty
-for_if_clause_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- comprehension_ty _res = NULL;
- int _mark = p->mark;
- { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*"));
- Token * _keyword;
- Token * _keyword_1;
- expr_ty a;
- Token * async_var;
- expr_ty b;
- asdl_seq * c;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- &&
- (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
- &&
- (a = star_targets_rule(p)) // star_targets
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
- &&
- (b = disjunction_rule(p)) // disjunction
- &&
- (c = _loop0_105_rule(p)) // (('if' disjunction))*
- )
- {
- D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*"));
- _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*"));
- }
- { // 'for' star_targets 'in' disjunction (('if' disjunction))*
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*"));
- Token * _keyword;
- Token * _keyword_1;
- expr_ty a;
- expr_ty b;
- asdl_seq * c;
- if (
- (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
- &&
- (a = star_targets_rule(p)) // star_targets
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in'
- &&
- (b = disjunction_rule(p)) // disjunction
- &&
- (c = _loop0_106_rule(p)) // (('if' disjunction))*
- )
- {
- D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*"));
- _res = _Py_comprehension ( a , b , c , 0 , p -> arena );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// yield_expr: 'yield' 'from' expression | 'yield' star_expressions?
-static expr_ty
-yield_expr_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // 'yield' 'from' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression"));
- Token * _keyword;
- Token * _keyword_1;
- expr_ty a;
- if (
- (_keyword = _PyPegen_expect_token(p, 504)) // token='yield'
- &&
- (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from'
- &&
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_YieldFrom ( a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' 'from' expression"));
- }
- { // 'yield' star_expressions?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?"));
- Token * _keyword;
- void *a;
- if (
- (_keyword = _PyPegen_expect_token(p, 504)) // token='yield'
- &&
- (a = star_expressions_rule(p), 1) // star_expressions?
- )
- {
- D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Yield ( a , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' star_expressions?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// arguments: args ','? &')' | incorrect_arguments
-static expr_ty
-arguments_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, arguments_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- { // args ','? &')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','? &')'"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- expr_ty a;
- if (
- (a = args_rule(p)) // args
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- &&
- _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','? &')'"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','? &')'"));
- }
- { // incorrect_arguments
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "incorrect_arguments"));
- void *incorrect_arguments_var;
- if (
- (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments
- )
- {
- D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "incorrect_arguments"));
- _res = incorrect_arguments_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "incorrect_arguments"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, arguments_type, _res);
- D(p->level--);
- return _res;
-}
-
-// args: starred_expression [',' args] | kwargs | named_expression [',' args]
-static expr_ty
-args_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // starred_expression [',' args]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]"));
- expr_ty a;
- void *b;
- if (
- (a = starred_expression_rule(p)) // starred_expression
- &&
- (b = _tmp_107_rule(p), 1) // [',' args]
- )
- {
- D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression [',' args]"));
- }
- { // kwargs
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs"));
- asdl_seq* a;
- if (
- (a = kwargs_rule(p)) // kwargs
- )
- {
- D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs"));
- }
- { // named_expression [',' args]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]"));
- expr_ty a;
- void *b;
- if (
- (a = named_expression_rule(p)) // named_expression
- &&
- (b = _tmp_108_rule(p), 1) // [',' args]
- )
- {
- D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression [',' args]"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// kwargs:
-// | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
-// | ','.kwarg_or_starred+
-// | ','.kwarg_or_double_starred+
-static asdl_seq*
-kwargs_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+"));
- Token * _literal;
- asdl_seq * a;
- asdl_seq * b;
- if (
- (a = _gather_109_rule(p)) // ','.kwarg_or_starred+
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+
- )
- {
- D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+"));
- _res = _PyPegen_join_sequences ( p , a , b );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+"));
- }
- { // ','.kwarg_or_starred+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+"));
- asdl_seq * _gather_113_var;
- if (
- (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+
- )
- {
- D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+"));
- _res = _gather_113_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+"));
- }
- { // ','.kwarg_or_double_starred+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+"));
- asdl_seq * _gather_115_var;
- if (
- (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+
- )
- {
- D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+"));
- _res = _gather_115_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_double_starred+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// starred_expression: '*' expression
-static expr_ty
-starred_expression_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '*' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Starred ( a , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s starred_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg
-static KeywordOrStarred*
-kwarg_or_starred_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- KeywordOrStarred* _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME '=' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression"));
- }
- { // starred_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression"));
- expr_ty a;
- if (
- (a = starred_expression_rule(p)) // starred_expression
- )
- {
- D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression"));
- _res = _PyPegen_keyword_or_starred ( p , a , 0 );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression"));
- }
- { // invalid_kwarg
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
- void *invalid_kwarg_var;
- if (
- (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
- )
- {
- D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
- _res = invalid_kwarg_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg
-static KeywordOrStarred*
-kwarg_or_double_starred_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- KeywordOrStarred* _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME '=' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- &&
- (b = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression"));
- }
- { // '**' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression"));
- Token * _literal;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (a = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression"));
- }
- { // invalid_kwarg
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
- void *invalid_kwarg_var;
- if (
- (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg
- )
- {
- D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg"));
- _res = invalid_kwarg_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// star_targets: star_target !',' | star_target ((',' star_target))* ','?
-static expr_ty
-star_targets_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // star_target !','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target !','"));
- expr_ty a;
- if (
- (a = star_target_rule(p)) // star_target
- &&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target !','"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target !','"));
- }
- { // star_target ((',' star_target))* ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- expr_ty a;
- asdl_seq * b;
- if (
- (a = star_target_rule(p)) // star_target
- &&
- (b = _loop0_117_rule(p)) // ((',' star_target))*
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))* ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// star_targets_seq: ','.star_target+ ','?
-static asdl_seq*
-star_targets_seq_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.star_target+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_targets_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- if (
- (a = _gather_118_rule(p)) // ','.star_target+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ star_targets_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_targets_seq[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_target+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// star_target:
-// | '*' (!'*' star_target)
-// | t_primary '.' NAME !t_lookahead
-// | t_primary '[' slices ']' !t_lookahead
-// | star_atom
-static expr_ty
-star_target_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, star_target_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // '*' (!'*' star_target)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)"));
- Token * _literal;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (a = _tmp_120_rule(p)) // !'*' star_target
- )
- {
- D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (!'*' star_target)"));
- }
- { // t_primary '.' NAME !t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- &&
- (b = _PyPegen_name_token(p)) // NAME
- &&
- _PyPegen_lookahead(0, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- }
- { // t_primary '[' slices ']' !t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (b = slices_rule(p)) // slices
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- &&
- _PyPegen_lookahead(0, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Subscript ( a , b , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- }
- { // star_atom
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_atom"));
- expr_ty star_atom_var;
- if (
- (star_atom_var = star_atom_rule(p)) // star_atom
- )
- {
- D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_atom"));
- _res = star_atom_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_atom"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, star_target_type, _res);
- D(p->level--);
- return _res;
-}
-
-// star_atom:
-// | NAME
-// | '(' star_target ')'
-// | '(' star_targets_seq? ')'
-// | '[' star_targets_seq? ']'
-static expr_ty
-star_atom_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
- expr_ty a;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
- _res = _PyPegen_set_expr_context ( p , a , Store );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
- }
- { // '(' star_target ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = star_target_rule(p)) // star_target
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'"));
- _res = _PyPegen_set_expr_context ( p , a , Store );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_target ')'"));
- }
- { // '(' star_targets_seq? ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = star_targets_seq_rule(p), 1) // star_targets_seq?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( a , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_targets_seq? ')'"));
- }
- { // '[' star_targets_seq? ']'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (a = star_targets_seq_rule(p), 1) // star_targets_seq?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- )
- {
- D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_List ( a , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_targets_seq? ']'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// single_target: single_subscript_attribute_target | NAME | '(' single_target ')'
-static expr_ty
-single_target_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- { // single_subscript_attribute_target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
- expr_ty single_subscript_attribute_target_var;
- if (
- (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target
- )
- {
- D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
- _res = single_subscript_attribute_target_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target"));
- }
- { // NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
- expr_ty a;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
- _res = _PyPegen_set_expr_context ( p , a , Store );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
- }
- { // '(' single_target ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = single_target_rule(p)) // single_target
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// single_subscript_attribute_target:
-// | t_primary '.' NAME !t_lookahead
-// | t_primary '[' slices ']' !t_lookahead
-static expr_ty
-single_subscript_attribute_target_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // t_primary '.' NAME !t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- &&
- (b = _PyPegen_name_token(p)) // NAME
- &&
- _PyPegen_lookahead(0, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- }
- { // t_primary '[' slices ']' !t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (b = slices_rule(p)) // slices
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- &&
- _PyPegen_lookahead(0, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Subscript ( a , b , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// del_targets: ','.del_target+ ','?
-static asdl_seq*
-del_targets_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.del_target+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- if (
- (a = _gather_121_rule(p)) // ','.del_target+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// del_target:
-// | t_primary '.' NAME &del_target_end
-// | t_primary '[' slices ']' &del_target_end
-// | del_t_atom
-static expr_ty
-del_target_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, del_target_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // t_primary '.' NAME &del_target_end
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- &&
- (b = _PyPegen_name_token(p)) // NAME
- &&
- _PyPegen_lookahead(1, del_target_end_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &del_target_end"));
- }
- { // t_primary '[' slices ']' &del_target_end
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (b = slices_rule(p)) // slices
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- &&
- _PyPegen_lookahead(1, del_target_end_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Subscript ( a , b , Del , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &del_target_end"));
- }
- { // del_t_atom
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_t_atom"));
- expr_ty del_t_atom_var;
- if (
- (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom
- )
- {
- D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_t_atom"));
- _res = del_t_atom_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_t_atom"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, del_target_type, _res);
- D(p->level--);
- return _res;
-}
-
-// del_t_atom:
-// | NAME &del_target_end
-// | '(' del_target ')'
-// | '(' del_targets? ')'
-// | '[' del_targets? ']'
-// | invalid_del_target
-static expr_ty
-del_t_atom_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME &del_target_end
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end"));
- expr_ty a;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- &&
- _PyPegen_lookahead(1, del_target_end_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end"));
- _res = _PyPegen_set_expr_context ( p , a , Del );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME &del_target_end"));
- }
- { // '(' del_target ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = del_target_rule(p)) // del_target
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'"));
- _res = _PyPegen_set_expr_context ( p , a , Del );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_target ')'"));
- }
- { // '(' del_targets? ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = del_targets_rule(p), 1) // del_targets?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( a , Del , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_targets? ')'"));
- }
- { // '[' del_targets? ']'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'"));
- Token * _literal;
- Token * _literal_1;
- void *a;
- if (
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (a = del_targets_rule(p), 1) // del_targets?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- )
- {
- D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_List ( a , Del , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' del_targets? ']'"));
- }
- { // invalid_del_target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_del_target"));
- void *invalid_del_target_var;
- if (
- (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target
- )
- {
- D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_del_target"));
- _res = invalid_del_target_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_del_target"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// del_target_end: ')' | ']' | ',' | ';' | NEWLINE
-static void *
-del_target_end_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
- }
- { // ']'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "']'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 10)) // token=']'
- )
- {
- D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "']'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "']'"));
- }
- { // ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','"));
- }
- { // ';'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 13)) // token=';'
- )
- {
- D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'"));
- }
- { // NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
- Token * newline_var;
- if (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
- _res = newline_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// targets: ','.target+ ','?
-static asdl_seq*
-targets_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq* _res = NULL;
- int _mark = p->mark;
- { // ','.target+ ','?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.target+ ','?"));
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- asdl_seq * a;
- if (
- (a = _gather_123_rule(p)) // ','.target+
- &&
- (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','?
- )
- {
- D(fprintf(stderr, "%*c+ targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.target+ ','?"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.target+ ','?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// target:
-// | t_primary '.' NAME !t_lookahead
-// | t_primary '[' slices ']' !t_lookahead
-// | t_atom
-static expr_ty
-target_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, target_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // t_primary '.' NAME !t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- &&
- (b = _PyPegen_name_token(p)) // NAME
- &&
- _PyPegen_lookahead(0, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead"));
- }
- { // t_primary '[' slices ']' !t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (b = slices_rule(p)) // slices
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- &&
- _PyPegen_lookahead(0, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Subscript ( a , b , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead"));
- }
- { // t_atom
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_atom"));
- expr_ty t_atom_var;
- if (
- (t_atom_var = t_atom_rule(p)) // t_atom
- )
- {
- D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_atom"));
- _res = t_atom_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_atom"));
- }
- _res = NULL;
- done:
- _PyPegen_insert_memo(p, _mark, target_type, _res);
- D(p->level--);
- return _res;
-}
-
-// Left-recursive
-// t_primary:
-// | t_primary '.' NAME &t_lookahead
-// | t_primary '[' slices ']' &t_lookahead
-// | t_primary genexp &t_lookahead
-// | t_primary '(' arguments? ')' &t_lookahead
-// | atom &t_lookahead
-static expr_ty t_primary_raw(Parser *);
-static expr_ty
-t_primary_rule(Parser *p)
-{
- D(p->level++);
- expr_ty _res = NULL;
- if (_PyPegen_is_memoized(p, t_primary_type, &_res)) {
- D(p->level--);
- return _res;
- }
- int _mark = p->mark;
- int _resmark = p->mark;
- while (1) {
- int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res);
- if (tmpvar_8) {
- D(p->level--);
- return _res;
- }
- p->mark = _mark;
- void *_raw = t_primary_raw(p);
- if (_raw == NULL || p->mark <= _resmark)
- break;
- _resmark = p->mark;
- _res = _raw;
- }
- p->mark = _resmark;
- D(p->level--);
- return _res;
-}
-static expr_ty
-t_primary_raw(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // t_primary '.' NAME &t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead"));
- Token * _literal;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- &&
- (b = _PyPegen_name_token(p)) // NAME
- &&
- _PyPegen_lookahead(1, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &t_lookahead"));
- }
- { // t_primary '[' slices ']' &t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (b = slices_rule(p)) // slices
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- &&
- _PyPegen_lookahead(1, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Subscript ( a , b , Load , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &t_lookahead"));
- }
- { // t_primary genexp &t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead"));
- expr_ty a;
- expr_ty b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (b = genexp_rule(p)) // genexp
- &&
- _PyPegen_lookahead(1, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary genexp &t_lookahead"));
- }
- { // t_primary '(' arguments? ')' &t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- void *b;
- if (
- (a = t_primary_rule(p)) // t_primary
- &&
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (b = arguments_rule(p), 1) // arguments?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- &&
- _PyPegen_lookahead(1, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead"));
- }
- { // atom &t_lookahead
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead"));
- expr_ty a;
- if (
- (a = atom_rule(p)) // atom
- &&
- _PyPegen_lookahead(1, t_lookahead_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead"));
- _res = a;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom &t_lookahead"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// t_lookahead: '(' | '[' | '.'
-static void *
-t_lookahead_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '('
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- )
- {
- D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('"));
- }
- { // '['
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- )
- {
- D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['"));
- }
- { // '.'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- )
- {
- D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']'
-static expr_ty
-t_atom_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- expr_ty _res = NULL;
- int _mark = p->mark;
- if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- int _start_lineno = p->tokens[_mark]->lineno;
- 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
- { // NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME"));
- expr_ty a;
- if (
- (a = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME"));
- _res = _PyPegen_set_expr_context ( p , a , Store );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME"));
- }
- { // '(' target ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target ')'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty a;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (a = target_rule(p)) // target
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target ')'"));
- _res = _PyPegen_set_expr_context ( p , a , Store );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target ')'"));
- }
- { // '(' targets? ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'"));
- Token * _literal;
- Token * _literal_1;
- void *b;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (b = targets_rule(p), 1) // targets?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_Tuple ( b , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' targets? ')'"));
- }
- { // '[' targets? ']'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'"));
- Token * _literal;
- Token * _literal_1;
- void *b;
- if (
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- &&
- (b = targets_rule(p), 1) // targets?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']'
- )
- {
- D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'"));
- Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
- if (_token == NULL) {
- D(p->level--);
- return NULL;
- }
- int _end_lineno = _token->end_lineno;
- UNUSED(_end_lineno); // Only used by EXTRA macro
- int _end_col_offset = _token->end_col_offset;
- UNUSED(_end_col_offset); // Only used by EXTRA macro
- _res = _Py_List ( b , Store , EXTRA );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' targets? ']'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// incorrect_arguments:
-// | args ',' '*'
-// | expression for_if_clauses ',' [args | expression for_if_clauses]
-// | args for_if_clauses
-// | args ',' expression for_if_clauses
-// | args ',' args
-static void *
-incorrect_arguments_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // args ',' '*'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' '*'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty args_var;
- if (
- (args_var = args_rule(p)) // args
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*'
- )
- {
- D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' '*'"));
- _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' '*'"));
- }
- { // expression for_if_clauses ',' [args | expression for_if_clauses]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
- Token * _literal;
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- expr_ty a;
- asdl_seq* for_if_clauses_var;
- if (
- (a = expression_rule(p)) // expression
- &&
- (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses]
- )
- {
- D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]"));
- }
- { // args for_if_clauses
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses"));
- expr_ty a;
- asdl_seq* for_if_clauses_var;
- if (
- (a = args_rule(p)) // args
- &&
- (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
- )
- {
- D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses"));
- _res = _PyPegen_nonparen_genexp_in_call ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses"));
- }
- { // args ',' expression for_if_clauses
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses"));
- Token * _literal;
- expr_ty a;
- expr_ty args_var;
- asdl_seq* for_if_clauses_var;
- if (
- (args_var = args_rule(p)) // args
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (a = expression_rule(p)) // expression
- &&
- (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
- )
- {
- D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses"));
- }
- { // args ',' args
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args"));
- Token * _literal;
- expr_ty a;
- expr_ty args_var;
- if (
- (a = args_rule(p)) // args
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (args_var = args_rule(p)) // args
- )
- {
- D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args"));
- _res = _PyPegen_arguments_parsing_error ( p , a );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_kwarg: expression '='
-static void *
-invalid_kwarg_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // expression '='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression '='"));
- Token * _literal;
- expr_ty a;
- if (
- (a = expression_rule(p)) // expression
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- )
- {
- D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression '='"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression cannot contain assignment, perhaps you meant \"==\"?" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression '='"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_named_expression: expression ':=' expression
-static void *
-invalid_named_expression_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // expression ':=' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression"));
- Token * _literal;
- expr_ty a;
- expr_ty expression_var;
- if (
- (a = expression_rule(p)) // expression
- &&
- (_literal = _PyPegen_expect_token(p, 53)) // token=':='
- &&
- (expression_var = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_assignment:
-// | list ':'
-// | tuple ':'
-// | star_named_expression ',' star_named_expressions* ':'
-// | expression ':' expression ['=' annotated_rhs]
-// | ((star_targets '='))* star_expressions '='
-// | ((star_targets '='))* yield_expr '='
-// | star_expressions augassign (yield_expr | star_expressions)
-static void *
-invalid_assignment_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // list ':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list ':'"));
- Token * _literal;
- expr_ty a;
- if (
- (a = list_rule(p)) // list
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list ':'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not list) can be annotated" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list ':'"));
- }
- { // tuple ':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple ':'"));
- Token * _literal;
- expr_ty a;
- if (
- (a = tuple_rule(p)) // tuple
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple ':'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple ':'"));
- }
- { // star_named_expression ',' star_named_expressions* ':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'"));
- Token * _literal;
- Token * _literal_1;
- asdl_seq * _loop0_126_var;
- expr_ty a;
- if (
- (a = star_named_expression_rule(p)) // star_named_expression
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_loop0_126_var = _loop0_126_rule(p)) // star_named_expressions*
- &&
- (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'"));
- }
- { // expression ':' expression ['=' annotated_rhs]
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]"));
- Token * _literal;
- void *_opt_var;
- UNUSED(_opt_var); // Silence compiler warnings
- expr_ty a;
- expr_ty expression_var;
- if (
- (a = expression_rule(p)) // expression
- &&
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (expression_var = expression_rule(p)) // expression
- &&
- (_opt_var = _tmp_127_rule(p), 1) // ['=' annotated_rhs]
- )
- {
- D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression ['=' annotated_rhs]"));
- }
- { // ((star_targets '='))* star_expressions '='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='"));
- Token * _literal;
- asdl_seq * _loop0_128_var;
- expr_ty a;
- if (
- (_loop0_128_var = _loop0_128_rule(p)) // ((star_targets '='))*
- &&
- (a = star_expressions_rule(p)) // star_expressions
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- )
- {
- D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( _PyPegen_get_invalid_target ( a ) , "cannot assign to %s" , _PyPegen_get_expr_name ( _PyPegen_get_invalid_target ( a ) ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* star_expressions '='"));
- }
- { // ((star_targets '='))* yield_expr '='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='"));
- Token * _literal;
- asdl_seq * _loop0_129_var;
- expr_ty a;
- if (
- (_loop0_129_var = _loop0_129_rule(p)) // ((star_targets '='))*
- &&
- (a = yield_expr_rule(p)) // yield_expr
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- )
- {
- D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "assignment to yield expression not possible" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* yield_expr '='"));
- }
- { // star_expressions augassign (yield_expr | star_expressions)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
- void *_tmp_130_var;
- expr_ty a;
- AugOperator* augassign_var;
- if (
- (a = star_expressions_rule(p)) // star_expressions
- &&
- (augassign_var = augassign_rule(p)) // augassign
- &&
- (_tmp_130_var = _tmp_130_rule(p)) // yield_expr | star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_block: NEWLINE !INDENT
-static void *
-invalid_block_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // NEWLINE !INDENT
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT"));
- Token * newline_var;
- if (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- &&
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT
- )
- {
- D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT"));
- _res = RAISE_INDENTATION_ERROR ( "expected an indented block" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_block[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_comprehension: ('[' | '(' | '{') starred_expression for_if_clauses
-static void *
-invalid_comprehension_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ('[' | '(' | '{') starred_expression for_if_clauses
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses"));
- void *_tmp_131_var;
- expr_ty a;
- asdl_seq* for_if_clauses_var;
- if (
- (_tmp_131_var = _tmp_131_rule(p)) // '[' | '(' | '{'
- &&
- (a = starred_expression_rule(p)) // starred_expression
- &&
- (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
- )
- {
- D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "iterable unpacking cannot be used in comprehension" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_dict_comprehension: '{' '**' bitwise_or for_if_clauses '}'
-static void *
-invalid_dict_comprehension_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '{' '**' bitwise_or for_if_clauses '}'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_dict_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'"));
- Token * _literal;
- Token * _literal_1;
- Token * a;
- expr_ty bitwise_or_var;
- asdl_seq* for_if_clauses_var;
- if (
- (_literal = _PyPegen_expect_token(p, 25)) // token='{'
- &&
- (a = _PyPegen_expect_token(p, 35)) // token='**'
- &&
- (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or
- &&
- (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
- &&
- (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}'
- )
- {
- D(fprintf(stderr, "%*c+ invalid_dict_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "dict unpacking cannot be used in dict comprehension" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_dict_comprehension[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_parameters:
-// | param_no_default* (slash_with_default | param_with_default+) param_no_default
-static void *
-invalid_parameters_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // param_no_default* (slash_with_default | param_with_default+) param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default"));
- asdl_seq * _loop0_132_var;
- void *_tmp_133_var;
- arg_ty param_no_default_var;
- if (
- (_loop0_132_var = _loop0_132_rule(p)) // param_no_default*
- &&
- (_tmp_133_var = _tmp_133_rule(p)) // slash_with_default | param_with_default+
- &&
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default"));
- _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_lambda_parameters:
-// | lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default
-static void *
-invalid_lambda_parameters_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default"));
- asdl_seq * _loop0_134_var;
- void *_tmp_135_var;
- arg_ty lambda_param_no_default_var;
- if (
- (_loop0_134_var = _loop0_134_rule(p)) // lambda_param_no_default*
- &&
- (_tmp_135_var = _tmp_135_rule(p)) // lambda_slash_with_default | lambda_param_with_default+
- &&
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default"));
- _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT
-static void *
-invalid_star_etc_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '*' (')' | ',' (')' | '**'))
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
- Token * _literal;
- void *_tmp_136_var;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (_tmp_136_var = _tmp_136_rule(p)) // ')' | ',' (')' | '**')
- )
- {
- D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
- _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))"));
- }
- { // '*' ',' TYPE_COMMENT
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT"));
- Token * _literal;
- Token * _literal_1;
- Token * type_comment_var;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (_literal_1 = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
- )
- {
- D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT"));
- _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_lambda_star_etc: '*' (':' | ',' (':' | '**'))
-static void *
-invalid_lambda_star_etc_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '*' (':' | ',' (':' | '**'))
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
- Token * _literal;
- void *_tmp_137_var;
- if (
- (_literal = _PyPegen_expect_token(p, 16)) // token='*'
- &&
- (_tmp_137_var = _tmp_137_rule(p)) // ':' | ',' (':' | '**')
- )
- {
- D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
- _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
-static void *
-invalid_double_type_comments_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT"));
- Token * indent_var;
- Token * newline_var;
- Token * newline_var_1;
- Token * type_comment_var;
- Token * type_comment_var_1;
- if (
- (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
- &&
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- &&
- (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT'
- &&
- (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- &&
- (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
- )
- {
- D(fprintf(stderr, "%*c+ invalid_double_type_comments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT"));
- _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_double_type_comments[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_del_target: star_expression &del_target_end
-static void *
-invalid_del_target_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // star_expression &del_target_end
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end"));
- expr_ty a;
- if (
- (a = star_expression_rule(p)) // star_expression
- &&
- _PyPegen_lookahead(1, del_target_end_rule, p)
- )
- {
- D(fprintf(stderr, "%*c+ invalid_del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end"));
- _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot delete %s" , _PyPegen_get_expr_name ( a ) );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_del_target[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression &del_target_end"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// invalid_import_from_targets: import_from_as_names ','
-static void *
-invalid_import_from_targets_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // import_from_as_names ','
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','"));
- Token * _literal;
- asdl_seq* import_from_as_names_var;
- if (
- (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- )
- {
- D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','"));
- _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ','"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_1: NEWLINE
-static asdl_seq *
-_loop0_1_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
- Token * newline_var;
- while (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- _res = newline_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_1[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_2: NEWLINE
-static asdl_seq *
-_loop0_2_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE"));
- Token * newline_var;
- while (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- _res = newline_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_2[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_4: ',' expression
-static asdl_seq *
-_loop0_4_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = expression_rule(p)) // expression
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_4[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_3: expression _loop0_4
-static asdl_seq *
-_gather_3_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // expression _loop0_4
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_4"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = expression_rule(p)) // expression
- &&
- (seq = _loop0_4_rule(p)) // _loop0_4
- )
- {
- D(fprintf(stderr, "%*c+ _gather_3[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_4"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_3[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_4"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_6: ',' expression
-static asdl_seq *
-_loop0_6_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = expression_rule(p)) // expression
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_6[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_5: expression _loop0_6
-static asdl_seq *
-_gather_5_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // expression _loop0_6
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_6"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = expression_rule(p)) // expression
- &&
- (seq = _loop0_6_rule(p)) // _loop0_6
- )
- {
- D(fprintf(stderr, "%*c+ _gather_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_6"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_5[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_6"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_8: ',' expression
-static asdl_seq *
-_loop0_8_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = expression_rule(p)) // expression
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_8[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_7: expression _loop0_8
-static asdl_seq *
-_gather_7_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // expression _loop0_8
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_8"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = expression_rule(p)) // expression
- &&
- (seq = _loop0_8_rule(p)) // _loop0_8
- )
- {
- D(fprintf(stderr, "%*c+ _gather_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_8"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_7[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_8"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_10: ',' expression
-static asdl_seq *
-_loop0_10_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = expression_rule(p)) // expression
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_10[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_9: expression _loop0_10
-static asdl_seq *
-_gather_9_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // expression _loop0_10
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_10"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = expression_rule(p)) // expression
- &&
- (seq = _loop0_10_rule(p)) // _loop0_10
- )
- {
- D(fprintf(stderr, "%*c+ _gather_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_10"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_9[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_10"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_11: statement
-static asdl_seq *
-_loop1_11_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // statement
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement"));
- asdl_seq* statement_var;
- while (
- (statement_var = statement_rule(p)) // statement
- )
- {
- _res = statement_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_11[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_13: ';' small_stmt
-static asdl_seq *
-_loop0_13_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ';' small_stmt
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt"));
- Token * _literal;
- stmt_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 13)) // token=';'
- &&
- (elem = small_stmt_rule(p)) // small_stmt
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_12: small_stmt _loop0_13
-static asdl_seq *
-_gather_12_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // small_stmt _loop0_13
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
- stmt_ty elem;
- asdl_seq * seq;
- if (
- (elem = small_stmt_rule(p)) // small_stmt
- &&
- (seq = _loop0_13_rule(p)) // _loop0_13
- )
- {
- D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_14: 'import' | 'from'
-static void *
-_tmp_14_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'import'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 513)) // token='import'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'"));
- _res = _keyword;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'"));
- }
- { // 'from'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'"));
- _res = _keyword;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_15: 'def' | '@' | ASYNC
-static void *
-_tmp_15_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'def'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 522)) // token='def'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'"));
- _res = _keyword;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'"));
- }
- { // '@'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 49)) // token='@'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'"));
- }
- { // ASYNC
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC"));
- Token * async_var;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC"));
- _res = async_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_16: 'class' | '@'
-static void *
-_tmp_16_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'class'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 523)) // token='class'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'"));
- _res = _keyword;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'"));
- }
- { // '@'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 49)) // token='@'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_17: 'with' | ASYNC
-static void *
-_tmp_17_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'with'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 519)) // token='with'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'"));
- _res = _keyword;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'"));
- }
- { // ASYNC
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC"));
- Token * async_var;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC"));
- _res = async_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_18: 'for' | ASYNC
-static void *
-_tmp_18_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'for'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'"));
- Token * _keyword;
- if (
- (_keyword = _PyPegen_expect_token(p, 517)) // token='for'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'"));
- _res = _keyword;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'"));
- }
- { // ASYNC
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC"));
- Token * async_var;
- if (
- (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC"));
- _res = async_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_19: '=' annotated_rhs
-static void *
-_tmp_19_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '=' annotated_rhs
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
- Token * _literal;
- expr_ty d;
- if (
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- &&
- (d = annotated_rhs_rule(p)) // annotated_rhs
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_19[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
- _res = d;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_19[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_20: '(' single_target ')' | single_subscript_attribute_target
-static void *
-_tmp_20_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '(' single_target ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
- Token * _literal;
- Token * _literal_1;
- expr_ty b;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (b = single_target_rule(p)) // single_target
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'"));
- _res = b;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'"));
- }
- { // single_subscript_attribute_target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
- expr_ty single_subscript_attribute_target_var;
- if (
- (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target"));
- _res = single_subscript_attribute_target_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_21: '=' annotated_rhs
-static void *
-_tmp_21_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '=' annotated_rhs
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
- Token * _literal;
- expr_ty d;
- if (
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- &&
- (d = annotated_rhs_rule(p)) // annotated_rhs
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
- _res = d;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_22: (star_targets '=')
-static asdl_seq *
-_loop1_22_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // (star_targets '=')
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
- void *_tmp_138_var;
- while (
- (_tmp_138_var = _tmp_138_rule(p)) // star_targets '='
- )
- {
- _res = _tmp_138_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_22[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_23: yield_expr | star_expressions
-static void *
-_tmp_23_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // yield_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- expr_ty yield_expr_var;
- if (
- (yield_expr_var = yield_expr_rule(p)) // yield_expr
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- _res = yield_expr_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
- }
- { // star_expressions
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- expr_ty star_expressions_var;
- if (
- (star_expressions_var = star_expressions_rule(p)) // star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- _res = star_expressions_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_24: yield_expr | star_expressions
-static void *
-_tmp_24_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // yield_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- expr_ty yield_expr_var;
- if (
- (yield_expr_var = yield_expr_rule(p)) // yield_expr
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- _res = yield_expr_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
- }
- { // star_expressions
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- expr_ty star_expressions_var;
- if (
- (star_expressions_var = star_expressions_rule(p)) // star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- _res = star_expressions_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_26: ',' NAME
-static asdl_seq *
-_loop0_26_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = _PyPegen_name_token(p)) // NAME
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_26[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_25: NAME _loop0_26
-static asdl_seq *
-_gather_25_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // NAME _loop0_26
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = _PyPegen_name_token(p)) // NAME
- &&
- (seq = _loop0_26_rule(p)) // _loop0_26
- )
- {
- D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_28: ',' NAME
-static asdl_seq *
-_loop0_28_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = _PyPegen_name_token(p)) // NAME
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_27: NAME _loop0_28
-static asdl_seq *
-_gather_27_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // NAME _loop0_28
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = _PyPegen_name_token(p)) // NAME
- &&
- (seq = _loop0_28_rule(p)) // _loop0_28
- )
- {
- D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_29: ',' expression
-static void *
-_tmp_29_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ',' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
- Token * _literal;
- expr_ty z;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (z = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_29[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_30: ('.' | '...')
-static asdl_seq *
-_loop0_30_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ('.' | '...')
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')"));
- void *_tmp_139_var;
- while (
- (_tmp_139_var = _tmp_139_rule(p)) // '.' | '...'
- )
- {
- _res = _tmp_139_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_30[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_31: ('.' | '...')
-static asdl_seq *
-_loop1_31_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ('.' | '...')
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')"));
- void *_tmp_140_var;
- while (
- (_tmp_140_var = _tmp_140_rule(p)) // '.' | '...'
- )
- {
- _res = _tmp_140_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_31[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_33: ',' import_from_as_name
-static asdl_seq *
-_loop0_33_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' import_from_as_name
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name"));
- Token * _literal;
- alias_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = import_from_as_name_rule(p)) // import_from_as_name
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_32: import_from_as_name _loop0_33
-static asdl_seq *
-_gather_32_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // import_from_as_name _loop0_33
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33"));
- alias_ty elem;
- asdl_seq * seq;
- if (
- (elem = import_from_as_name_rule(p)) // import_from_as_name
- &&
- (seq = _loop0_33_rule(p)) // _loop0_33
- )
- {
- D(fprintf(stderr, "%*c+ _gather_32[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_32[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_33"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_34: 'as' NAME
-static void *
-_tmp_34_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'as' NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
- Token * _keyword;
- expr_ty z;
- if (
- (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
- &&
- (z = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_34[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_36: ',' dotted_as_name
-static asdl_seq *
-_loop0_36_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' dotted_as_name
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name"));
- Token * _literal;
- alias_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = dotted_as_name_rule(p)) // dotted_as_name
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_36[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_35: dotted_as_name _loop0_36
-static asdl_seq *
-_gather_35_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // dotted_as_name _loop0_36
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36"));
- alias_ty elem;
- asdl_seq * seq;
- if (
- (elem = dotted_as_name_rule(p)) // dotted_as_name
- &&
- (seq = _loop0_36_rule(p)) // _loop0_36
- )
- {
- D(fprintf(stderr, "%*c+ _gather_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_35[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_36"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_37: 'as' NAME
-static void *
-_tmp_37_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'as' NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
- Token * _keyword;
- expr_ty z;
- if (
- (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
- &&
- (z = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_37[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_37[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_39: ',' with_item
-static asdl_seq *
-_loop0_39_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' with_item
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
- Token * _literal;
- withitem_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = with_item_rule(p)) // with_item
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_38: with_item _loop0_39
-static asdl_seq *
-_gather_38_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // with_item _loop0_39
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39"));
- withitem_ty elem;
- asdl_seq * seq;
- if (
- (elem = with_item_rule(p)) // with_item
- &&
- (seq = _loop0_39_rule(p)) // _loop0_39
- )
- {
- D(fprintf(stderr, "%*c+ _gather_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_38[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_39"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_41: ',' with_item
-static asdl_seq *
-_loop0_41_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' with_item
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
- Token * _literal;
- withitem_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = with_item_rule(p)) // with_item
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_41[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_40: with_item _loop0_41
-static asdl_seq *
-_gather_40_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // with_item _loop0_41
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41"));
- withitem_ty elem;
- asdl_seq * seq;
- if (
- (elem = with_item_rule(p)) // with_item
- &&
- (seq = _loop0_41_rule(p)) // _loop0_41
- )
- {
- D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_41"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_43: ',' with_item
-static asdl_seq *
-_loop0_43_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' with_item
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
- Token * _literal;
- withitem_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = with_item_rule(p)) // with_item
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_43[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_42: with_item _loop0_43
-static asdl_seq *
-_gather_42_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // with_item _loop0_43
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43"));
- withitem_ty elem;
- asdl_seq * seq;
- if (
- (elem = with_item_rule(p)) // with_item
- &&
- (seq = _loop0_43_rule(p)) // _loop0_43
- )
- {
- D(fprintf(stderr, "%*c+ _gather_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_42[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_43"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_45: ',' with_item
-static asdl_seq *
-_loop0_45_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' with_item
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item"));
- Token * _literal;
- withitem_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = with_item_rule(p)) // with_item
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_45[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_44: with_item _loop0_45
-static asdl_seq *
-_gather_44_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // with_item _loop0_45
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45"));
- withitem_ty elem;
- asdl_seq * seq;
- if (
- (elem = with_item_rule(p)) // with_item
- &&
- (seq = _loop0_45_rule(p)) // _loop0_45
- )
- {
- D(fprintf(stderr, "%*c+ _gather_44[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_44[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_45"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_46: 'as' target
-static void *
-_tmp_46_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'as' target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' target"));
- Token * _keyword;
- expr_ty t;
- if (
- (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
- &&
- (t = target_rule(p)) // target
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_46[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' target"));
- _res = t;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_46[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' target"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_47: except_block
-static asdl_seq *
-_loop1_47_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // except_block
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block"));
- excepthandler_ty except_block_var;
- while (
- (except_block_var = except_block_rule(p)) // except_block
- )
- {
- _res = except_block_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_47[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_48: 'as' NAME
-static void *
-_tmp_48_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'as' NAME
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
- Token * _keyword;
- expr_ty z;
- if (
- (_keyword = _PyPegen_expect_token(p, 530)) // token='as'
- &&
- (z = _PyPegen_name_token(p)) // NAME
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_49: 'from' expression
-static void *
-_tmp_49_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'from' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression"));
- Token * _keyword;
- expr_ty z;
- if (
- (_keyword = _PyPegen_expect_token(p, 514)) // token='from'
- &&
- (z = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_49[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_49[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_50: '->' expression
-static void *
-_tmp_50_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '->' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression"));
- Token * _literal;
- expr_ty z;
- if (
- (_literal = _PyPegen_expect_token(p, 51)) // token='->'
- &&
- (z = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_50[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_51: '->' expression
-static void *
-_tmp_51_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '->' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression"));
- Token * _literal;
- expr_ty z;
- if (
- (_literal = _PyPegen_expect_token(p, 51)) // token='->'
- &&
- (z = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_51[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_51[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_52: NEWLINE INDENT
-static void *
-_tmp_52_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // NEWLINE INDENT
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT"));
- Token * indent_var;
- Token * newline_var;
- if (
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- &&
- (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT"));
- _res = _PyPegen_dummy_name(p, newline_var, indent_var);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_52[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_53: param_no_default
-static asdl_seq *
-_loop0_53_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
- while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- _res = param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_53[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_53_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_54: param_with_default
-static asdl_seq *
-_loop0_54_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
- NameDefaultPair* param_with_default_var;
- while (
- (param_with_default_var = param_with_default_rule(p)) // param_with_default
- )
- {
- _res = param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_55: param_with_default
-static asdl_seq *
-_loop0_55_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
- NameDefaultPair* param_with_default_var;
- while (
- (param_with_default_var = param_with_default_rule(p)) // param_with_default
- )
- {
- _res = param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_56: param_no_default
-static asdl_seq *
-_loop1_56_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
- while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- _res = param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_56[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_56_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_57: param_with_default
-static asdl_seq *
-_loop0_57_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
- NameDefaultPair* param_with_default_var;
- while (
- (param_with_default_var = param_with_default_rule(p)) // param_with_default
- )
- {
- _res = param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_58: param_with_default
-static asdl_seq *
-_loop1_58_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
- NameDefaultPair* param_with_default_var;
- while (
- (param_with_default_var = param_with_default_rule(p)) // param_with_default
- )
- {
- _res = param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_58[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_58_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_59: param_no_default
-static asdl_seq *
-_loop1_59_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
- while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- _res = param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_59[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_59_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_60: param_no_default
-static asdl_seq *
-_loop1_60_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
- while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- _res = param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_60[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_60_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_61: param_no_default
-static asdl_seq *
-_loop0_61_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
- while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- _res = param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_62: param_with_default
-static asdl_seq *
-_loop1_62_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
- NameDefaultPair* param_with_default_var;
- while (
- (param_with_default_var = param_with_default_rule(p)) // param_with_default
- )
- {
- _res = param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_62[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_62_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_63: param_no_default
-static asdl_seq *
-_loop0_63_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
- while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- _res = param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_64: param_with_default
-static asdl_seq *
-_loop1_64_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
- NameDefaultPair* param_with_default_var;
- while (
- (param_with_default_var = param_with_default_rule(p)) // param_with_default
- )
- {
- _res = param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_64[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_64_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_65: param_maybe_default
-static asdl_seq *
-_loop0_65_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_maybe_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default"));
- NameDefaultPair* param_maybe_default_var;
- while (
- (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
- )
- {
- _res = param_maybe_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_66: param_maybe_default
-static asdl_seq *
-_loop1_66_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_maybe_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default"));
- NameDefaultPair* param_maybe_default_var;
- while (
- (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default
- )
- {
- _res = param_maybe_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_66[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_66_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_67: ('@' named_expression NEWLINE)
-static asdl_seq *
-_loop1_67_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ('@' named_expression NEWLINE)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)"));
- void *_tmp_141_var;
- while (
- (_tmp_141_var = _tmp_141_rule(p)) // '@' named_expression NEWLINE
- )
- {
- _res = _tmp_141_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_67[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_67_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_68: '(' arguments? ')'
-static void *
-_tmp_68_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '(' arguments? ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'"));
- Token * _literal;
- Token * _literal_1;
- void *z;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- &&
- (z = arguments_rule(p), 1) // arguments?
- &&
- (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_70: ',' star_expression
-static asdl_seq *
-_loop0_70_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' star_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = star_expression_rule(p)) // star_expression
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_69: star_expression _loop0_70
-static asdl_seq *
-_gather_69_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // star_expression _loop0_70
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = star_expression_rule(p)) // star_expression
- &&
- (seq = _loop0_70_rule(p)) // _loop0_70
- )
- {
- D(fprintf(stderr, "%*c+ _gather_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_69[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_70"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_71: (',' star_expression)
-static asdl_seq *
-_loop1_71_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // (',' star_expression)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)"));
- void *_tmp_142_var;
- while (
- (_tmp_142_var = _tmp_142_rule(p)) // ',' star_expression
- )
- {
- _res = _tmp_142_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_71[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_71_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_73: ',' star_named_expression
-static asdl_seq *
-_loop0_73_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' star_named_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = star_named_expression_rule(p)) // star_named_expression
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_72: star_named_expression _loop0_73
-static asdl_seq *
-_gather_72_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // star_named_expression _loop0_73
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = star_named_expression_rule(p)) // star_named_expression
- &&
- (seq = _loop0_73_rule(p)) // _loop0_73
- )
- {
- D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_73"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_74: (',' expression)
-static asdl_seq *
-_loop1_74_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // (',' expression)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)"));
- void *_tmp_143_var;
- while (
- (_tmp_143_var = _tmp_143_rule(p)) // ',' expression
- )
- {
- _res = _tmp_143_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_74[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_75: lambda_param_no_default
-static asdl_seq *
-_loop0_75_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
- while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- _res = lambda_param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_75[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_76: lambda_param_with_default
-static asdl_seq *
-_loop0_76_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
- NameDefaultPair* lambda_param_with_default_var;
- while (
- (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
- )
- {
- _res = lambda_param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_77: lambda_param_with_default
-static asdl_seq *
-_loop0_77_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
- NameDefaultPair* lambda_param_with_default_var;
- while (
- (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
- )
- {
- _res = lambda_param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_78: lambda_param_no_default
-static asdl_seq *
-_loop1_78_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
- while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- _res = lambda_param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_78[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_79: lambda_param_with_default
-static asdl_seq *
-_loop0_79_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
- NameDefaultPair* lambda_param_with_default_var;
- while (
- (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
- )
- {
- _res = lambda_param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_80: lambda_param_with_default
-static asdl_seq *
-_loop1_80_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
- NameDefaultPair* lambda_param_with_default_var;
- while (
- (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
- )
- {
- _res = lambda_param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_81: lambda_param_no_default
-static asdl_seq *
-_loop1_81_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
- while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- _res = lambda_param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_82: lambda_param_no_default
-static asdl_seq *
-_loop1_82_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
- while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- _res = lambda_param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_83: lambda_param_no_default
-static asdl_seq *
-_loop0_83_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
- while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- _res = lambda_param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_83[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_84: lambda_param_with_default
-static asdl_seq *
-_loop1_84_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
- NameDefaultPair* lambda_param_with_default_var;
- while (
- (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
- )
- {
- _res = lambda_param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_85: lambda_param_no_default
-static asdl_seq *
-_loop0_85_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
- while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- _res = lambda_param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_86: lambda_param_with_default
-static asdl_seq *
-_loop1_86_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
- NameDefaultPair* lambda_param_with_default_var;
- while (
- (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
- )
- {
- _res = lambda_param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_87: lambda_param_maybe_default
-static asdl_seq *
-_loop0_87_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_maybe_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
- NameDefaultPair* lambda_param_maybe_default_var;
- while (
- (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
- )
- {
- _res = lambda_param_maybe_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_87[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_88: lambda_param_maybe_default
-static asdl_seq *
-_loop1_88_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_maybe_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default"));
- NameDefaultPair* lambda_param_maybe_default_var;
- while (
- (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default
- )
- {
- _res = lambda_param_maybe_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_89: ('or' conjunction)
-static asdl_seq *
-_loop1_89_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ('or' conjunction)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)"));
- void *_tmp_144_var;
- while (
- (_tmp_144_var = _tmp_144_rule(p)) // 'or' conjunction
- )
- {
- _res = _tmp_144_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_90: ('and' inversion)
-static asdl_seq *
-_loop1_90_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ('and' inversion)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)"));
- void *_tmp_145_var;
- while (
- (_tmp_145_var = _tmp_145_rule(p)) // 'and' inversion
- )
- {
- _res = _tmp_145_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_91: compare_op_bitwise_or_pair
-static asdl_seq *
-_loop1_91_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // compare_op_bitwise_or_pair
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair"));
- CmpopExprPair* compare_op_bitwise_or_pair_var;
- while (
- (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair
- )
- {
- _res = compare_op_bitwise_or_pair_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_92: '!='
-static void *
-_tmp_92_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '!='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='"));
- Token * tok;
- if (
- (tok = _PyPegen_expect_token(p, 28)) // token='!='
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='"));
- _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_94: ',' slice
-static asdl_seq *
-_loop0_94_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' slice
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = slice_rule(p)) // slice
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_93: slice _loop0_94
-static asdl_seq *
-_gather_93_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // slice _loop0_94
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_94"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = slice_rule(p)) // slice
- &&
- (seq = _loop0_94_rule(p)) // _loop0_94
- )
- {
- D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_94"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_94"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_95: ':' expression?
-static void *
-_tmp_95_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ':' expression?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?"));
- Token * _literal;
- void *d;
- if (
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- &&
- (d = expression_rule(p), 1) // expression?
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?"));
- _res = d;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_96: tuple | group | genexp
-static void *
-_tmp_96_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // tuple
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple"));
- expr_ty tuple_var;
- if (
- (tuple_var = tuple_rule(p)) // tuple
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple"));
- _res = tuple_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple"));
- }
- { // group
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group"));
- expr_ty group_var;
- if (
- (group_var = group_rule(p)) // group
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group"));
- _res = group_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group"));
- }
- { // genexp
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp"));
- expr_ty genexp_var;
- if (
- (genexp_var = genexp_rule(p)) // genexp
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp"));
- _res = genexp_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_97: list | listcomp
-static void *
-_tmp_97_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // list
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list"));
- expr_ty list_var;
- if (
- (list_var = list_rule(p)) // list
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list"));
- _res = list_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list"));
- }
- { // listcomp
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp"));
- expr_ty listcomp_var;
- if (
- (listcomp_var = listcomp_rule(p)) // listcomp
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp"));
- _res = listcomp_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_98: dict | set | dictcomp | setcomp
-static void *
-_tmp_98_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // dict
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict"));
- expr_ty dict_var;
- if (
- (dict_var = dict_rule(p)) // dict
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict"));
- _res = dict_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict"));
- }
- { // set
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set"));
- expr_ty set_var;
- if (
- (set_var = set_rule(p)) // set
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set"));
- _res = set_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set"));
- }
- { // dictcomp
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp"));
- expr_ty dictcomp_var;
- if (
- (dictcomp_var = dictcomp_rule(p)) // dictcomp
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp"));
- _res = dictcomp_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp"));
- }
- { // setcomp
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp"));
- expr_ty setcomp_var;
- if (
- (setcomp_var = setcomp_rule(p)) // setcomp
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp"));
- _res = setcomp_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_99: STRING
-static asdl_seq *
-_loop1_99_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // STRING
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING"));
- expr_ty string_var;
- while (
- (string_var = _PyPegen_string_token(p)) // STRING
- )
- {
- _res = string_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_100: star_named_expression ',' star_named_expressions?
-static void *
-_tmp_100_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // star_named_expression ',' star_named_expressions?
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
- Token * _literal;
- expr_ty y;
- void *z;
- if (
- (y = star_named_expression_rule(p)) // star_named_expression
- &&
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (z = star_named_expressions_rule(p), 1) // star_named_expressions?
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
- _res = _PyPegen_seq_insert_in_front ( p , y , z );
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_101: yield_expr | named_expression
-static void *
-_tmp_101_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // yield_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- expr_ty yield_expr_var;
- if (
- (yield_expr_var = yield_expr_rule(p)) // yield_expr
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- _res = yield_expr_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
- }
- { // named_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression"));
- expr_ty named_expression_var;
- if (
- (named_expression_var = named_expression_rule(p)) // named_expression
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression"));
- _res = named_expression_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_103: ',' double_starred_kvpair
-static asdl_seq *
-_loop0_103_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' double_starred_kvpair
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair"));
- Token * _literal;
- KeyValuePair* elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_102: double_starred_kvpair _loop0_103
-static asdl_seq *
-_gather_102_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // double_starred_kvpair _loop0_103
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103"));
- KeyValuePair* elem;
- asdl_seq * seq;
- if (
- (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair
- &&
- (seq = _loop0_103_rule(p)) // _loop0_103
- )
- {
- D(fprintf(stderr, "%*c+ _gather_102[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_102[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_103"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_104: for_if_clause
-static asdl_seq *
-_loop1_104_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // for_if_clause
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause"));
- comprehension_ty for_if_clause_var;
- while (
- (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause
- )
- {
- _res = for_if_clause_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_105: ('if' disjunction)
-static asdl_seq *
-_loop0_105_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ('if' disjunction)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
- void *_tmp_146_var;
- while (
- (_tmp_146_var = _tmp_146_rule(p)) // 'if' disjunction
- )
- {
- _res = _tmp_146_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_106: ('if' disjunction)
-static asdl_seq *
-_loop0_106_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ('if' disjunction)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)"));
- void *_tmp_147_var;
- while (
- (_tmp_147_var = _tmp_147_rule(p)) // 'if' disjunction
- )
- {
- _res = _tmp_147_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_107: ',' args
-static void *
-_tmp_107_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ',' args
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args"));
- Token * _literal;
- expr_ty c;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (c = args_rule(p)) // args
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args"));
- _res = c;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_108: ',' args
-static void *
-_tmp_108_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ',' args
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args"));
- Token * _literal;
- expr_ty c;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (c = args_rule(p)) // args
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args"));
- _res = c;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_108[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_110: ',' kwarg_or_starred
-static asdl_seq *
-_loop0_110_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' kwarg_or_starred
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
- Token * _literal;
- KeywordOrStarred* elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_109: kwarg_or_starred _loop0_110
-static asdl_seq *
-_gather_109_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // kwarg_or_starred _loop0_110
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110"));
- KeywordOrStarred* elem;
- asdl_seq * seq;
- if (
- (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
- &&
- (seq = _loop0_110_rule(p)) // _loop0_110
- )
- {
- D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_110"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_112: ',' kwarg_or_double_starred
-static asdl_seq *
-_loop0_112_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' kwarg_or_double_starred
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
- Token * _literal;
- KeywordOrStarred* elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_111: kwarg_or_double_starred _loop0_112
-static asdl_seq *
-_gather_111_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // kwarg_or_double_starred _loop0_112
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
- KeywordOrStarred* elem;
- asdl_seq * seq;
- if (
- (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
- &&
- (seq = _loop0_112_rule(p)) // _loop0_112
- )
- {
- D(fprintf(stderr, "%*c+ _gather_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_111[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_112"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_114: ',' kwarg_or_starred
-static asdl_seq *
-_loop0_114_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' kwarg_or_starred
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred"));
- Token * _literal;
- KeywordOrStarred* elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_113: kwarg_or_starred _loop0_114
-static asdl_seq *
-_gather_113_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // kwarg_or_starred _loop0_114
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114"));
- KeywordOrStarred* elem;
- asdl_seq * seq;
- if (
- (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred
- &&
- (seq = _loop0_114_rule(p)) // _loop0_114
- )
- {
- D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_114"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_116: ',' kwarg_or_double_starred
-static asdl_seq *
-_loop0_116_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' kwarg_or_double_starred
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred"));
- Token * _literal;
- KeywordOrStarred* elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_115: kwarg_or_double_starred _loop0_116
-static asdl_seq *
-_gather_115_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // kwarg_or_double_starred _loop0_116
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
- KeywordOrStarred* elem;
- asdl_seq * seq;
- if (
- (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred
- &&
- (seq = _loop0_116_rule(p)) // _loop0_116
- )
- {
- D(fprintf(stderr, "%*c+ _gather_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_115[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_116"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_117: (',' star_target)
-static asdl_seq *
-_loop0_117_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // (',' star_target)
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)"));
- void *_tmp_148_var;
- while (
- (_tmp_148_var = _tmp_148_rule(p)) // ',' star_target
- )
- {
- _res = _tmp_148_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_117[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_119: ',' star_target
-static asdl_seq *
-_loop0_119_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' star_target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = star_target_rule(p)) // star_target
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_118: star_target _loop0_119
-static asdl_seq *
-_gather_118_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // star_target _loop0_119
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = star_target_rule(p)) // star_target
- &&
- (seq = _loop0_119_rule(p)) // _loop0_119
- )
- {
- D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_119"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_120: !'*' star_target
-static void *
-_tmp_120_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // !'*' star_target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
- expr_ty star_target_var;
- if (
- _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*'
- &&
- (star_target_var = star_target_rule(p)) // star_target
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target"));
- _res = star_target_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_122: ',' del_target
-static asdl_seq *
-_loop0_122_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' del_target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = del_target_rule(p)) // del_target
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_121: del_target _loop0_122
-static asdl_seq *
-_gather_121_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // del_target _loop0_122
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = del_target_rule(p)) // del_target
- &&
- (seq = _loop0_122_rule(p)) // _loop0_122
- )
- {
- D(fprintf(stderr, "%*c+ _gather_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_121[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_122"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_124: ',' target
-static asdl_seq *
-_loop0_124_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // ',' target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target"));
- Token * _literal;
- expr_ty elem;
- while (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (elem = target_rule(p)) // target
- )
- {
- _res = elem;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _gather_123: target _loop0_124
-static asdl_seq *
-_gather_123_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- asdl_seq * _res = NULL;
- int _mark = p->mark;
- { // target _loop0_124
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_124"));
- expr_ty elem;
- asdl_seq * seq;
- if (
- (elem = target_rule(p)) // target
- &&
- (seq = _loop0_124_rule(p)) // _loop0_124
- )
- {
- D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_124"));
- _res = _PyPegen_seq_insert_in_front(p, elem, seq);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_124"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_125: args | expression for_if_clauses
-static void *
-_tmp_125_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // args
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args"));
- expr_ty args_var;
- if (
- (args_var = args_rule(p)) // args
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args"));
- _res = args_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args"));
- }
- { // expression for_if_clauses
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
- expr_ty expression_var;
- asdl_seq* for_if_clauses_var;
- if (
- (expression_var = expression_rule(p)) // expression
- &&
- (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses"));
- _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_126: star_named_expressions
-static asdl_seq *
-_loop0_126_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // star_named_expressions
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions"));
- asdl_seq* star_named_expressions_var;
- while (
- (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions
- )
- {
- _res = star_named_expressions_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_127: '=' annotated_rhs
-static void *
-_tmp_127_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '=' annotated_rhs
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
- Token * _literal;
- expr_ty annotated_rhs_var;
- if (
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- &&
- (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs"));
- _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_128: (star_targets '=')
-static asdl_seq *
-_loop0_128_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // (star_targets '=')
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
- void *_tmp_149_var;
- while (
- (_tmp_149_var = _tmp_149_rule(p)) // star_targets '='
- )
- {
- _res = _tmp_149_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop0_129: (star_targets '=')
-static asdl_seq *
-_loop0_129_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // (star_targets '=')
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')"));
- void *_tmp_150_var;
- while (
- (_tmp_150_var = _tmp_150_rule(p)) // star_targets '='
- )
- {
- _res = _tmp_150_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_129_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_130: yield_expr | star_expressions
-static void *
-_tmp_130_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // yield_expr
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- expr_ty yield_expr_var;
- if (
- (yield_expr_var = yield_expr_rule(p)) // yield_expr
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr"));
- _res = yield_expr_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr"));
- }
- { // star_expressions
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- expr_ty star_expressions_var;
- if (
- (star_expressions_var = star_expressions_rule(p)) // star_expressions
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
- _res = star_expressions_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_131: '[' | '(' | '{'
-static void *
-_tmp_131_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '['
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 9)) // token='['
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['"));
- }
- { // '('
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 7)) // token='('
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('"));
- }
- { // '{'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 25)) // token='{'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_132: param_no_default
-static asdl_seq *
-_loop0_132_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default"));
- arg_ty param_no_default_var;
- while (
- (param_no_default_var = param_no_default_rule(p)) // param_no_default
- )
- {
- _res = param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_133: slash_with_default | param_with_default+
-static void *
-_tmp_133_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // slash_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
- SlashWithDefault* slash_with_default_var;
- if (
- (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default"));
- _res = slash_with_default_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default"));
- }
- { // param_with_default+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
- asdl_seq * _loop1_151_var;
- if (
- (_loop1_151_var = _loop1_151_rule(p)) // param_with_default+
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+"));
- _res = _loop1_151_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop0_134: lambda_param_no_default
-static asdl_seq *
-_loop0_134_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_no_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default"));
- arg_ty lambda_param_no_default_var;
- while (
- (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default
- )
- {
- _res = lambda_param_no_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default"));
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop0_134_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_135: lambda_slash_with_default | lambda_param_with_default+
-static void *
-_tmp_135_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // lambda_slash_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
- SlashWithDefault* lambda_slash_with_default_var;
- if (
- (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default"));
- _res = lambda_slash_with_default_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default"));
- }
- { // lambda_param_with_default+
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
- asdl_seq * _loop1_152_var;
- if (
- (_loop1_152_var = _loop1_152_rule(p)) // lambda_param_with_default+
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+"));
- _res = _loop1_152_var;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_136: ')' | ',' (')' | '**')
-static void *
-_tmp_136_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
- }
- { // ',' (')' | '**')
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
- Token * _literal;
- void *_tmp_153_var;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_tmp_153_var = _tmp_153_rule(p)) // ')' | '**'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')"));
- _res = _PyPegen_dummy_name(p, _literal, _tmp_153_var);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_137: ':' | ',' (':' | '**')
-static void *
-_tmp_137_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'"));
- }
- { // ',' (':' | '**')
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
- Token * _literal;
- void *_tmp_154_var;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (_tmp_154_var = _tmp_154_rule(p)) // ':' | '**'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')"));
- _res = _PyPegen_dummy_name(p, _literal, _tmp_154_var);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_138: star_targets '='
-static void *
-_tmp_138_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // star_targets '='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
- Token * _literal;
- expr_ty z;
- if (
- (z = star_targets_rule(p)) // star_targets
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_139: '.' | '...'
-static void *
-_tmp_139_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '.'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
- }
- { // '...'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 52)) // token='...'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_140: '.' | '...'
-static void *
-_tmp_140_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '.'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 23)) // token='.'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'"));
- }
- { // '...'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 52)) // token='...'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_141: '@' named_expression NEWLINE
-static void *
-_tmp_141_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // '@' named_expression NEWLINE
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
- Token * _literal;
- expr_ty f;
- Token * newline_var;
- if (
- (_literal = _PyPegen_expect_token(p, 49)) // token='@'
- &&
- (f = named_expression_rule(p)) // named_expression
- &&
- (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE"));
- _res = f;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_142: ',' star_expression
-static void *
-_tmp_142_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ',' star_expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
- Token * _literal;
- expr_ty c;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (c = star_expression_rule(p)) // star_expression
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression"));
- _res = c;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_143: ',' expression
-static void *
-_tmp_143_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ',' expression
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression"));
- Token * _literal;
- expr_ty c;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (c = expression_rule(p)) // expression
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression"));
- _res = c;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_144: 'or' conjunction
-static void *
-_tmp_144_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'or' conjunction
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
- Token * _keyword;
- expr_ty c;
- if (
- (_keyword = _PyPegen_expect_token(p, 531)) // token='or'
- &&
- (c = conjunction_rule(p)) // conjunction
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction"));
- _res = c;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_145: 'and' inversion
-static void *
-_tmp_145_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'and' inversion
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
- Token * _keyword;
- expr_ty c;
- if (
- (_keyword = _PyPegen_expect_token(p, 532)) // token='and'
- &&
- (c = inversion_rule(p)) // inversion
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion"));
- _res = c;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_146: 'if' disjunction
-static void *
-_tmp_146_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'if' disjunction
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
- Token * _keyword;
- expr_ty z;
- if (
- (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
- &&
- (z = disjunction_rule(p)) // disjunction
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_147: 'if' disjunction
-static void *
-_tmp_147_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // 'if' disjunction
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
- Token * _keyword;
- expr_ty z;
- if (
- (_keyword = _PyPegen_expect_token(p, 510)) // token='if'
- &&
- (z = disjunction_rule(p)) // disjunction
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction"));
- _res = z;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_148: ',' star_target
-static void *
-_tmp_148_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ',' star_target
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target"));
- Token * _literal;
- expr_ty c;
- if (
- (_literal = _PyPegen_expect_token(p, 12)) // token=','
- &&
- (c = star_target_rule(p)) // star_target
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target"));
- _res = c;
- if (_res == NULL && PyErr_Occurred()) {
- p->error_indicator = 1;
- D(p->level--);
- return NULL;
- }
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_149: star_targets '='
-static void *
-_tmp_149_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // star_targets '='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
- Token * _literal;
- expr_ty star_targets_var;
- if (
- (star_targets_var = star_targets_rule(p)) // star_targets
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
- _res = _PyPegen_dummy_name(p, star_targets_var, _literal);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_150: star_targets '='
-static void *
-_tmp_150_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // star_targets '='
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
- Token * _literal;
- expr_ty star_targets_var;
- if (
- (star_targets_var = star_targets_rule(p)) // star_targets
- &&
- (_literal = _PyPegen_expect_token(p, 22)) // token='='
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='"));
- _res = _PyPegen_dummy_name(p, star_targets_var, _literal);
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _loop1_151: param_with_default
-static asdl_seq *
-_loop1_151_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default"));
- NameDefaultPair* param_with_default_var;
- while (
- (param_with_default_var = param_with_default_rule(p)) // param_with_default
- )
- {
- _res = param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_151[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_151_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _loop1_152: lambda_param_with_default
-static asdl_seq *
-_loop1_152_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void *_res = NULL;
- int _mark = p->mark;
- int _start_mark = p->mark;
- void **_children = PyMem_Malloc(sizeof(void *));
- if (!_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- ssize_t _children_capacity = 1;
- ssize_t _n = 0;
- { // lambda_param_with_default
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _loop1_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default"));
- NameDefaultPair* lambda_param_with_default_var;
- while (
- (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default
- )
- {
- _res = lambda_param_with_default_var;
- if (_n == _children_capacity) {
- _children_capacity *= 2;
- void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *));
- if (!_new_children) {
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- _children = _new_children;
- }
- _children[_n++] = _res;
- _mark = p->mark;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _loop1_152[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default"));
- }
- if (_n == 0 || p->error_indicator) {
- PyMem_Free(_children);
- D(p->level--);
- return NULL;
- }
- asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena);
- if (!_seq) {
- PyMem_Free(_children);
- p->error_indicator = 1;
- PyErr_NoMemory();
- D(p->level--);
- return NULL;
- }
- for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]);
- PyMem_Free(_children);
- _PyPegen_insert_memo(p, _start_mark, _loop1_152_type, _seq);
- D(p->level--);
- return _seq;
-}
-
-// _tmp_153: ')' | '**'
-static void *
-_tmp_153_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ')'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 8)) // token=')'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'"));
- }
- { // '**'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-// _tmp_154: ':' | '**'
-static void *
-_tmp_154_rule(Parser *p)
-{
- D(p->level++);
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- void * _res = NULL;
- int _mark = p->mark;
- { // ':'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 11)) // token=':'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'"));
- }
- { // '**'
- if (p->error_indicator) {
- D(p->level--);
- return NULL;
- }
- D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'"));
- Token * _literal;
- if (
- (_literal = _PyPegen_expect_token(p, 35)) // token='**'
- )
- {
- D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'"));
- _res = _literal;
- goto done;
- }
- p->mark = _mark;
- D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ',
- p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'"));
- }
- _res = NULL;
- done:
- D(p->level--);
- return _res;
-}
-
-void *
-_PyPegen_parse(Parser *p)
-{
- // Initialize keywords
- p->keywords = reserved_keywords;
- p->n_keyword_lists = n_keyword_lists;
-
- // Run parser
- void *result = NULL;
- if (p->start_rule == Py_file_input) {
- result = file_rule(p);
- } else if (p->start_rule == Py_single_input) {
- result = interactive_rule(p);
- } else if (p->start_rule == Py_eval_input) {
- result = eval_rule(p);
- } else if (p->start_rule == Py_func_type_input) {
- result = func_type_rule(p);
- } else if (p->start_rule == Py_fstring_input) {
- result = fstring_rule(p);
- }
-
- return result;
-}
-
-// The end
diff --git a/Parser/pgen/__init__.py b/Parser/pgen/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/Parser/pgen/__init__.py
+++ /dev/null
diff --git a/Parser/pgen/__main__.py b/Parser/pgen/__main__.py
deleted file mode 100644
index d3780a7..0000000
--- a/Parser/pgen/__main__.py
+++ /dev/null
@@ -1,43 +0,0 @@
-import argparse
-
-from .pgen import ParserGenerator
-
-
-def main():
- parser = argparse.ArgumentParser(description="Parser generator main program.")
- parser.add_argument(
- "grammar", type=str, help="The file with the grammar definition in EBNF format"
- )
- parser.add_argument("tokens", type=str, help="The file with the token definitions")
- parser.add_argument(
- "graminit_h",
- type=argparse.FileType("w"),
- help="The path to write the grammar's non-terminals as #defines",
- )
- parser.add_argument(
- "graminit_c",
- type=argparse.FileType("w"),
- help="The path to write the grammar as initialized data",
- )
-
- parser.add_argument("--verbose", "-v", action="count")
- parser.add_argument(
- "--graph",
- type=argparse.FileType("w"),
- action="store",
- metavar="GRAPH_OUTPUT_FILE",
- help="Dumps a DOT representation of the generated automata in a file",
- )
-
- args = parser.parse_args()
-
- p = ParserGenerator(
- args.grammar, args.tokens, verbose=args.verbose, graph_file=args.graph
- )
- grammar = p.make_grammar()
- grammar.produce_graminit_h(args.graminit_h.write)
- grammar.produce_graminit_c(args.graminit_c.write)
-
-
-if __name__ == "__main__":
- main()
diff --git a/Parser/pgen/automata.py b/Parser/pgen/automata.py
deleted file mode 100644
index f2ed221..0000000
--- a/Parser/pgen/automata.py
+++ /dev/null
@@ -1,400 +0,0 @@
-"""Classes representing state-machine concepts"""
-
-class NFA:
- """A non deterministic finite automata
-
- A non deterministic automata is a form of a finite state
- machine. An NFA's rules are less restrictive than a DFA.
- The NFA rules are:
-
- * A transition can be non-deterministic and can result in
- nothing, one, or two or more states.
-
- * An epsilon transition consuming empty input is valid.
- Transitions consuming labeled symbols are also permitted.
-
- This class assumes that there is only one starting state and one
- accepting (ending) state.
-
- Attributes:
- name (str): The name of the rule the NFA is representing.
- start (NFAState): The starting state.
- end (NFAState): The ending state
- """
-
- def __init__(self, start, end):
- self.name = start.rule_name
- self.start = start
- self.end = end
-
- def __repr__(self):
- return "NFA(start={}, end={})".format(self.start, self.end)
-
- def dump(self, writer=print):
- """Dump a graphical representation of the NFA"""
- todo = [self.start]
- for i, state in enumerate(todo):
- writer(" State", i, state is self.end and "(final)" or "")
- for arc in state.arcs:
- label = arc.label
- next = arc.target
- if next in todo:
- j = todo.index(next)
- else:
- j = len(todo)
- todo.append(next)
- if label is None:
- writer(" -> %d" % j)
- else:
- writer(" %s -> %d" % (label, j))
-
- def dump_graph(self, writer):
- """Dump a DOT representation of the NFA"""
- writer('digraph %s_nfa {\n' % self.name)
- todo = [self.start]
- for i, state in enumerate(todo):
- writer(' %d [label="State %d %s"];\n' % (i, i, state is self.end and "(final)" or ""))
- for arc in state.arcs:
- label = arc.label
- next = arc.target
- if next in todo:
- j = todo.index(next)
- else:
- j = len(todo)
- todo.append(next)
- if label is None:
- writer(" %d -> %d [style=dotted label=ε];\n" % (i, j))
- else:
- writer(" %d -> %d [label=%s];\n" % (i, j, label.replace("'", '"')))
- writer('}\n')
-
-
-class NFAArc:
- """An arc representing a transition between two NFA states.
-
- NFA states can be connected via two ways:
-
- * A label transition: An input equal to the label must
- be consumed to perform the transition.
- * An epsilon transition: The transition can be taken without
- consuming any input symbol.
-
- Attributes:
- target (NFAState): The ending state of the transition arc.
- label (Optional[str]): The label that must be consumed to make
- the transition. An epsilon transition is represented
- using `None`.
- """
-
- def __init__(self, target, label):
- self.target = target
- self.label = label
-
- def __repr__(self):
- return "<%s: %s>" % (self.__class__.__name__, self.label)
-
-
-class NFAState:
- """A state of a NFA, non deterministic finite automata.
-
- Attributes:
- target (rule_name): The name of the rule used to represent the NFA's
- ending state after a transition.
- arcs (Dict[Optional[str], NFAState]): A mapping representing transitions
- between the current NFA state and another NFA state via following
- a label.
- """
-
- def __init__(self, rule_name):
- self.rule_name = rule_name
- self.arcs = []
-
- def add_arc(self, target, label=None):
- """Add a new arc to connect the state to a target state within the NFA
-
- The method adds a new arc to the list of arcs available as transitions
- from the present state. An optional label indicates a named transition
- that consumes an input while the absence of a label represents an epsilon
- transition.
-
- Attributes:
- target (NFAState): The end of the transition that the arc represents.
- label (Optional[str]): The label that must be consumed for making
- the transition. If the label is not provided the transition is assumed
- to be an epsilon-transition.
- """
- assert label is None or isinstance(label, str)
- assert isinstance(target, NFAState)
- self.arcs.append(NFAArc(target, label))
-
- def __repr__(self):
- return "<%s: from %s>" % (self.__class__.__name__, self.rule_name)
-
-
-class DFA:
- """A deterministic finite automata
-
- A deterministic finite automata is a form of a finite state machine
- that obeys the following rules:
-
- * Each of the transitions is uniquely determined by
- the source state and input symbol
- * Reading an input symbol is required for each state
- transition (no epsilon transitions).
-
- The finite-state machine will accept or reject a string of symbols
- and only produces a unique computation of the automaton for each input
- string. The DFA must have a unique starting state (represented as the first
- element in the list of states) but can have multiple final states.
-
- Attributes:
- name (str): The name of the rule the DFA is representing.
- states (List[DFAState]): A collection of DFA states.
- """
-
- def __init__(self, name, states):
- self.name = name
- self.states = states
-
- @classmethod
- def from_nfa(cls, nfa):
- """Constructs a DFA from a NFA using the Rabin–Scott construction algorithm.
-
- To simulate the operation of a DFA on a given input string, it's
- necessary to keep track of a single state at any time, or more precisely,
- the state that the automaton will reach after seeing a prefix of the
- input. In contrast, to simulate an NFA, it's necessary to keep track of
- a set of states: all of the states that the automaton could reach after
- seeing the same prefix of the input, according to the nondeterministic
- choices made by the automaton. There are two possible sources of
- non-determinism:
-
- 1) Multiple (one or more) transitions with the same label
-
- 'A' +-------+
- +----------->+ State +----------->+
- | | 2 |
- +-------+ +-------+
- | State |
- | 1 | +-------+
- +-------+ | State |
- +----------->+ 3 +----------->+
- 'A' +-------+
-
- 2) Epsilon transitions (transitions that can be taken without consuming any input)
-
- +-------+ +-------+
- | State | ε | State |
- | 1 +----------->+ 2 +----------->+
- +-------+ +-------+
-
- Looking at the first case above, we can't determine which transition should be
- followed when given an input A. We could choose whether or not to follow the
- transition while in the second case the problem is that we can choose both to
- follow the transition or not doing it. To solve this problem we can imagine that
- we follow all possibilities at the same time and we construct new states from the
- set of all possible reachable states. For every case in the previous example:
-
-
- 1) For multiple transitions with the same label we colapse all of the
- final states under the same one
-
- +-------+ +-------+
- | State | 'A' | State |
- | 1 +----------->+ 2-3 +----------->+
- +-------+ +-------+
-
- 2) For epsilon transitions we collapse all epsilon-reachable states
- into the same one
-
- +-------+
- | State |
- | 1-2 +----------->
- +-------+
-
- Because the DFA states consist of sets of NFA states, an n-state NFA
- may be converted to a DFA with at most 2**n states. Notice that the
- constructed DFA is not minimal and can be simplified or reduced
- afterwards.
-
- Parameters:
- name (NFA): The NFA to transform to DFA.
- """
- assert isinstance(nfa, NFA)
-
- def add_closure(nfa_state, base_nfa_set):
- """Calculate the epsilon-closure of a given state
-
- Add to the *base_nfa_set* all the states that are
- reachable from *nfa_state* via epsilon-transitions.
- """
- assert isinstance(nfa_state, NFAState)
- if nfa_state in base_nfa_set:
- return
- base_nfa_set.add(nfa_state)
- for nfa_arc in nfa_state.arcs:
- if nfa_arc.label is None:
- add_closure(nfa_arc.target, base_nfa_set)
-
- # Calculate the epsilon-closure of the starting state
- base_nfa_set = set()
- add_closure(nfa.start, base_nfa_set)
-
- # Start by visiting the NFA starting state (there is only one).
- states = [DFAState(nfa.name, base_nfa_set, nfa.end)]
-
- for state in states: # NB states grow while we're iterating
-
- # Find transitions from the current state to other reachable states
- # and store them in mapping that correlates the label to all the
- # possible reachable states that can be obtained by consuming a
- # token equal to the label. Each set of all the states that can
- # be reached after following a label will be the a DFA state.
- arcs = {}
- for nfa_state in state.nfa_set:
- for nfa_arc in nfa_state.arcs:
- if nfa_arc.label is not None:
- nfa_set = arcs.setdefault(nfa_arc.label, set())
- # All states that can be reached by epsilon-transitions
- # are also included in the set of reachable states.
- add_closure(nfa_arc.target, nfa_set)
-
- # Now create new DFAs by visiting all posible transitions between
- # the current DFA state and the new power-set states (each nfa_set)
- # via the different labels. As the nodes are appended to *states* this
- # is performing a breadth-first search traversal over the power-set of
- # the states of the original NFA.
- for label, nfa_set in sorted(arcs.items()):
- for exisisting_state in states:
- if exisisting_state.nfa_set == nfa_set:
- # The DFA state already exists for this rule.
- next_state = exisisting_state
- break
- else:
- next_state = DFAState(nfa.name, nfa_set, nfa.end)
- states.append(next_state)
-
- # Add a transition between the current DFA state and the new
- # DFA state (the power-set state) via the current label.
- state.add_arc(next_state, label)
-
- return cls(nfa.name, states)
-
- def __iter__(self):
- return iter(self.states)
-
- def simplify(self):
- """Attempt to reduce the number of states of the DFA
-
- Transform the DFA into an equivalent DFA that has fewer states. Two
- classes of states can be removed or merged from the original DFA without
- affecting the language it accepts to minimize it:
-
- * Unreachable states can not be reached from the initial
- state of the DFA, for any input string.
- * Nondistinguishable states are those that cannot be distinguished
- from one another for any input string.
-
- This algorithm does not achieve the optimal fully-reduced solution, but it
- works well enough for the particularities of the Python grammar. The
- algorithm repeatedly looks for two states that have the same set of
- arcs (same labels pointing to the same nodes) and unifies them, until
- things stop changing.
- """
- changes = True
- while changes:
- changes = False
- for i, state_i in enumerate(self.states):
- for j in range(i + 1, len(self.states)):
- state_j = self.states[j]
- if state_i == state_j:
- del self.states[j]
- for state in self.states:
- state.unifystate(state_j, state_i)
- changes = True
- break
-
- def dump(self, writer=print):
- """Dump a graphical representation of the DFA"""
- for i, state in enumerate(self.states):
- writer(" State", i, state.is_final and "(final)" or "")
- for label, next in sorted(state.arcs.items()):
- writer(" %s -> %d" % (label, self.states.index(next)))
-
- def dump_graph(self, writer):
- """Dump a DOT representation of the DFA"""
- writer('digraph %s_dfa {\n' % self.name)
- for i, state in enumerate(self.states):
- writer(' %d [label="State %d %s"];\n' % (i, i, state.is_final and "(final)" or ""))
- for label, next in sorted(state.arcs.items()):
- writer(" %d -> %d [label=%s];\n" % (i, self.states.index(next), label.replace("'", '"')))
- writer('}\n')
-
-
-class DFAState(object):
- """A state of a DFA
-
- Attributes:
- rule_name (rule_name): The name of the DFA rule containing the represented state.
- nfa_set (Set[NFAState]): The set of NFA states used to create this state.
- final (bool): True if the state represents an accepting state of the DFA
- containing this state.
- arcs (Dict[label, DFAState]): A mapping representing transitions between
- the current DFA state and another DFA state via following a label.
- """
-
- def __init__(self, rule_name, nfa_set, final):
- assert isinstance(nfa_set, set)
- assert isinstance(next(iter(nfa_set)), NFAState)
- assert isinstance(final, NFAState)
- self.rule_name = rule_name
- self.nfa_set = nfa_set
- self.arcs = {} # map from terminals/nonterminals to DFAState
- self.is_final = final in nfa_set
-
- def add_arc(self, target, label):
- """Add a new arc to the current state.
-
- Parameters:
- target (DFAState): The DFA state at the end of the arc.
- label (str): The label respresenting the token that must be consumed
- to perform this transition.
- """
- assert isinstance(label, str)
- assert label not in self.arcs
- assert isinstance(target, DFAState)
- self.arcs[label] = target
-
- def unifystate(self, old, new):
- """Replace all arcs from the current node to *old* with *new*.
-
- Parameters:
- old (DFAState): The DFA state to remove from all existing arcs.
- new (DFAState): The DFA state to replace in all existing arcs.
- """
- for label, next_ in self.arcs.items():
- if next_ is old:
- self.arcs[label] = new
-
- def __eq__(self, other):
- # The nfa_set does not matter for equality
- assert isinstance(other, DFAState)
- if self.is_final != other.is_final:
- return False
- # We cannot just return self.arcs == other.arcs because that
- # would invoke this method recursively if there are any cycles.
- if len(self.arcs) != len(other.arcs):
- return False
- for label, next_ in self.arcs.items():
- if next_ is not other.arcs.get(label):
- return False
- return True
-
- __hash__ = None # For Py3 compatibility.
-
- def __repr__(self):
- return "<%s: %s is_final=%s>" % (
- self.__class__.__name__,
- self.rule_name,
- self.is_final,
- )
diff --git a/Parser/pgen/grammar.py b/Parser/pgen/grammar.py
deleted file mode 100644
index ce40e16..0000000
--- a/Parser/pgen/grammar.py
+++ /dev/null
@@ -1,147 +0,0 @@
-import collections
-
-
-class Grammar:
- """Pgen parsing tables class.
-
- The instance variables are as follows:
-
- symbol2number -- a dict mapping symbol names to numbers. Symbol
- numbers are always 256 or higher, to distinguish
- them from token numbers, which are between 0 and
- 255 (inclusive).
-
- number2symbol -- a dict mapping numbers to symbol names;
- these two are each other's inverse.
-
- states -- a list of DFAs, where each DFA is a list of
- states, each state is a list of arcs, and each
- arc is a (i, j) pair where i is a label and j is
- a state number. The DFA number is the index into
- this list. (This name is slightly confusing.)
- Final states are represented by a special arc of
- the form (0, j) where j is its own state number.
-
- dfas -- a dict mapping symbol numbers to (DFA, first)
- pairs, where DFA is an item from the states list
- above, and first is a set of tokens that can
- begin this grammar rule.
-
- labels -- a list of (x, y) pairs where x is either a token
- number or a symbol number, and y is either None
- or a string; the strings are keywords. The label
- number is the index in this list; label numbers
- are used to mark state transitions (arcs) in the
- DFAs.
-
- start -- the number of the grammar's start symbol.
-
- keywords -- a dict mapping keyword strings to arc labels.
-
- tokens -- a dict mapping token numbers to arc labels.
-
- """
-
- def __init__(self):
- self.symbol2number = collections.OrderedDict()
- self.number2symbol = collections.OrderedDict()
- self.states = []
- self.dfas = collections.OrderedDict()
- self.labels = [(0, "EMPTY")]
- self.keywords = collections.OrderedDict()
- self.tokens = collections.OrderedDict()
- self.symbol2label = collections.OrderedDict()
- self.start = 256
-
- def produce_graminit_h(self, writer):
- writer("/* Generated by Parser/pgen */\n\n")
- for number, symbol in self.number2symbol.items():
- writer("#define {} {}\n".format(symbol, number))
-
- def produce_graminit_c(self, writer):
- writer("/* Generated by Parser/pgen */\n\n")
-
- writer('#include "exports.h"\n')
- writer('#include "grammar.h"\n')
- writer("Py_EXPORTED_SYMBOL grammar _PyParser_Grammar;\n")
-
- self.print_dfas(writer)
- self.print_labels(writer)
-
- writer("Py_EXPORTED_SYMBOL grammar _PyParser_Grammar = {\n")
- writer(" {n_dfas},\n".format(n_dfas=len(self.dfas)))
- writer(" dfas,\n")
- writer(" {{{n_labels}, labels}},\n".format(n_labels=len(self.labels)))
- writer(" {start_number}\n".format(start_number=self.start))
- writer("};\n")
-
- def print_labels(self, writer):
- writer(
- "static const label labels[{n_labels}] = {{\n".format(
- n_labels=len(self.labels)
- )
- )
- for label, name in self.labels:
- label_name = '"{}"'.format(name) if name is not None else 0
- writer(
- " {{{label}, {label_name}}},\n".format(
- label=label, label_name=label_name
- )
- )
- writer("};\n")
-
- def print_dfas(self, writer):
- self.print_states(writer)
- writer("static const dfa dfas[{}] = {{\n".format(len(self.dfas)))
- for dfaindex, dfa_elem in enumerate(self.dfas.items()):
- symbol, (dfa, first_sets) = dfa_elem
- writer(
- ' {{{dfa_symbol}, "{symbol_name}", '.format(
- dfa_symbol=symbol, symbol_name=self.number2symbol[symbol]
- )
- + "{n_states}, states_{dfa_index},\n".format(
- n_states=len(dfa), dfa_index=dfaindex
- )
- + ' "'
- )
-
- bitset = bytearray((len(self.labels) >> 3) + 1)
- for token in first_sets:
- bitset[token >> 3] |= 1 << (token & 7)
- for byte in bitset:
- writer("\\%03o" % (byte & 0xFF))
- writer('"},\n')
- writer("};\n")
-
- def print_states(self, write):
- for dfaindex, dfa in enumerate(self.states):
- self.print_arcs(write, dfaindex, dfa)
- write(
- "static state states_{dfa_index}[{n_states}] = {{\n".format(
- dfa_index=dfaindex, n_states=len(dfa)
- )
- )
- for stateindex, state in enumerate(dfa):
- narcs = len(state)
- write(
- " {{{n_arcs}, arcs_{dfa_index}_{state_index}}},\n".format(
- n_arcs=narcs, dfa_index=dfaindex, state_index=stateindex
- )
- )
- write("};\n")
-
- def print_arcs(self, write, dfaindex, states):
- for stateindex, state in enumerate(states):
- narcs = len(state)
- write(
- "static const arc arcs_{dfa_index}_{state_index}[{n_arcs}] = {{\n".format(
- dfa_index=dfaindex, state_index=stateindex, n_arcs=narcs
- )
- )
- for a, b in state:
- write(
- " {{{from_label}, {to_state}}},\n".format(
- from_label=a, to_state=b
- )
- )
- write("};\n")
diff --git a/Parser/pgen/keywordgen.py b/Parser/pgen/keywordgen.py
deleted file mode 100644
index f0234a8..0000000
--- a/Parser/pgen/keywordgen.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""Generate Lib/keyword.py from the Grammar and Tokens files using pgen"""
-
-import argparse
-
-from .pgen import ParserGenerator
-
-TEMPLATE = r'''
-"""Keywords (from "Grammar/Grammar")
-
-This file is automatically generated; please don't muck it up!
-
-To update the symbols in this file, 'cd' to the top directory of
-the python source tree and run:
-
- python3 -m Parser.pgen.keywordgen Grammar/Grammar \
- Grammar/Tokens \
- Lib/keyword.py
-
-Alternatively, you can run 'make regen-keyword'.
-"""
-
-__all__ = ["iskeyword", "kwlist"]
-
-kwlist = [
- {keywords}
-]
-
-iskeyword = frozenset(kwlist).__contains__
-'''.lstrip()
-
-EXTRA_KEYWORDS = ["async", "await"]
-
-
-def main():
- parser = argparse.ArgumentParser(
- description="Generate the Lib/keywords.py " "file from the grammar."
- )
- parser.add_argument(
- "grammar", type=str, help="The file with the grammar definition in EBNF format"
- )
- parser.add_argument("tokens", type=str, help="The file with the token definitions")
- parser.add_argument(
- "keyword_file",
- type=argparse.FileType("w"),
- help="The path to write the keyword definitions",
- )
- args = parser.parse_args()
- p = ParserGenerator(args.grammar, args.tokens)
- grammar = p.make_grammar()
-
- with args.keyword_file as thefile:
- all_keywords = sorted(list(grammar.keywords) + EXTRA_KEYWORDS)
-
- keywords = ",\n ".join(map(repr, all_keywords))
- thefile.write(TEMPLATE.format(keywords=keywords))
-
-
-if __name__ == "__main__":
- main()
diff --git a/Parser/pgen/metaparser.py b/Parser/pgen/metaparser.py
deleted file mode 100644
index 074a083..0000000
--- a/Parser/pgen/metaparser.py
+++ /dev/null
@@ -1,152 +0,0 @@
-"""Parser for the Python metagrammar"""
-
-import io
-import tokenize # from stdlib
-
-from .automata import NFA, NFAState
-
-
-class GrammarParser:
- """Parser for Python grammar files."""
-
- _translation_table = {
- tokenize.NAME: "NAME",
- tokenize.STRING: "STRING",
- tokenize.NEWLINE: "NEWLINE",
- tokenize.NL: "NL",
- tokenize.OP: "OP",
- tokenize.ENDMARKER: "ENDMARKER",
- tokenize.COMMENT: "COMMENT",
- }
-
- def __init__(self, grammar):
- self.grammar = grammar
- grammar_adaptor = io.StringIO(grammar)
- self.generator = tokenize.generate_tokens(grammar_adaptor.readline)
- self._gettoken() # Initialize lookahead
- self._current_rule_name = None
-
- def parse(self):
- """Turn the grammar into a collection of NFAs"""
- # grammar: (NEWLINE | rule)* ENDMARKER
- while self.type != tokenize.ENDMARKER:
- while self.type == tokenize.NEWLINE:
- self._gettoken()
- # rule: NAME ':' rhs NEWLINE
- self._current_rule_name = self._expect(tokenize.NAME)
- self._expect(tokenize.OP, ":")
- a, z = self._parse_rhs()
- self._expect(tokenize.NEWLINE)
-
- yield NFA(a, z)
-
- def _parse_rhs(self):
- # rhs: items ('|' items)*
- a, z = self._parse_items()
- if self.value != "|":
- return a, z
- else:
- aa = NFAState(self._current_rule_name)
- zz = NFAState(self._current_rule_name)
- while True:
- # Allow to transit directly to the previous state and connect the end of the
- # previous state to the end of the current one, effectively allowing to skip
- # the current state.
- aa.add_arc(a)
- z.add_arc(zz)
- if self.value != "|":
- break
-
- self._gettoken()
- a, z = self._parse_items()
- return aa, zz
-
- def _parse_items(self):
- # items: item+
- a, b = self._parse_item()
- while self.type in (tokenize.NAME, tokenize.STRING) or self.value in ("(", "["):
- c, d = self._parse_item()
- # Allow a transition between the end of the previous state
- # and the beginning of the new one, connecting all the items
- # together. In this way we can only reach the end if we visit
- # all the items.
- b.add_arc(c)
- b = d
- return a, b
-
- def _parse_item(self):
- # item: '[' rhs ']' | atom ['+' | '*']
- if self.value == "[":
- self._gettoken()
- a, z = self._parse_rhs()
- self._expect(tokenize.OP, "]")
- # Make a transition from the beginning to the end so it is possible to
- # advance for free to the next state of this item # without consuming
- # anything from the rhs.
- a.add_arc(z)
- return a, z
- else:
- a, z = self._parse_atom()
- value = self.value
- if value not in ("+", "*"):
- return a, z
- self._gettoken()
- z.add_arc(a)
- if value == "+":
- # Create a cycle to the beginning so we go back to the old state in this
- # item and repeat.
- return a, z
- else:
- # The end state is the same as the beginning, so we can cycle arbitrarily
- # and end in the beginning if necessary.
- return a, a
-
- def _parse_atom(self):
- # atom: '(' rhs ')' | NAME | STRING
- if self.value == "(":
- self._gettoken()
- a, z = self._parse_rhs()
- self._expect(tokenize.OP, ")")
- return a, z
- elif self.type in (tokenize.NAME, tokenize.STRING):
- a = NFAState(self._current_rule_name)
- z = NFAState(self._current_rule_name)
- # We can transit to the next state only if we consume the value.
- a.add_arc(z, self.value)
- self._gettoken()
- return a, z
- else:
- self._raise_error(
- "expected (...) or NAME or STRING, got {} ({})",
- self._translation_table.get(self.type, self.type),
- self.value,
- )
-
- def _expect(self, type_, value=None):
- if self.type != type_:
- self._raise_error(
- "expected {}, got {} ({})",
- self._translation_table.get(type_, type_),
- self._translation_table.get(self.type, self.type),
- self.value,
- )
- if value is not None and self.value != value:
- self._raise_error("expected {}, got {}", value, self.value)
- value = self.value
- self._gettoken()
- return value
-
- def _gettoken(self):
- tup = next(self.generator)
- while tup[0] in (tokenize.COMMENT, tokenize.NL):
- tup = next(self.generator)
- self.type, self.value, self.begin, self.end, self.line = tup
-
- def _raise_error(self, msg, *args):
- if args:
- try:
- msg = msg.format(*args)
- except Exception:
- msg = " ".join([msg] + list(map(str, args)))
- line = self.grammar.splitlines()[self.begin[0] - 1]
- raise SyntaxError(msg, ("<grammar>", self.begin[0], self.begin[1], line))
diff --git a/Parser/pgen/pgen.py b/Parser/pgen/pgen.py
deleted file mode 100644
index 03032d4..0000000
--- a/Parser/pgen/pgen.py
+++ /dev/null
@@ -1,310 +0,0 @@
-"""Python parser generator
-
-
-This parser generator transforms a Python grammar file into parsing tables
-that can be consumed by Python's LL(1) parser written in C.
-
-Concepts
---------
-
-* An LL(1) parser (Left-to-right, Leftmost derivation, 1 token-lookahead) is a
- top-down parser for a subset of context-free languages. It parses the input
- from Left to right, performing Leftmost derivation of the sentence, and can
- only use 1 token of lookahead when parsing a sentence.
-
-* A parsing table is a collection of data that a generic implementation of the
- LL(1) parser consumes to know how to parse a given context-free grammar. In
- this case the collection of data involves Deterministic Finite Automatons,
- calculated first sets, keywords and transition labels.
-
-* A grammar is defined by production rules (or just 'productions') that specify
- which symbols may replace which other symbols; these rules may be used to
- generate strings, or to parse them. Each such rule has a head, or left-hand
- side, which consists of the string that may be replaced, and a body, or
- right-hand side, which consists of a string that may replace it. In the
- Python grammar, rules are written in the form
-
- rule_name: rule_description;
-
- meaning the rule 'a: b' specifies that a can be replaced by b. A context-free
- grammar is a grammar in which the left-hand side of each production rule
- consists of only a single nonterminal symbol. Context-free grammars can
- always be recognized by a Non-Deterministic Automatons.
-
-* Terminal symbols are literal symbols which may appear in the outputs of the
- production rules of the grammar and which cannot be changed using the rules
- of the grammar. Applying the rules recursively to a source string of symbols
- will usually terminate in a final output string consisting only of terminal
- symbols.
-
-* Nonterminal symbols are those symbols which can be replaced. The grammar
- includes a start symbol a designated member of the set of nonterminals from
- which all the strings in the language may be derived by successive
- applications of the production rules.
-
-* The language defined by the grammar is defined as the set of terminal strings
- that can be derived using the production rules.
-
-* The first sets of a rule (FIRST(rule)) are defined to be the set of terminals
- that can appear in the first position of any string derived from the rule.
- This is useful for LL(1) parsers as the parser is only allowed to look at the
- next token in the input to know which rule needs to parse. For example, given
- this grammar:
-
- start: '(' A | B ')'
- A: 'a' '<'
- B: 'b' '<'
-
- and the input '(b<)' the parser can only look at 'b' to know if it needs
- to parse A o B. Because FIRST(A) = {'a'} and FIRST(B) = {'b'} it knows
- that needs to continue parsing rule B because only that rule can start
- with 'b'.
-
-Description
------------
-
-The input for the parser generator is a grammar in extended BNF form (using *
-for repetition, + for at-least-once repetition, [] for optional parts, | for
-alternatives and () for grouping).
-
-Each rule in the grammar file is considered as a regular expression in its
-own right. It is turned into a Non-deterministic Finite Automaton (NFA),
-which is then turned into a Deterministic Finite Automaton (DFA), which is
-then optimized to reduce the number of states. See [Aho&Ullman 77] chapter 3,
-or similar compiler books (this technique is more often used for lexical
-analyzers).
-
-The DFA's are used by the parser as parsing tables in a special way that's
-probably unique. Before they are usable, the FIRST sets of all non-terminals
-are computed so the LL(1) parser consuming the parsing tables can distinguish
-between different transitions.
-Reference
----------
-
-[Aho&Ullman 77]
- Aho&Ullman, Principles of Compiler Design, Addison-Wesley 1977
- (first edition)
-"""
-
-from ast import literal_eval
-import collections
-
-from . import grammar, token
-from .automata import DFA
-from .metaparser import GrammarParser
-
-import enum
-
-
-class LabelType(enum.Enum):
- NONTERMINAL = 0
- NAMED_TOKEN = 1
- KEYWORD = 2
- OPERATOR = 3
- NONE = 4
-
-
-class Label(str):
- def __init__(self, value):
- self.type = self._get_type()
-
- def _get_type(self):
- if self[0].isalpha():
- if self.upper() == self:
- # NAMED tokens (ASYNC, NAME...) are all uppercase by convention
- return LabelType.NAMED_TOKEN
- else:
- # If is not uppercase it must be a non terminal.
- return LabelType.NONTERMINAL
- else:
- # Keywords and operators are wrapped in quotes
- assert self[0] == self[-1] in ('"', "'"), self
- value = literal_eval(self)
- if value[0].isalpha():
- return LabelType.KEYWORD
- else:
- return LabelType.OPERATOR
-
- def __repr__(self):
- return "{}({})".format(self.type, super().__repr__())
-
-
-class ParserGenerator(object):
- def __init__(self, grammar_file, token_file, verbose=False, graph_file=None):
- with open(grammar_file) as f:
- self.grammar = f.read()
- with open(token_file) as tok_file:
- token_lines = tok_file.readlines()
- self.tokens = dict(token.generate_tokens(token_lines))
- self.opmap = dict(token.generate_opmap(token_lines))
- # Manually add <> so it does not collide with !=
- self.opmap["<>"] = "NOTEQUAL"
- self.verbose = verbose
- self.filename = grammar_file
- self.graph_file = graph_file
- self.dfas, self.startsymbol = self.create_dfas()
- self.first = {} # map from symbol name to set of tokens
- self.calculate_first_sets()
-
- def create_dfas(self):
- rule_to_dfas = collections.OrderedDict()
- start_nonterminal = None
- for nfa in GrammarParser(self.grammar).parse():
- if self.verbose:
- print("Dump of NFA for", nfa.name)
- nfa.dump()
- if self.graph_file is not None:
- nfa.dump_graph(self.graph_file.write)
- dfa = DFA.from_nfa(nfa)
- if self.verbose:
- print("Dump of DFA for", dfa.name)
- dfa.dump()
- dfa.simplify()
- if self.graph_file is not None:
- dfa.dump_graph(self.graph_file.write)
- rule_to_dfas[dfa.name] = dfa
-
- if start_nonterminal is None:
- start_nonterminal = dfa.name
-
- return rule_to_dfas, start_nonterminal
-
- def make_grammar(self):
- c = grammar.Grammar()
- c.all_labels = set()
- names = list(self.dfas.keys())
- names.remove(self.startsymbol)
- names.insert(0, self.startsymbol)
- for name in names:
- i = 256 + len(c.symbol2number)
- c.symbol2number[Label(name)] = i
- c.number2symbol[i] = Label(name)
- c.all_labels.add(name)
- for name in names:
- self.make_label(c, name)
- dfa = self.dfas[name]
- states = []
- for state in dfa:
- arcs = []
- for label, next in sorted(state.arcs.items()):
- c.all_labels.add(label)
- arcs.append((self.make_label(c, label), dfa.states.index(next)))
- if state.is_final:
- arcs.append((0, dfa.states.index(state)))
- states.append(arcs)
- c.states.append(states)
- c.dfas[c.symbol2number[name]] = (states, self.make_first_sets(c, name))
- c.start = c.symbol2number[self.startsymbol]
-
- if self.verbose:
- print("")
- print("Grammar summary")
- print("===============")
-
- print("- {n_labels} labels".format(n_labels=len(c.labels)))
- print("- {n_dfas} dfas".format(n_dfas=len(c.dfas)))
- print("- {n_tokens} tokens".format(n_tokens=len(c.tokens)))
- print("- {n_keywords} keywords".format(n_keywords=len(c.keywords)))
- print(
- "- Start symbol: {start_symbol}".format(
- start_symbol=c.number2symbol[c.start]
- )
- )
- return c
-
- def make_first_sets(self, c, name):
- rawfirst = self.first[name]
- first = set()
- for label in sorted(rawfirst):
- ilabel = self.make_label(c, label)
- ##assert ilabel not in first # XXX failed on <> ... !=
- first.add(ilabel)
- return first
-
- def make_label(self, c, label):
- label = Label(label)
- ilabel = len(c.labels)
-
- if label.type == LabelType.NONTERMINAL:
- if label in c.symbol2label:
- return c.symbol2label[label]
- else:
- c.labels.append((c.symbol2number[label], None))
- c.symbol2label[label] = ilabel
- return ilabel
- elif label.type == LabelType.NAMED_TOKEN:
- # A named token (NAME, NUMBER, STRING)
- itoken = self.tokens.get(label, None)
- assert isinstance(itoken, int), label
- assert itoken in self.tokens.values(), label
- if itoken in c.tokens:
- return c.tokens[itoken]
- else:
- c.labels.append((itoken, None))
- c.tokens[itoken] = ilabel
- return ilabel
- elif label.type == LabelType.KEYWORD:
- # A keyword
- value = literal_eval(label)
- if value in c.keywords:
- return c.keywords[value]
- else:
- c.labels.append((self.tokens["NAME"], value))
- c.keywords[value] = ilabel
- return ilabel
- elif label.type == LabelType.OPERATOR:
- # An operator (any non-numeric token)
- value = literal_eval(label)
- tok_name = self.opmap[value] # Fails if unknown token
- itoken = self.tokens[tok_name]
- if itoken in c.tokens:
- return c.tokens[itoken]
- else:
- c.labels.append((itoken, None))
- c.tokens[itoken] = ilabel
- return ilabel
- else:
- raise ValueError("Cannot categorize label {}".format(label))
-
- def calculate_first_sets(self):
- names = list(self.dfas.keys())
- for name in names:
- if name not in self.first:
- self.calculate_first_sets_for_rule(name)
-
- if self.verbose:
- print("First set for {dfa_name}".format(dfa_name=name))
- for item in self.first[name]:
- print(" - {terminal}".format(terminal=item))
-
- def calculate_first_sets_for_rule(self, name):
- dfa = self.dfas[name]
- self.first[name] = None # dummy to detect left recursion
- state = dfa.states[0]
- totalset = set()
- overlapcheck = {}
- for label, next in state.arcs.items():
- if label in self.dfas:
- if label in self.first:
- fset = self.first[label]
- if fset is None:
- raise ValueError("recursion for rule %r" % name)
- else:
- self.calculate_first_sets_for_rule(label)
- fset = self.first[label]
- totalset.update(fset)
- overlapcheck[label] = fset
- else:
- totalset.add(label)
- overlapcheck[label] = {label}
- inverse = {}
- for label, itsfirst in overlapcheck.items():
- for symbol in itsfirst:
- if symbol in inverse:
- raise ValueError(
- "rule %s is ambiguous; %s is in the"
- " first sets of %s as well as %s"
- % (name, symbol, label, inverse[symbol])
- )
- inverse[symbol] = label
- self.first[name] = totalset
diff --git a/Parser/pgen/token.py b/Parser/pgen/token.py
deleted file mode 100644
index 2cff62c..0000000
--- a/Parser/pgen/token.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import itertools
-
-
-def generate_tokens(tokens):
- numbers = itertools.count(0)
- for line in tokens:
- line = line.strip()
-
- if not line or line.startswith("#"):
- continue
-
- name = line.split()[0]
- yield (name, next(numbers))
-
- yield ("N_TOKENS", next(numbers))
- yield ("NT_OFFSET", 256)
-
-
-def generate_opmap(tokens):
- for line in tokens:
- line = line.strip()
-
- if not line or line.startswith("#"):
- continue
-
- pieces = line.split()
-
- if len(pieces) != 2:
- continue
-
- name, op = pieces
- yield (op.strip("'"), name)
-
- # Yield independently <>. This is needed so it does not collide
- # with the token generation in "generate_tokens" because if this
- # symbol is included in Grammar/Tokens, it will collide with !=
- # as it has the same name (NOTEQUAL).
- yield ("<>", "NOTEQUAL")
diff --git a/Parser/pegen/parse_string.c b/Parser/string_parser.c
index 94241e1..cb2332b 100644
--- a/Parser/pegen/parse_string.c
+++ b/Parser/string_parser.c
@@ -1,8 +1,8 @@
#include <Python.h>
-#include "../tokenizer.h"
+#include "tokenizer.h"
#include "pegen.h"
-#include "parse_string.h"
+#include "string_parser.h"
//// STRING HANDLING FUNCTIONS ////
diff --git a/Parser/pegen/parse_string.h b/Parser/string_parser.h
index cd85bd5..cd85bd5 100644
--- a/Parser/pegen/parse_string.h
+++ b/Parser/string_parser.h
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index d89f6be..6f38b62 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -486,7 +486,6 @@ static int test_init_from_config(void)
config.install_signal_handlers = 0;
putenv("PYTHONOLDPARSER=1");
- config._use_peg_parser = 0;
/* FIXME: test use_environment */
diff --git a/Python/ast.c b/Python/ast.c
index 408591f..d7feb8c 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -550,5295 +550,6 @@ PyAST_Validate(mod_ty mod)
return res;
}
-/* This is done here, so defines like "test" don't interfere with AST use above. */
-#include "grammar.h"
-#include "parsetok.h"
-#include "graminit.h"
-
-/* Data structure used internally */
-struct compiling {
- PyArena *c_arena; /* Arena for allocating memory. */
- PyObject *c_filename; /* filename */
- PyObject *c_normalize; /* Normalization function from unicodedata. */
- int c_feature_version; /* Latest minor version of Python for allowed features */
-};
-
-static asdl_seq *seq_for_testlist(struct compiling *, const node *);
-static expr_ty ast_for_expr(struct compiling *, const node *);
-static stmt_ty ast_for_stmt(struct compiling *, const node *);
-static asdl_seq *ast_for_suite(struct compiling *c, const node *n);
-static asdl_seq *ast_for_exprlist(struct compiling *, const node *,
- expr_context_ty);
-static expr_ty ast_for_testlist(struct compiling *, const node *);
-static stmt_ty ast_for_classdef(struct compiling *, const node *, asdl_seq *);
-
-static stmt_ty ast_for_with_stmt(struct compiling *, const node *, bool);
-static stmt_ty ast_for_for_stmt(struct compiling *, const node *, bool);
-
-/* Note different signature for ast_for_call */
-static expr_ty ast_for_call(struct compiling *, const node *, expr_ty,
- const node *, const node *, const node *);
-
-static PyObject *parsenumber(struct compiling *, const char *);
-static expr_ty parsestrplus(struct compiling *, const node *n);
-static void get_last_end_pos(asdl_seq *, int *, int *);
-
-#define COMP_GENEXP 0
-#define COMP_LISTCOMP 1
-#define COMP_SETCOMP 2
-
-static int
-init_normalization(struct compiling *c)
-{
- PyObject *m = PyImport_ImportModuleNoBlock("unicodedata");
- if (!m)
- return 0;
- c->c_normalize = PyObject_GetAttrString(m, "normalize");
- Py_DECREF(m);
- if (!c->c_normalize)
- return 0;
- return 1;
-}
-
-static identifier
-new_identifier(const char *n, struct compiling *c)
-{
- PyObject *id = PyUnicode_DecodeUTF8(n, strlen(n), NULL);
- if (!id)
- return NULL;
- /* PyUnicode_DecodeUTF8 should always return a ready string. */
- assert(PyUnicode_IS_READY(id));
- /* Check whether there are non-ASCII characters in the
- identifier; if so, normalize to NFKC. */
- if (!PyUnicode_IS_ASCII(id)) {
- PyObject *id2;
- if (!c->c_normalize && !init_normalization(c)) {
- Py_DECREF(id);
- return NULL;
- }
- PyObject *form = PyUnicode_InternFromString("NFKC");
- if (form == NULL) {
- Py_DECREF(id);
- return NULL;
- }
- PyObject *args[2] = {form, id};
- id2 = _PyObject_FastCall(c->c_normalize, args, 2);
- Py_DECREF(id);
- Py_DECREF(form);
- if (!id2)
- return NULL;
- if (!PyUnicode_Check(id2)) {
- PyErr_Format(PyExc_TypeError,
- "unicodedata.normalize() must return a string, not "
- "%.200s",
- _PyType_Name(Py_TYPE(id2)));
- Py_DECREF(id2);
- return NULL;
- }
- id = id2;
- }
- PyUnicode_InternInPlace(&id);
- if (PyArena_AddPyObject(c->c_arena, id) < 0) {
- Py_DECREF(id);
- return NULL;
- }
- return id;
-}
-
-#define NEW_IDENTIFIER(n) new_identifier(STR(n), c)
-
-static int
-ast_error(struct compiling *c, const node *n, const char *errmsg, ...)
-{
- PyObject *value, *errstr, *loc, *tmp;
- va_list va;
-
- va_start(va, errmsg);
- errstr = PyUnicode_FromFormatV(errmsg, va);
- va_end(va);
- if (!errstr) {
- return 0;
- }
- loc = PyErr_ProgramTextObject(c->c_filename, LINENO(n));
- if (!loc) {
- Py_INCREF(Py_None);
- loc = Py_None;
- }
- tmp = Py_BuildValue("(OiiN)", c->c_filename, LINENO(n), n->n_col_offset + 1, loc);
- if (!tmp) {
- Py_DECREF(errstr);
- return 0;
- }
- value = PyTuple_Pack(2, errstr, tmp);
- Py_DECREF(errstr);
- Py_DECREF(tmp);
- if (value) {
- PyErr_SetObject(PyExc_SyntaxError, value);
- Py_DECREF(value);
- }
- return 0;
-}
-
-/* num_stmts() returns number of contained statements.
-
- Use this routine to determine how big a sequence is needed for
- the statements in a parse tree. Its raison d'etre is this bit of
- grammar:
-
- stmt: simple_stmt | compound_stmt
- simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
-
- A simple_stmt can contain multiple small_stmt elements joined
- by semicolons. If the arg is a simple_stmt, the number of
- small_stmt elements is returned.
-*/
-
-static string
-new_type_comment(const char *s, struct compiling *c)
-{
- PyObject *res = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
- if (res == NULL)
- return NULL;
- if (PyArena_AddPyObject(c->c_arena, res) < 0) {
- Py_DECREF(res);
- return NULL;
- }
- return res;
-}
-#define NEW_TYPE_COMMENT(n) new_type_comment(STR(n), c)
-
-static int
-num_stmts(const node *n)
-{
- int i, l;
- node *ch;
-
- switch (TYPE(n)) {
- case single_input:
- if (TYPE(CHILD(n, 0)) == NEWLINE)
- return 0;
- else
- return num_stmts(CHILD(n, 0));
- case file_input:
- l = 0;
- for (i = 0; i < NCH(n); i++) {
- ch = CHILD(n, i);
- if (TYPE(ch) == stmt)
- l += num_stmts(ch);
- }
- return l;
- case stmt:
- return num_stmts(CHILD(n, 0));
- case compound_stmt:
- return 1;
- case simple_stmt:
- return NCH(n) / 2; /* Divide by 2 to remove count of semi-colons */
- case suite:
- case func_body_suite:
- /* func_body_suite: simple_stmt | NEWLINE [TYPE_COMMENT NEWLINE] INDENT stmt+ DEDENT */
- /* suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT */
- if (NCH(n) == 1)
- return num_stmts(CHILD(n, 0));
- else {
- i = 2;
- l = 0;
- if (TYPE(CHILD(n, 1)) == TYPE_COMMENT)
- i += 2;
- for (; i < (NCH(n) - 1); i++)
- l += num_stmts(CHILD(n, i));
- return l;
- }
- default: {
- _Py_FatalErrorFormat(__func__, "Non-statement found: %d %d",
- TYPE(n), NCH(n));
- }
- }
- Py_UNREACHABLE();
-}
-
-/* Transform the CST rooted at node * to the appropriate AST
-*/
-
-mod_ty
-PyAST_FromNodeObject(const node *n, PyCompilerFlags *flags,
- PyObject *filename, PyArena *arena)
-{
- int i, j, k, num;
- asdl_seq *stmts = NULL;
- asdl_seq *type_ignores = NULL;
- stmt_ty s;
- node *ch;
- struct compiling c;
- mod_ty res = NULL;
- asdl_seq *argtypes = NULL;
- expr_ty ret, arg;
-
- c.c_arena = arena;
- /* borrowed reference */
- c.c_filename = filename;
- c.c_normalize = NULL;
- c.c_feature_version = flags ? flags->cf_feature_version : PY_MINOR_VERSION;
-
- if (TYPE(n) == encoding_decl)
- n = CHILD(n, 0);
-
- k = 0;
- switch (TYPE(n)) {
- case file_input:
- stmts = _Py_asdl_seq_new(num_stmts(n), arena);
- if (!stmts)
- goto out;
- for (i = 0; i < NCH(n) - 1; i++) {
- ch = CHILD(n, i);
- if (TYPE(ch) == NEWLINE)
- continue;
- REQ(ch, stmt);
- num = num_stmts(ch);
- if (num == 1) {
- s = ast_for_stmt(&c, ch);
- if (!s)
- goto out;
- asdl_seq_SET(stmts, k++, s);
- }
- else {
- ch = CHILD(ch, 0);
- REQ(ch, simple_stmt);
- for (j = 0; j < num; j++) {
- s = ast_for_stmt(&c, CHILD(ch, j * 2));
- if (!s)
- goto out;
- asdl_seq_SET(stmts, k++, s);
- }
- }
- }
-
- /* Type ignores are stored under the ENDMARKER in file_input. */
- ch = CHILD(n, NCH(n) - 1);
- REQ(ch, ENDMARKER);
- num = NCH(ch);
- type_ignores = _Py_asdl_seq_new(num, arena);
- if (!type_ignores)
- goto out;
-
- for (i = 0; i < num; i++) {
- string type_comment = new_type_comment(STR(CHILD(ch, i)), &c);
- if (!type_comment)
- goto out;
- type_ignore_ty ti = TypeIgnore(LINENO(CHILD(ch, i)), type_comment, arena);
- if (!ti)
- goto out;
- asdl_seq_SET(type_ignores, i, ti);
- }
-
- res = Module(stmts, type_ignores, arena);
- break;
- case eval_input: {
- expr_ty testlist_ast;
-
- /* XXX Why not comp_for here? */
- testlist_ast = ast_for_testlist(&c, CHILD(n, 0));
- if (!testlist_ast)
- goto out;
- res = Expression(testlist_ast, arena);
- break;
- }
- case single_input:
- if (TYPE(CHILD(n, 0)) == NEWLINE) {
- stmts = _Py_asdl_seq_new(1, arena);
- if (!stmts)
- goto out;
- asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- arena));
- if (!asdl_seq_GET(stmts, 0))
- goto out;
- res = Interactive(stmts, arena);
- }
- else {
- n = CHILD(n, 0);
- num = num_stmts(n);
- stmts = _Py_asdl_seq_new(num, arena);
- if (!stmts)
- goto out;
- if (num == 1) {
- s = ast_for_stmt(&c, n);
- if (!s)
- goto out;
- asdl_seq_SET(stmts, 0, s);
- }
- else {
- /* Only a simple_stmt can contain multiple statements. */
- REQ(n, simple_stmt);
- for (i = 0; i < NCH(n); i += 2) {
- if (TYPE(CHILD(n, i)) == NEWLINE)
- break;
- s = ast_for_stmt(&c, CHILD(n, i));
- if (!s)
- goto out;
- asdl_seq_SET(stmts, i / 2, s);
- }
- }
-
- res = Interactive(stmts, arena);
- }
- break;
- case func_type_input:
- n = CHILD(n, 0);
- REQ(n, func_type);
-
- if (TYPE(CHILD(n, 1)) == typelist) {
- ch = CHILD(n, 1);
- /* this is overly permissive -- we don't pay any attention to
- * stars on the args -- just parse them into an ordered list */
- num = 0;
- for (i = 0; i < NCH(ch); i++) {
- if (TYPE(CHILD(ch, i)) == test) {
- num++;
- }
- }
-
- argtypes = _Py_asdl_seq_new(num, arena);
- if (!argtypes)
- goto out;
-
- j = 0;
- for (i = 0; i < NCH(ch); i++) {
- if (TYPE(CHILD(ch, i)) == test) {
- arg = ast_for_expr(&c, CHILD(ch, i));
- if (!arg)
- goto out;
- asdl_seq_SET(argtypes, j++, arg);
- }
- }
- }
- else {
- argtypes = _Py_asdl_seq_new(0, arena);
- if (!argtypes)
- goto out;
- }
-
- ret = ast_for_expr(&c, CHILD(n, NCH(n) - 1));
- if (!ret)
- goto out;
- res = FunctionType(argtypes, ret, arena);
- break;
- default:
- PyErr_Format(PyExc_SystemError,
- "invalid node %d for PyAST_FromNode", TYPE(n));
- goto out;
- }
- out:
- if (c.c_normalize) {
- Py_DECREF(c.c_normalize);
- }
- return res;
-}
-
-mod_ty
-PyAST_FromNode(const node *n, PyCompilerFlags *flags, const char *filename_str,
- PyArena *arena)
-{
- mod_ty mod;
- PyObject *filename;
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL)
- return NULL;
- mod = PyAST_FromNodeObject(n, flags, filename, arena);
- Py_DECREF(filename);
- return mod;
-
-}
-
-/* Return the AST repr. of the operator represented as syntax (|, ^, etc.)
-*/
-
-static operator_ty
-get_operator(struct compiling *c, const node *n)
-{
- switch (TYPE(n)) {
- case VBAR:
- return BitOr;
- case CIRCUMFLEX:
- return BitXor;
- case AMPER:
- return BitAnd;
- case LEFTSHIFT:
- return LShift;
- case RIGHTSHIFT:
- return RShift;
- case PLUS:
- return Add;
- case MINUS:
- return Sub;
- case STAR:
- return Mult;
- case AT:
- if (c->c_feature_version < 5) {
- ast_error(c, n,
- "The '@' operator is only supported in Python 3.5 and greater");
- return (operator_ty)0;
- }
- return MatMult;
- case SLASH:
- return Div;
- case DOUBLESLASH:
- return FloorDiv;
- case PERCENT:
- return Mod;
- default:
- return (operator_ty)0;
- }
-}
-
-static const char * const FORBIDDEN[] = {
- "None",
- "True",
- "False",
- "__debug__",
- NULL,
-};
-
-static int
-forbidden_name(struct compiling *c, identifier name, const node *n,
- int full_checks)
-{
- assert(PyUnicode_Check(name));
- const char * const *p = FORBIDDEN;
- if (!full_checks) {
- /* In most cases, the parser will protect True, False, and None
- from being assign to. */
- p += 3;
- }
- for (; *p; p++) {
- if (_PyUnicode_EqualToASCIIString(name, *p)) {
- ast_error(c, n, "cannot assign to %U", name);
- return 1;
- }
- }
- return 0;
-}
-
-static expr_ty
-copy_location(expr_ty e, const node *n, const node *end)
-{
- if (e) {
- e->lineno = LINENO(n);
- e->col_offset = n->n_col_offset;
- e->end_lineno = end->n_end_lineno;
- e->end_col_offset = end->n_end_col_offset;
- }
- return e;
-}
-
-static const char *
-get_expr_name(expr_ty e)
-{
- switch (e->kind) {
- case Attribute_kind:
- return "attribute";
- case Subscript_kind:
- return "subscript";
- case Starred_kind:
- return "starred";
- case Name_kind:
- return "name";
- case List_kind:
- return "list";
- case Tuple_kind:
- return "tuple";
- case Lambda_kind:
- return "lambda";
- case Call_kind:
- return "function call";
- case BoolOp_kind:
- case BinOp_kind:
- case UnaryOp_kind:
- return "operator";
- case GeneratorExp_kind:
- return "generator expression";
- case Yield_kind:
- case YieldFrom_kind:
- return "yield expression";
- case Await_kind:
- return "await expression";
- case ListComp_kind:
- return "list comprehension";
- case SetComp_kind:
- return "set comprehension";
- case DictComp_kind:
- return "dict comprehension";
- case Dict_kind:
- return "dict display";
- case Set_kind:
- return "set display";
- case JoinedStr_kind:
- case FormattedValue_kind:
- return "f-string expression";
- case Constant_kind: {
- PyObject *value = e->v.Constant.value;
- if (value == Py_None) {
- return "None";
- }
- if (value == Py_False) {
- return "False";
- }
- if (value == Py_True) {
- return "True";
- }
- if (value == Py_Ellipsis) {
- return "Ellipsis";
- }
- return "literal";
- }
- case Compare_kind:
- return "comparison";
- case IfExp_kind:
- return "conditional expression";
- case NamedExpr_kind:
- return "named expression";
- default:
- PyErr_Format(PyExc_SystemError,
- "unexpected expression in assignment %d (line %d)",
- e->kind, e->lineno);
- return NULL;
- }
-}
-
-/* Set the context ctx for expr_ty e, recursively traversing e.
-
- Only sets context for expr kinds that "can appear in assignment context"
- (according to ../Parser/Python.asdl). For other expr kinds, it sets
- an appropriate syntax error and returns false.
-*/
-
-static int
-set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
-{
- asdl_seq *s = NULL;
-
- /* Expressions in an augmented assignment have a Store context. */
-
- switch (e->kind) {
- case Attribute_kind:
- e->v.Attribute.ctx = ctx;
- if (ctx == Store && forbidden_name(c, e->v.Attribute.attr, n, 1))
- return 0;
- break;
- case Subscript_kind:
- e->v.Subscript.ctx = ctx;
- break;
- case Starred_kind:
- e->v.Starred.ctx = ctx;
- if (!set_context(c, e->v.Starred.value, ctx, n))
- return 0;
- break;
- case Name_kind:
- if (ctx == Store) {
- if (forbidden_name(c, e->v.Name.id, n, 0))
- return 0; /* forbidden_name() calls ast_error() */
- }
- e->v.Name.ctx = ctx;
- break;
- case List_kind:
- e->v.List.ctx = ctx;
- s = e->v.List.elts;
- break;
- case Tuple_kind:
- e->v.Tuple.ctx = ctx;
- s = e->v.Tuple.elts;
- break;
- default: {
- const char *expr_name = get_expr_name(e);
- if (expr_name != NULL) {
- ast_error(c, n, "cannot %s %s",
- ctx == Store ? "assign to" : "delete",
- expr_name);
- }
- return 0;
- }
- }
-
- /* If the LHS is a list or tuple, we need to set the assignment
- context for all the contained elements.
- */
- if (s) {
- Py_ssize_t i;
-
- for (i = 0; i < asdl_seq_LEN(s); i++) {
- if (!set_context(c, (expr_ty)asdl_seq_GET(s, i), ctx, n))
- return 0;
- }
- }
- return 1;
-}
-
-static operator_ty
-ast_for_augassign(struct compiling *c, const node *n)
-{
- REQ(n, augassign);
- n = CHILD(n, 0);
- switch (STR(n)[0]) {
- case '+':
- return Add;
- case '-':
- return Sub;
- case '/':
- if (STR(n)[1] == '/')
- return FloorDiv;
- else
- return Div;
- case '%':
- return Mod;
- case '<':
- return LShift;
- case '>':
- return RShift;
- case '&':
- return BitAnd;
- case '^':
- return BitXor;
- case '|':
- return BitOr;
- case '*':
- if (STR(n)[1] == '*')
- return Pow;
- else
- return Mult;
- case '@':
- if (c->c_feature_version < 5) {
- ast_error(c, n,
- "The '@' operator is only supported in Python 3.5 and greater");
- return (operator_ty)0;
- }
- return MatMult;
- default:
- PyErr_Format(PyExc_SystemError, "invalid augassign: %s", STR(n));
- return (operator_ty)0;
- }
-}
-
-static cmpop_ty
-ast_for_comp_op(struct compiling *c, const node *n)
-{
- /* comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'
- |'is' 'not'
- */
- REQ(n, comp_op);
- if (NCH(n) == 1) {
- n = CHILD(n, 0);
- switch (TYPE(n)) {
- case LESS:
- return Lt;
- case GREATER:
- return Gt;
- case EQEQUAL: /* == */
- return Eq;
- case LESSEQUAL:
- return LtE;
- case GREATEREQUAL:
- return GtE;
- case NOTEQUAL:
- return NotEq;
- case NAME:
- if (strcmp(STR(n), "in") == 0)
- return In;
- if (strcmp(STR(n), "is") == 0)
- return Is;
- /* fall through */
- default:
- PyErr_Format(PyExc_SystemError, "invalid comp_op: %s",
- STR(n));
- return (cmpop_ty)0;
- }
- }
- else if (NCH(n) == 2) {
- /* handle "not in" and "is not" */
- switch (TYPE(CHILD(n, 0))) {
- case NAME:
- if (strcmp(STR(CHILD(n, 1)), "in") == 0)
- return NotIn;
- if (strcmp(STR(CHILD(n, 0)), "is") == 0)
- return IsNot;
- /* fall through */
- default:
- PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s",
- STR(CHILD(n, 0)), STR(CHILD(n, 1)));
- return (cmpop_ty)0;
- }
- }
- PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children",
- NCH(n));
- return (cmpop_ty)0;
-}
-
-static asdl_seq *
-seq_for_testlist(struct compiling *c, const node *n)
-{
- /* testlist: test (',' test)* [',']
- testlist_star_expr: test|star_expr (',' test|star_expr)* [',']
- */
- asdl_seq *seq;
- expr_ty expression;
- int i;
- assert(TYPE(n) == testlist || TYPE(n) == testlist_star_expr || TYPE(n) == testlist_comp);
-
- seq = _Py_asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
- if (!seq)
- return NULL;
-
- for (i = 0; i < NCH(n); i += 2) {
- const node *ch = CHILD(n, i);
- assert(TYPE(ch) == test || TYPE(ch) == test_nocond || TYPE(ch) == star_expr || TYPE(ch) == namedexpr_test);
-
- expression = ast_for_expr(c, ch);
- if (!expression)
- return NULL;
-
- assert(i / 2 < seq->size);
- asdl_seq_SET(seq, i / 2, expression);
- }
- return seq;
-}
-
-static arg_ty
-ast_for_arg(struct compiling *c, const node *n)
-{
- identifier name;
- expr_ty annotation = NULL;
- node *ch;
- arg_ty ret;
-
- assert(TYPE(n) == tfpdef || TYPE(n) == vfpdef);
- ch = CHILD(n, 0);
- name = NEW_IDENTIFIER(ch);
- if (!name)
- return NULL;
- if (forbidden_name(c, name, ch, 0))
- return NULL;
-
- if (NCH(n) == 3 && TYPE(CHILD(n, 1)) == COLON) {
- annotation = ast_for_expr(c, CHILD(n, 2));
- if (!annotation)
- return NULL;
- }
-
- ret = arg(name, annotation, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- if (!ret)
- return NULL;
- return ret;
-}
-
-/* returns -1 if failed to handle keyword only arguments
- returns new position to keep processing if successful
- (',' tfpdef ['=' test])*
- ^^^
- start pointing here
- */
-static int
-handle_keywordonly_args(struct compiling *c, const node *n, int start,
- asdl_seq *kwonlyargs, asdl_seq *kwdefaults)
-{
- PyObject *argname;
- node *ch;
- expr_ty expression, annotation;
- arg_ty arg = NULL;
- int i = start;
- int j = 0; /* index for kwdefaults and kwonlyargs */
-
- if (kwonlyargs == NULL) {
- ast_error(c, CHILD(n, start), "named arguments must follow bare *");
- return -1;
- }
- assert(kwdefaults != NULL);
- while (i < NCH(n)) {
- ch = CHILD(n, i);
- switch (TYPE(ch)) {
- case vfpdef:
- case tfpdef:
- if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
- expression = ast_for_expr(c, CHILD(n, i + 2));
- if (!expression)
- goto error;
- asdl_seq_SET(kwdefaults, j, expression);
- i += 2; /* '=' and test */
- }
- else { /* setting NULL if no default value exists */
- asdl_seq_SET(kwdefaults, j, NULL);
- }
- if (NCH(ch) == 3) {
- /* ch is NAME ':' test */
- annotation = ast_for_expr(c, CHILD(ch, 2));
- if (!annotation)
- goto error;
- }
- else {
- annotation = NULL;
- }
- ch = CHILD(ch, 0);
- argname = NEW_IDENTIFIER(ch);
- if (!argname)
- goto error;
- if (forbidden_name(c, argname, ch, 0))
- goto error;
- arg = arg(argname, annotation, NULL, LINENO(ch), ch->n_col_offset,
- ch->n_end_lineno, ch->n_end_col_offset,
- c->c_arena);
- if (!arg)
- goto error;
- asdl_seq_SET(kwonlyargs, j++, arg);
- i += 1; /* the name */
- if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
- i += 1; /* the comma, if present */
- break;
- case TYPE_COMMENT:
- /* arg will be equal to the last argument processed */
- arg->type_comment = NEW_TYPE_COMMENT(ch);
- if (!arg->type_comment)
- goto error;
- i += 1;
- break;
- case DOUBLESTAR:
- return i;
- default:
- ast_error(c, ch, "unexpected node");
- goto error;
- }
- }
- return i;
- error:
- return -1;
-}
-
-/* Create AST for argument list. */
-
-static arguments_ty
-ast_for_arguments(struct compiling *c, const node *n)
-{
- /* This function handles both typedargslist (function definition)
- and varargslist (lambda definition).
-
- parameters: '(' [typedargslist] ')'
-
- The following definition for typedarglist is equivalent to this set of rules:
-
- arguments = argument (',' [TYPE_COMMENT] argument)*
- argument = tfpdef ['=' test]
- kwargs = '**' tfpdef [','] [TYPE_COMMENT]
- args = '*' [tfpdef]
- kwonly_kwargs = (',' [TYPE_COMMENT] argument)* (TYPE_COMMENT | [','
- [TYPE_COMMENT] [kwargs]])
- args_kwonly_kwargs = args kwonly_kwargs | kwargs
- poskeyword_args_kwonly_kwargs = arguments ( TYPE_COMMENT | [','
- [TYPE_COMMENT] [args_kwonly_kwargs]])
- typedargslist_no_posonly = poskeyword_args_kwonly_kwargs | args_kwonly_kwargs
- typedarglist = (arguments ',' [TYPE_COMMENT] '/' [',' [[TYPE_COMMENT]
- typedargslist_no_posonly]])|(typedargslist_no_posonly)"
-
- typedargslist: ( (tfpdef ['=' test] (',' [TYPE_COMMENT] tfpdef ['=' test])*
- ',' [TYPE_COMMENT] '/' [',' [ [TYPE_COMMENT] tfpdef ['=' test] ( ','
- [TYPE_COMMENT] tfpdef ['=' test])* (TYPE_COMMENT | [',' [TYPE_COMMENT] [ '*'
- [tfpdef] (',' [TYPE_COMMENT] tfpdef ['=' test])* (TYPE_COMMENT | [','
- [TYPE_COMMENT] ['**' tfpdef [','] [TYPE_COMMENT]]]) | '**' tfpdef [',']
- [TYPE_COMMENT]]]) | '*' [tfpdef] (',' [TYPE_COMMENT] tfpdef ['=' test])*
- (TYPE_COMMENT | [',' [TYPE_COMMENT] ['**' tfpdef [','] [TYPE_COMMENT]]]) |
- '**' tfpdef [','] [TYPE_COMMENT]]] ) | (tfpdef ['=' test] (','
- [TYPE_COMMENT] tfpdef ['=' test])* (TYPE_COMMENT | [',' [TYPE_COMMENT] [ '*'
- [tfpdef] (',' [TYPE_COMMENT] tfpdef ['=' test])* (TYPE_COMMENT | [','
- [TYPE_COMMENT] ['**' tfpdef [','] [TYPE_COMMENT]]]) | '**' tfpdef [',']
- [TYPE_COMMENT]]]) | '*' [tfpdef] (',' [TYPE_COMMENT] tfpdef ['=' test])*
- (TYPE_COMMENT | [',' [TYPE_COMMENT] ['**' tfpdef [','] [TYPE_COMMENT]]]) |
- '**' tfpdef [','] [TYPE_COMMENT]))
-
- tfpdef: NAME [':' test]
-
- The following definition for varargslist is equivalent to this set of rules:
-
- arguments = argument (',' argument )*
- argument = vfpdef ['=' test]
- kwargs = '**' vfpdef [',']
- args = '*' [vfpdef]
- kwonly_kwargs = (',' argument )* [',' [kwargs]]
- args_kwonly_kwargs = args kwonly_kwargs | kwargs
- poskeyword_args_kwonly_kwargs = arguments [',' [args_kwonly_kwargs]]
- vararglist_no_posonly = poskeyword_args_kwonly_kwargs | args_kwonly_kwargs
- varargslist = arguments ',' '/' [','[(vararglist_no_posonly)]] |
- (vararglist_no_posonly)
-
- varargslist: vfpdef ['=' test ](',' vfpdef ['=' test])* ',' '/' [',' [ (vfpdef ['='
- test] (',' vfpdef ['=' test])* [',' [ '*' [vfpdef] (',' vfpdef ['=' test])* [','
- ['**' vfpdef [',']]] | '**' vfpdef [',']]] | '*' [vfpdef] (',' vfpdef ['=' test])*
- [',' ['**' vfpdef [',']]] | '**' vfpdef [',']) ]] | (vfpdef ['=' test] (',' vfpdef
- ['=' test])* [',' [ '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef [',']]]
- | '**' vfpdef [',']]] | '*' [vfpdef] (',' vfpdef ['=' test])* [',' ['**' vfpdef
- [',']]] | '**' vfpdef [','])
-
- vfpdef: NAME
-
- */
- int i, j, k, l, nposonlyargs=0, nposargs = 0, nkwonlyargs = 0;
- int nposdefaults = 0, found_default = 0;
- asdl_seq *posonlyargs, *posargs, *posdefaults, *kwonlyargs, *kwdefaults;
- arg_ty vararg = NULL, kwarg = NULL;
- arg_ty arg = NULL;
- node *ch;
-
- if (TYPE(n) == parameters) {
- if (NCH(n) == 2) /* () as argument list */
- return arguments(NULL, NULL, NULL, NULL, NULL, NULL, NULL, c->c_arena);
- n = CHILD(n, 1);
- }
- assert(TYPE(n) == typedargslist || TYPE(n) == varargslist);
-
- /* First count the number of positional args & defaults. The
- variable i is the loop index for this for loop and the next.
- The next loop picks up where the first leaves off.
- */
- for (i = 0; i < NCH(n); i++) {
- ch = CHILD(n, i);
- if (TYPE(ch) == STAR) {
- /* skip star */
- i++;
- if (i < NCH(n) && /* skip argument following star */
- (TYPE(CHILD(n, i)) == tfpdef ||
- TYPE(CHILD(n, i)) == vfpdef)) {
- i++;
- }
- break;
- }
- if (TYPE(ch) == DOUBLESTAR) break;
- if (TYPE(ch) == vfpdef || TYPE(ch) == tfpdef) nposargs++;
- if (TYPE(ch) == EQUAL) nposdefaults++;
- if (TYPE(ch) == SLASH ) {
- nposonlyargs = nposargs;
- nposargs = 0;
- }
- }
- /* count the number of keyword only args &
- defaults for keyword only args */
- for ( ; i < NCH(n); ++i) {
- ch = CHILD(n, i);
- if (TYPE(ch) == DOUBLESTAR) break;
- if (TYPE(ch) == tfpdef || TYPE(ch) == vfpdef) nkwonlyargs++;
- }
- posonlyargs = (nposonlyargs ? _Py_asdl_seq_new(nposonlyargs, c->c_arena) : NULL);
- if (!posonlyargs && nposonlyargs) {
- return NULL;
- }
- posargs = (nposargs ? _Py_asdl_seq_new(nposargs, c->c_arena) : NULL);
- if (!posargs && nposargs)
- return NULL;
- kwonlyargs = (nkwonlyargs ?
- _Py_asdl_seq_new(nkwonlyargs, c->c_arena) : NULL);
- if (!kwonlyargs && nkwonlyargs)
- return NULL;
- posdefaults = (nposdefaults ?
- _Py_asdl_seq_new(nposdefaults, c->c_arena) : NULL);
- if (!posdefaults && nposdefaults)
- return NULL;
- /* The length of kwonlyargs and kwdefaults are same
- since we set NULL as default for keyword only argument w/o default
- - we have sequence data structure, but no dictionary */
- kwdefaults = (nkwonlyargs ?
- _Py_asdl_seq_new(nkwonlyargs, c->c_arena) : NULL);
- if (!kwdefaults && nkwonlyargs)
- return NULL;
-
- /* tfpdef: NAME [':' test]
- vfpdef: NAME
- */
- i = 0;
- j = 0; /* index for defaults */
- k = 0; /* index for args */
- l = 0; /* index for posonlyargs */
- while (i < NCH(n)) {
- ch = CHILD(n, i);
- switch (TYPE(ch)) {
- case tfpdef:
- case vfpdef:
- /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is
- anything other than EQUAL or a comma? */
- /* XXX Should NCH(n) check be made a separate check? */
- if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
- expr_ty expression = ast_for_expr(c, CHILD(n, i + 2));
- if (!expression)
- return NULL;
- assert(posdefaults != NULL);
- asdl_seq_SET(posdefaults, j++, expression);
- i += 2;
- found_default = 1;
- }
- else if (found_default) {
- ast_error(c, n,
- "non-default argument follows default argument");
- return NULL;
- }
- arg = ast_for_arg(c, ch);
- if (!arg)
- return NULL;
- if (l < nposonlyargs) {
- asdl_seq_SET(posonlyargs, l++, arg);
- } else {
- asdl_seq_SET(posargs, k++, arg);
- }
- i += 1; /* the name */
- if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
- i += 1; /* the comma, if present */
- break;
- case SLASH:
- /* Advance the slash and the comma. If there are more names
- * after the slash there will be a comma so we are advancing
- * the correct number of nodes. If the slash is the last item,
- * we will be advancing an extra token but then * i > NCH(n)
- * and the enclosing while will finish correctly. */
- i += 2;
- break;
- case STAR:
- if (i+1 >= NCH(n) ||
- (i+2 == NCH(n) && (TYPE(CHILD(n, i+1)) == COMMA
- || TYPE(CHILD(n, i+1)) == TYPE_COMMENT))) {
- ast_error(c, CHILD(n, i),
- "named arguments must follow bare *");
- return NULL;
- }
- ch = CHILD(n, i+1); /* tfpdef or COMMA */
- if (TYPE(ch) == COMMA) {
- int res = 0;
- i += 2; /* now follows keyword only arguments */
-
- if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {
- ast_error(c, CHILD(n, i),
- "bare * has associated type comment");
- return NULL;
- }
-
- res = handle_keywordonly_args(c, n, i,
- kwonlyargs, kwdefaults);
- if (res == -1) return NULL;
- i = res; /* res has new position to process */
- }
- else {
- vararg = ast_for_arg(c, ch);
- if (!vararg)
- return NULL;
-
- i += 2; /* the star and the name */
- if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
- i += 1; /* the comma, if present */
-
- if (i < NCH(n) && TYPE(CHILD(n, i)) == TYPE_COMMENT) {
- vararg->type_comment = NEW_TYPE_COMMENT(CHILD(n, i));
- if (!vararg->type_comment)
- return NULL;
- i += 1;
- }
-
- if (i < NCH(n) && (TYPE(CHILD(n, i)) == tfpdef
- || TYPE(CHILD(n, i)) == vfpdef)) {
- int res = 0;
- res = handle_keywordonly_args(c, n, i,
- kwonlyargs, kwdefaults);
- if (res == -1) return NULL;
- i = res; /* res has new position to process */
- }
- }
- break;
- case DOUBLESTAR:
- ch = CHILD(n, i+1); /* tfpdef */
- assert(TYPE(ch) == tfpdef || TYPE(ch) == vfpdef);
- kwarg = ast_for_arg(c, ch);
- if (!kwarg)
- return NULL;
- i += 2; /* the double star and the name */
- if (i < NCH(n) && TYPE(CHILD(n, i)) == COMMA)
- i += 1; /* the comma, if present */
- break;
- case TYPE_COMMENT:
- assert(i);
-
- if (kwarg)
- arg = kwarg;
-
- /* arg will be equal to the last argument processed */
- arg->type_comment = NEW_TYPE_COMMENT(ch);
- if (!arg->type_comment)
- return NULL;
- i += 1;
- break;
- default:
- PyErr_Format(PyExc_SystemError,
- "unexpected node in varargslist: %d @ %d",
- TYPE(ch), i);
- return NULL;
- }
- }
- return arguments(posonlyargs, posargs, vararg, kwonlyargs, kwdefaults, kwarg, posdefaults, c->c_arena);
-}
-
-static expr_ty
-ast_for_decorator(struct compiling *c, const node *n)
-{
- /* decorator: '@' namedexpr_test NEWLINE */
-
- REQ(n, decorator);
- REQ(CHILD(n, 0), AT);
- REQ(CHILD(n, 2), NEWLINE);
-
- return ast_for_expr(c, CHILD(n, 1));
-}
-
-static asdl_seq*
-ast_for_decorators(struct compiling *c, const node *n)
-{
- asdl_seq* decorator_seq;
- expr_ty d;
- int i;
-
- REQ(n, decorators);
- decorator_seq = _Py_asdl_seq_new(NCH(n), c->c_arena);
- if (!decorator_seq)
- return NULL;
-
- for (i = 0; i < NCH(n); i++) {
- d = ast_for_decorator(c, CHILD(n, i));
- if (!d)
- return NULL;
- asdl_seq_SET(decorator_seq, i, d);
- }
- return decorator_seq;
-}
-
-static stmt_ty
-ast_for_funcdef_impl(struct compiling *c, const node *n0,
- asdl_seq *decorator_seq, bool is_async)
-{
- /* funcdef: 'def' NAME parameters ['->' test] ':' [TYPE_COMMENT] suite */
- const node * const n = is_async ? CHILD(n0, 1) : n0;
- identifier name;
- arguments_ty args;
- asdl_seq *body;
- expr_ty returns = NULL;
- int name_i = 1;
- int end_lineno, end_col_offset;
- node *tc;
- string type_comment = NULL;
-
- if (is_async && c->c_feature_version < 5) {
- ast_error(c, n,
- "Async functions are only supported in Python 3.5 and greater");
- return NULL;
- }
-
- REQ(n, funcdef);
-
- name = NEW_IDENTIFIER(CHILD(n, name_i));
- if (!name)
- return NULL;
- if (forbidden_name(c, name, CHILD(n, name_i), 0))
- return NULL;
- args = ast_for_arguments(c, CHILD(n, name_i + 1));
- if (!args)
- return NULL;
- if (TYPE(CHILD(n, name_i+2)) == RARROW) {
- returns = ast_for_expr(c, CHILD(n, name_i + 3));
- if (!returns)
- return NULL;
- name_i += 2;
- }
- if (TYPE(CHILD(n, name_i + 3)) == TYPE_COMMENT) {
- type_comment = NEW_TYPE_COMMENT(CHILD(n, name_i + 3));
- if (!type_comment)
- return NULL;
- name_i += 1;
- }
- body = ast_for_suite(c, CHILD(n, name_i + 3));
- if (!body)
- return NULL;
- get_last_end_pos(body, &end_lineno, &end_col_offset);
-
- if (NCH(CHILD(n, name_i + 3)) > 1) {
- /* Check if the suite has a type comment in it. */
- tc = CHILD(CHILD(n, name_i + 3), 1);
-
- if (TYPE(tc) == TYPE_COMMENT) {
- if (type_comment != NULL) {
- ast_error(c, n, "Cannot have two type comments on def");
- return NULL;
- }
- type_comment = NEW_TYPE_COMMENT(tc);
- if (!type_comment)
- return NULL;
- }
- }
-
- if (is_async)
- return AsyncFunctionDef(name, args, body, decorator_seq, returns, type_comment,
- LINENO(n0), n0->n_col_offset, end_lineno, end_col_offset, c->c_arena);
- else
- return FunctionDef(name, args, body, decorator_seq, returns, type_comment,
- LINENO(n), n->n_col_offset, end_lineno, end_col_offset, c->c_arena);
-}
-
-static stmt_ty
-ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)
-{
- /* async_funcdef: ASYNC funcdef */
- REQ(n, async_funcdef);
- REQ(CHILD(n, 0), ASYNC);
- REQ(CHILD(n, 1), funcdef);
-
- return ast_for_funcdef_impl(c, n, decorator_seq,
- true /* is_async */);
-}
-
-static stmt_ty
-ast_for_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)
-{
- /* funcdef: 'def' NAME parameters ['->' test] ':' suite */
- return ast_for_funcdef_impl(c, n, decorator_seq,
- false /* is_async */);
-}
-
-
-static stmt_ty
-ast_for_async_stmt(struct compiling *c, const node *n)
-{
- /* async_stmt: ASYNC (funcdef | with_stmt | for_stmt) */
- REQ(n, async_stmt);
- REQ(CHILD(n, 0), ASYNC);
-
- switch (TYPE(CHILD(n, 1))) {
- case funcdef:
- return ast_for_funcdef_impl(c, n, NULL,
- true /* is_async */);
- case with_stmt:
- return ast_for_with_stmt(c, n,
- true /* is_async */);
-
- case for_stmt:
- return ast_for_for_stmt(c, n,
- true /* is_async */);
-
- default:
- PyErr_Format(PyExc_SystemError,
- "invalid async stament: %s",
- STR(CHILD(n, 1)));
- return NULL;
- }
-}
-
-static stmt_ty
-ast_for_decorated(struct compiling *c, const node *n)
-{
- /* decorated: decorators (classdef | funcdef | async_funcdef) */
- stmt_ty thing = NULL;
- asdl_seq *decorator_seq = NULL;
-
- REQ(n, decorated);
-
- decorator_seq = ast_for_decorators(c, CHILD(n, 0));
- if (!decorator_seq)
- return NULL;
-
- assert(TYPE(CHILD(n, 1)) == funcdef ||
- TYPE(CHILD(n, 1)) == async_funcdef ||
- TYPE(CHILD(n, 1)) == classdef);
-
- if (TYPE(CHILD(n, 1)) == funcdef) {
- thing = ast_for_funcdef(c, CHILD(n, 1), decorator_seq);
- } else if (TYPE(CHILD(n, 1)) == classdef) {
- thing = ast_for_classdef(c, CHILD(n, 1), decorator_seq);
- } else if (TYPE(CHILD(n, 1)) == async_funcdef) {
- thing = ast_for_async_funcdef(c, CHILD(n, 1), decorator_seq);
- }
- return thing;
-}
-
-static expr_ty
-ast_for_namedexpr(struct compiling *c, const node *n)
-{
- /* namedexpr_test: test [':=' test]
- argument: ( test [comp_for] |
- test ':=' test |
- test '=' test |
- '**' test |
- '*' test )
- */
- expr_ty target, value;
-
- target = ast_for_expr(c, CHILD(n, 0));
- if (!target)
- return NULL;
-
- value = ast_for_expr(c, CHILD(n, 2));
- if (!value)
- return NULL;
-
- if (target->kind != Name_kind) {
- const char *expr_name = get_expr_name(target);
- if (expr_name != NULL) {
- ast_error(c, n, "cannot use assignment expressions with %s", expr_name);
- }
- return NULL;
- }
-
- if (!set_context(c, target, Store, n))
- return NULL;
-
- return NamedExpr(target, value, LINENO(n), n->n_col_offset, n->n_end_lineno,
- n->n_end_col_offset, c->c_arena);
-}
-
-static expr_ty
-ast_for_lambdef(struct compiling *c, const node *n)
-{
- /* lambdef: 'lambda' [varargslist] ':' test
- lambdef_nocond: 'lambda' [varargslist] ':' test_nocond */
- arguments_ty args;
- expr_ty expression;
-
- if (NCH(n) == 3) {
- args = arguments(NULL, NULL, NULL, NULL, NULL, NULL, NULL, c->c_arena);
- if (!args)
- return NULL;
- expression = ast_for_expr(c, CHILD(n, 2));
- if (!expression)
- return NULL;
- }
- else {
- args = ast_for_arguments(c, CHILD(n, 1));
- if (!args)
- return NULL;
- expression = ast_for_expr(c, CHILD(n, 3));
- if (!expression)
- return NULL;
- }
-
- return Lambda(args, expression, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static expr_ty
-ast_for_ifexpr(struct compiling *c, const node *n)
-{
- /* test: or_test 'if' or_test 'else' test */
- expr_ty expression, body, orelse;
-
- assert(NCH(n) == 5);
- body = ast_for_expr(c, CHILD(n, 0));
- if (!body)
- return NULL;
- expression = ast_for_expr(c, CHILD(n, 2));
- if (!expression)
- return NULL;
- orelse = ast_for_expr(c, CHILD(n, 4));
- if (!orelse)
- return NULL;
- return IfExp(expression, body, orelse, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- c->c_arena);
-}
-
-/*
- Count the number of 'for' loops in a comprehension.
-
- Helper for ast_for_comprehension().
-*/
-
-static int
-count_comp_fors(struct compiling *c, const node *n)
-{
- int n_fors = 0;
-
- count_comp_for:
- n_fors++;
- REQ(n, comp_for);
- if (NCH(n) == 2) {
- REQ(CHILD(n, 0), ASYNC);
- n = CHILD(n, 1);
- }
- else if (NCH(n) == 1) {
- n = CHILD(n, 0);
- }
- else {
- goto error;
- }
- if (NCH(n) == (5)) {
- n = CHILD(n, 4);
- }
- else {
- return n_fors;
- }
- count_comp_iter:
- REQ(n, comp_iter);
- n = CHILD(n, 0);
- if (TYPE(n) == comp_for)
- goto count_comp_for;
- else if (TYPE(n) == comp_if) {
- if (NCH(n) == 3) {
- n = CHILD(n, 2);
- goto count_comp_iter;
- }
- else
- return n_fors;
- }
-
- error:
- /* Should never be reached */
- PyErr_SetString(PyExc_SystemError,
- "logic error in count_comp_fors");
- return -1;
-}
-
-/* Count the number of 'if' statements in a comprehension.
-
- Helper for ast_for_comprehension().
-*/
-
-static int
-count_comp_ifs(struct compiling *c, const node *n)
-{
- int n_ifs = 0;
-
- while (1) {
- REQ(n, comp_iter);
- if (TYPE(CHILD(n, 0)) == comp_for)
- return n_ifs;
- n = CHILD(n, 0);
- REQ(n, comp_if);
- n_ifs++;
- if (NCH(n) == 2)
- return n_ifs;
- n = CHILD(n, 2);
- }
-}
-
-static asdl_seq *
-ast_for_comprehension(struct compiling *c, const node *n)
-{
- int i, n_fors;
- asdl_seq *comps;
-
- n_fors = count_comp_fors(c, n);
- if (n_fors == -1)
- return NULL;
-
- comps = _Py_asdl_seq_new(n_fors, c->c_arena);
- if (!comps)
- return NULL;
-
- for (i = 0; i < n_fors; i++) {
- comprehension_ty comp;
- asdl_seq *t;
- expr_ty expression, first;
- node *for_ch;
- node *sync_n;
- int is_async = 0;
-
- REQ(n, comp_for);
-
- if (NCH(n) == 2) {
- is_async = 1;
- REQ(CHILD(n, 0), ASYNC);
- sync_n = CHILD(n, 1);
- }
- else {
- sync_n = CHILD(n, 0);
- }
- REQ(sync_n, sync_comp_for);
-
- /* Async comprehensions only allowed in Python 3.6 and greater */
- if (is_async && c->c_feature_version < 6) {
- ast_error(c, n,
- "Async comprehensions are only supported in Python 3.6 and greater");
- return NULL;
- }
-
- for_ch = CHILD(sync_n, 1);
- t = ast_for_exprlist(c, for_ch, Store);
- if (!t)
- return NULL;
- expression = ast_for_expr(c, CHILD(sync_n, 3));
- if (!expression)
- return NULL;
-
- /* Check the # of children rather than the length of t, since
- (x for x, in ...) has 1 element in t, but still requires a Tuple. */
- first = (expr_ty)asdl_seq_GET(t, 0);
- if (NCH(for_ch) == 1)
- comp = comprehension(first, expression, NULL,
- is_async, c->c_arena);
- else
- comp = comprehension(Tuple(t, Store, first->lineno, first->col_offset,
- for_ch->n_end_lineno, for_ch->n_end_col_offset,
- c->c_arena),
- expression, NULL, is_async, c->c_arena);
- if (!comp)
- return NULL;
-
- if (NCH(sync_n) == 5) {
- int j, n_ifs;
- asdl_seq *ifs;
-
- n = CHILD(sync_n, 4);
- n_ifs = count_comp_ifs(c, n);
- if (n_ifs == -1)
- return NULL;
-
- ifs = _Py_asdl_seq_new(n_ifs, c->c_arena);
- if (!ifs)
- return NULL;
-
- for (j = 0; j < n_ifs; j++) {
- REQ(n, comp_iter);
- n = CHILD(n, 0);
- REQ(n, comp_if);
-
- expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
- asdl_seq_SET(ifs, j, expression);
- if (NCH(n) == 3)
- n = CHILD(n, 2);
- }
- /* on exit, must guarantee that n is a comp_for */
- if (TYPE(n) == comp_iter)
- n = CHILD(n, 0);
- comp->ifs = ifs;
- }
- asdl_seq_SET(comps, i, comp);
- }
- return comps;
-}
-
-static expr_ty
-ast_for_itercomp(struct compiling *c, const node *n, int type)
-{
- /* testlist_comp: (test|star_expr)
- * ( comp_for | (',' (test|star_expr))* [','] ) */
- expr_ty elt;
- asdl_seq *comps;
- node *ch;
-
- assert(NCH(n) > 1);
-
- ch = CHILD(n, 0);
- elt = ast_for_expr(c, ch);
- if (!elt)
- return NULL;
- if (elt->kind == Starred_kind) {
- ast_error(c, ch, "iterable unpacking cannot be used in comprehension");
- return NULL;
- }
-
- comps = ast_for_comprehension(c, CHILD(n, 1));
- if (!comps)
- return NULL;
-
- if (type == COMP_GENEXP)
- return GeneratorExp(elt, comps, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- else if (type == COMP_LISTCOMP)
- return ListComp(elt, comps, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- else if (type == COMP_SETCOMP)
- return SetComp(elt, comps, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- else
- /* Should never happen */
- return NULL;
-}
-
-/* Fills in the key, value pair corresponding to the dict element. In case
- * of an unpacking, key is NULL. *i is advanced by the number of ast
- * elements. Iff successful, nonzero is returned.
- */
-static int
-ast_for_dictelement(struct compiling *c, const node *n, int *i,
- expr_ty *key, expr_ty *value)
-{
- expr_ty expression;
- if (TYPE(CHILD(n, *i)) == DOUBLESTAR) {
- assert(NCH(n) - *i >= 2);
-
- expression = ast_for_expr(c, CHILD(n, *i + 1));
- if (!expression)
- return 0;
- *key = NULL;
- *value = expression;
-
- *i += 2;
- }
- else {
- assert(NCH(n) - *i >= 3);
-
- expression = ast_for_expr(c, CHILD(n, *i));
- if (!expression)
- return 0;
- *key = expression;
-
- REQ(CHILD(n, *i + 1), COLON);
-
- expression = ast_for_expr(c, CHILD(n, *i + 2));
- if (!expression)
- return 0;
- *value = expression;
-
- *i += 3;
- }
- return 1;
-}
-
-static expr_ty
-ast_for_dictcomp(struct compiling *c, const node *n)
-{
- expr_ty key, value;
- asdl_seq *comps;
- int i = 0;
-
- if (!ast_for_dictelement(c, n, &i, &key, &value))
- return NULL;
- assert(key);
- assert(NCH(n) - i >= 1);
-
- comps = ast_for_comprehension(c, CHILD(n, i));
- if (!comps)
- return NULL;
-
- return DictComp(key, value, comps, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static expr_ty
-ast_for_dictdisplay(struct compiling *c, const node *n)
-{
- int i;
- int j;
- int size;
- asdl_seq *keys, *values;
-
- size = (NCH(n) + 1) / 3; /* +1 in case no trailing comma */
- keys = _Py_asdl_seq_new(size, c->c_arena);
- if (!keys)
- return NULL;
-
- values = _Py_asdl_seq_new(size, c->c_arena);
- if (!values)
- return NULL;
-
- j = 0;
- for (i = 0; i < NCH(n); i++) {
- expr_ty key, value;
-
- if (!ast_for_dictelement(c, n, &i, &key, &value))
- return NULL;
- asdl_seq_SET(keys, j, key);
- asdl_seq_SET(values, j, value);
-
- j++;
- }
- keys->size = j;
- values->size = j;
- return Dict(keys, values, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static expr_ty
-ast_for_genexp(struct compiling *c, const node *n)
-{
- assert(TYPE(n) == (testlist_comp) || TYPE(n) == (argument));
- return ast_for_itercomp(c, n, COMP_GENEXP);
-}
-
-static expr_ty
-ast_for_listcomp(struct compiling *c, const node *n)
-{
- assert(TYPE(n) == (testlist_comp));
- return ast_for_itercomp(c, n, COMP_LISTCOMP);
-}
-
-static expr_ty
-ast_for_setcomp(struct compiling *c, const node *n)
-{
- assert(TYPE(n) == (dictorsetmaker));
- return ast_for_itercomp(c, n, COMP_SETCOMP);
-}
-
-static expr_ty
-ast_for_setdisplay(struct compiling *c, const node *n)
-{
- int i;
- int size;
- asdl_seq *elts;
-
- assert(TYPE(n) == (dictorsetmaker));
- size = (NCH(n) + 1) / 2; /* +1 in case no trailing comma */
- elts = _Py_asdl_seq_new(size, c->c_arena);
- if (!elts)
- return NULL;
- for (i = 0; i < NCH(n); i += 2) {
- expr_ty expression;
- expression = ast_for_expr(c, CHILD(n, i));
- if (!expression)
- return NULL;
- asdl_seq_SET(elts, i / 2, expression);
- }
- return Set(elts, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static expr_ty
-ast_for_atom(struct compiling *c, const node *n)
-{
- /* atom: '(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']'
- | '{' [dictmaker|testlist_comp] '}' | NAME | NUMBER | STRING+
- | '...' | 'None' | 'True' | 'False'
- */
- node *ch = CHILD(n, 0);
-
- switch (TYPE(ch)) {
- case NAME: {
- PyObject *name;
- const char *s = STR(ch);
- size_t len = strlen(s);
- if (len >= 4 && len <= 5) {
- if (!strcmp(s, "None"))
- return Constant(Py_None, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- if (!strcmp(s, "True"))
- return Constant(Py_True, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- if (!strcmp(s, "False"))
- return Constant(Py_False, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- name = new_identifier(s, c);
- if (!name)
- return NULL;
- /* All names start in Load context, but may later be changed. */
- return Name(name, Load, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- case STRING: {
- expr_ty str = parsestrplus(c, n);
- if (!str) {
- const char *errtype = NULL;
- if (PyErr_ExceptionMatches(PyExc_UnicodeError))
- errtype = "unicode error";
- else if (PyErr_ExceptionMatches(PyExc_ValueError))
- errtype = "value error";
- if (errtype) {
- PyObject *type, *value, *tback, *errstr;
- PyErr_Fetch(&type, &value, &tback);
- errstr = PyObject_Str(value);
- if (errstr) {
- ast_error(c, n, "(%s) %U", errtype, errstr);
- Py_DECREF(errstr);
- }
- else {
- PyErr_Clear();
- ast_error(c, n, "(%s) unknown error", errtype);
- }
- Py_DECREF(type);
- Py_XDECREF(value);
- Py_XDECREF(tback);
- }
- return NULL;
- }
- return str;
- }
- case NUMBER: {
- PyObject *pynum;
- /* Underscores in numeric literals are only allowed in Python 3.6 or greater */
- /* Check for underscores here rather than in parse_number so we can report a line number on error */
- if (c->c_feature_version < 6 && strchr(STR(ch), '_') != NULL) {
- ast_error(c, ch,
- "Underscores in numeric literals are only supported in Python 3.6 and greater");
- return NULL;
- }
- pynum = parsenumber(c, STR(ch));
- if (!pynum)
- return NULL;
-
- if (PyArena_AddPyObject(c->c_arena, pynum) < 0) {
- Py_DECREF(pynum);
- return NULL;
- }
- return Constant(pynum, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- case ELLIPSIS: /* Ellipsis */
- return Constant(Py_Ellipsis, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- case LPAR: /* some parenthesized expressions */
- ch = CHILD(n, 1);
-
- if (TYPE(ch) == RPAR)
- return Tuple(NULL, Load, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-
- if (TYPE(ch) == yield_expr)
- return ast_for_expr(c, ch);
-
- /* testlist_comp: test ( comp_for | (',' test)* [','] ) */
- if (NCH(ch) == 1) {
- return ast_for_testlist(c, ch);
- }
-
- if (TYPE(CHILD(ch, 1)) == comp_for) {
- return copy_location(ast_for_genexp(c, ch), n, n);
- }
- else {
- return copy_location(ast_for_testlist(c, ch), n, n);
- }
- case LSQB: /* list (or list comprehension) */
- ch = CHILD(n, 1);
-
- if (TYPE(ch) == RSQB)
- return List(NULL, Load, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-
- REQ(ch, testlist_comp);
- if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) {
- asdl_seq *elts = seq_for_testlist(c, ch);
- if (!elts)
- return NULL;
-
- return List(elts, Load, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else {
- return copy_location(ast_for_listcomp(c, ch), n, n);
- }
- case LBRACE: {
- /* dictorsetmaker: ( ((test ':' test | '**' test)
- * (comp_for | (',' (test ':' test | '**' test))* [','])) |
- * ((test | '*' test)
- * (comp_for | (',' (test | '*' test))* [','])) ) */
- expr_ty res;
- ch = CHILD(n, 1);
- if (TYPE(ch) == RBRACE) {
- /* It's an empty dict. */
- return Dict(NULL, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else {
- int is_dict = (TYPE(CHILD(ch, 0)) == DOUBLESTAR);
- if (NCH(ch) == 1 ||
- (NCH(ch) > 1 &&
- TYPE(CHILD(ch, 1)) == COMMA)) {
- /* It's a set display. */
- res = ast_for_setdisplay(c, ch);
- }
- else if (NCH(ch) > 1 &&
- TYPE(CHILD(ch, 1)) == comp_for) {
- /* It's a set comprehension. */
- res = ast_for_setcomp(c, ch);
- }
- else if (NCH(ch) > 3 - is_dict &&
- TYPE(CHILD(ch, 3 - is_dict)) == comp_for) {
- /* It's a dictionary comprehension. */
- if (is_dict) {
- ast_error(c, n,
- "dict unpacking cannot be used in dict comprehension");
- return NULL;
- }
- res = ast_for_dictcomp(c, ch);
- }
- else {
- /* It's a dictionary display. */
- res = ast_for_dictdisplay(c, ch);
- }
- return copy_location(res, n, n);
- }
- }
- default:
- PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch));
- return NULL;
- }
-}
-
-static expr_ty
-ast_for_slice(struct compiling *c, const node *n)
-{
- node *ch;
- expr_ty lower = NULL, upper = NULL, step = NULL;
-
- REQ(n, subscript);
-
- /*
- subscript: test | [test] ':' [test] [sliceop]
- sliceop: ':' [test]
- */
- ch = CHILD(n, 0);
- if (NCH(n) == 1 && TYPE(ch) == test) {
- return ast_for_expr(c, ch);
- }
-
- if (TYPE(ch) == test) {
- lower = ast_for_expr(c, ch);
- if (!lower)
- return NULL;
- }
-
- /* If there's an upper bound it's in the second or third position. */
- if (TYPE(ch) == COLON) {
- if (NCH(n) > 1) {
- node *n2 = CHILD(n, 1);
-
- if (TYPE(n2) == test) {
- upper = ast_for_expr(c, n2);
- if (!upper)
- return NULL;
- }
- }
- } else if (NCH(n) > 2) {
- node *n2 = CHILD(n, 2);
-
- if (TYPE(n2) == test) {
- upper = ast_for_expr(c, n2);
- if (!upper)
- return NULL;
- }
- }
-
- ch = CHILD(n, NCH(n) - 1);
- if (TYPE(ch) == sliceop) {
- if (NCH(ch) != 1) {
- ch = CHILD(ch, 1);
- if (TYPE(ch) == test) {
- step = ast_for_expr(c, ch);
- if (!step)
- return NULL;
- }
- }
- }
-
- return Slice(lower, upper, step, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static expr_ty
-ast_for_binop(struct compiling *c, const node *n)
-{
- /* Must account for a sequence of expressions.
- How should A op B op C by represented?
- BinOp(BinOp(A, op, B), op, C).
- */
-
- int i, nops;
- expr_ty expr1, expr2, result;
- operator_ty newoperator;
-
- expr1 = ast_for_expr(c, CHILD(n, 0));
- if (!expr1)
- return NULL;
-
- expr2 = ast_for_expr(c, CHILD(n, 2));
- if (!expr2)
- return NULL;
-
- newoperator = get_operator(c, CHILD(n, 1));
- if (!newoperator)
- return NULL;
-
- result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset,
- CHILD(n, 2)->n_end_lineno, CHILD(n, 2)->n_end_col_offset,
- c->c_arena);
- if (!result)
- return NULL;
-
- nops = (NCH(n) - 1) / 2;
- for (i = 1; i < nops; i++) {
- expr_ty tmp_result, tmp;
- const node* next_oper = CHILD(n, i * 2 + 1);
-
- newoperator = get_operator(c, next_oper);
- if (!newoperator)
- return NULL;
-
- tmp = ast_for_expr(c, CHILD(n, i * 2 + 2));
- if (!tmp)
- return NULL;
-
- tmp_result = BinOp(result, newoperator, tmp,
- LINENO(n), n->n_col_offset,
- CHILD(n, i * 2 + 2)->n_end_lineno,
- CHILD(n, i * 2 + 2)->n_end_col_offset,
- c->c_arena);
- if (!tmp_result)
- return NULL;
- result = tmp_result;
- }
- return result;
-}
-
-static expr_ty
-ast_for_trailer(struct compiling *c, const node *n, expr_ty left_expr, const node *start)
-{
- /* trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
- subscriptlist: subscript (',' subscript)* [',']
- subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop]
- */
- const node *n_copy = n;
- REQ(n, trailer);
- if (TYPE(CHILD(n, 0)) == LPAR) {
- if (NCH(n) == 2)
- return Call(left_expr, NULL, NULL, LINENO(start), start->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- else
- return ast_for_call(c, CHILD(n, 1), left_expr,
- start, CHILD(n, 0), CHILD(n, 2));
- }
- else if (TYPE(CHILD(n, 0)) == DOT) {
- PyObject *attr_id = NEW_IDENTIFIER(CHILD(n, 1));
- if (!attr_id)
- return NULL;
- return Attribute(left_expr, attr_id, Load,
- LINENO(start), start->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else {
- REQ(CHILD(n, 0), LSQB);
- REQ(CHILD(n, 2), RSQB);
- n = CHILD(n, 1);
- if (NCH(n) == 1) {
- expr_ty slc = ast_for_slice(c, CHILD(n, 0));
- if (!slc)
- return NULL;
- return Subscript(left_expr, slc, Load, LINENO(start), start->n_col_offset,
- n_copy->n_end_lineno, n_copy->n_end_col_offset,
- c->c_arena);
- }
- else {
- int j;
- expr_ty slc, e;
- asdl_seq *elts;
- elts = _Py_asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
- if (!elts)
- return NULL;
- for (j = 0; j < NCH(n); j += 2) {
- slc = ast_for_slice(c, CHILD(n, j));
- if (!slc)
- return NULL;
- asdl_seq_SET(elts, j / 2, slc);
- }
- e = Tuple(elts, Load, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- c->c_arena);
- if (!e)
- return NULL;
- return Subscript(left_expr, e,
- Load, LINENO(start), start->n_col_offset,
- n_copy->n_end_lineno, n_copy->n_end_col_offset,
- c->c_arena);
- }
- }
-}
-
-static expr_ty
-ast_for_factor(struct compiling *c, const node *n)
-{
- expr_ty expression;
-
- expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
-
- switch (TYPE(CHILD(n, 0))) {
- case PLUS:
- return UnaryOp(UAdd, expression, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- c->c_arena);
- case MINUS:
- return UnaryOp(USub, expression, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- c->c_arena);
- case TILDE:
- return UnaryOp(Invert, expression, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- c->c_arena);
- }
- PyErr_Format(PyExc_SystemError, "unhandled factor: %d",
- TYPE(CHILD(n, 0)));
- return NULL;
-}
-
-static expr_ty
-ast_for_atom_expr(struct compiling *c, const node *n)
-{
- int i, nch, start = 0;
- expr_ty e;
-
- REQ(n, atom_expr);
- nch = NCH(n);
-
- if (TYPE(CHILD(n, 0)) == AWAIT) {
- if (c->c_feature_version < 5) {
- ast_error(c, n,
- "Await expressions are only supported in Python 3.5 and greater");
- return NULL;
- }
- start = 1;
- assert(nch > 1);
- }
-
- e = ast_for_atom(c, CHILD(n, start));
- if (!e)
- return NULL;
- if (nch == 1)
- return e;
- if (start && nch == 2) {
- return Await(e, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
-
- for (i = start + 1; i < nch; i++) {
- node *ch = CHILD(n, i);
- if (TYPE(ch) != trailer)
- break;
- e = ast_for_trailer(c, ch, e, CHILD(n, start));
- if (!e)
- return NULL;
- }
-
- if (start) {
- /* there was an 'await' */
- return Await(e, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else {
- return e;
- }
-}
-
-static expr_ty
-ast_for_power(struct compiling *c, const node *n)
-{
- /* power: atom trailer* ('**' factor)*
- */
- expr_ty e;
- REQ(n, power);
- e = ast_for_atom_expr(c, CHILD(n, 0));
- if (!e)
- return NULL;
- if (NCH(n) == 1)
- return e;
- if (TYPE(CHILD(n, NCH(n) - 1)) == factor) {
- expr_ty f = ast_for_expr(c, CHILD(n, NCH(n) - 1));
- if (!f)
- return NULL;
- e = BinOp(e, Pow, f, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- return e;
-}
-
-static expr_ty
-ast_for_starred(struct compiling *c, const node *n)
-{
- expr_ty tmp;
- REQ(n, star_expr);
-
- tmp = ast_for_expr(c, CHILD(n, 1));
- if (!tmp)
- return NULL;
-
- /* The Load context is changed later. */
- return Starred(tmp, Load, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-
-/* Do not name a variable 'expr'! Will cause a compile error.
-*/
-
-static expr_ty
-ast_for_expr(struct compiling *c, const node *n)
-{
- /* handle the full range of simple expressions
- namedexpr_test: test [':=' test]
- test: or_test ['if' or_test 'else' test] | lambdef
- test_nocond: or_test | lambdef_nocond
- or_test: and_test ('or' and_test)*
- and_test: not_test ('and' not_test)*
- not_test: 'not' not_test | comparison
- comparison: expr (comp_op expr)*
- expr: xor_expr ('|' xor_expr)*
- xor_expr: and_expr ('^' and_expr)*
- and_expr: shift_expr ('&' shift_expr)*
- shift_expr: arith_expr (('<<'|'>>') arith_expr)*
- arith_expr: term (('+'|'-') term)*
- term: factor (('*'|'@'|'/'|'%'|'//') factor)*
- factor: ('+'|'-'|'~') factor | power
- power: atom_expr ['**' factor]
- atom_expr: [AWAIT] atom trailer*
- yield_expr: 'yield' [yield_arg]
- */
-
- asdl_seq *seq;
- int i;
-
- loop:
- switch (TYPE(n)) {
- case namedexpr_test:
- if (NCH(n) == 3)
- return ast_for_namedexpr(c, n);
- /* Fallthrough */
- case test:
- case test_nocond:
- if (TYPE(CHILD(n, 0)) == lambdef ||
- TYPE(CHILD(n, 0)) == lambdef_nocond)
- return ast_for_lambdef(c, CHILD(n, 0));
- else if (NCH(n) > 1)
- return ast_for_ifexpr(c, n);
- /* Fallthrough */
- case or_test:
- case and_test:
- if (NCH(n) == 1) {
- n = CHILD(n, 0);
- goto loop;
- }
- seq = _Py_asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
- if (!seq)
- return NULL;
- for (i = 0; i < NCH(n); i += 2) {
- expr_ty e = ast_for_expr(c, CHILD(n, i));
- if (!e)
- return NULL;
- asdl_seq_SET(seq, i / 2, e);
- }
- if (!strcmp(STR(CHILD(n, 1)), "and"))
- return BoolOp(And, seq, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- c->c_arena);
- assert(!strcmp(STR(CHILD(n, 1)), "or"));
- return BoolOp(Or, seq, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- case not_test:
- if (NCH(n) == 1) {
- n = CHILD(n, 0);
- goto loop;
- }
- else {
- expr_ty expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
-
- return UnaryOp(Not, expression, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset,
- c->c_arena);
- }
- case comparison:
- if (NCH(n) == 1) {
- n = CHILD(n, 0);
- goto loop;
- }
- else {
- expr_ty expression;
- asdl_int_seq *ops;
- asdl_seq *cmps;
- ops = _Py_asdl_int_seq_new(NCH(n) / 2, c->c_arena);
- if (!ops)
- return NULL;
- cmps = _Py_asdl_seq_new(NCH(n) / 2, c->c_arena);
- if (!cmps) {
- return NULL;
- }
- for (i = 1; i < NCH(n); i += 2) {
- cmpop_ty newoperator;
-
- newoperator = ast_for_comp_op(c, CHILD(n, i));
- if (!newoperator) {
- return NULL;
- }
-
- expression = ast_for_expr(c, CHILD(n, i + 1));
- if (!expression) {
- return NULL;
- }
-
- asdl_seq_SET(ops, i / 2, newoperator);
- asdl_seq_SET(cmps, i / 2, expression);
- }
- expression = ast_for_expr(c, CHILD(n, 0));
- if (!expression) {
- return NULL;
- }
-
- return Compare(expression, ops, cmps, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
-
- case star_expr:
- return ast_for_starred(c, n);
- /* The next five cases all handle BinOps. The main body of code
- is the same in each case, but the switch turned inside out to
- reuse the code for each type of operator.
- */
- case expr:
- case xor_expr:
- case and_expr:
- case shift_expr:
- case arith_expr:
- case term:
- if (NCH(n) == 1) {
- n = CHILD(n, 0);
- goto loop;
- }
- return ast_for_binop(c, n);
- case yield_expr: {
- node *an = NULL;
- node *en = NULL;
- int is_from = 0;
- expr_ty exp = NULL;
- if (NCH(n) > 1)
- an = CHILD(n, 1); /* yield_arg */
- if (an) {
- en = CHILD(an, NCH(an) - 1);
- if (NCH(an) == 2) {
- is_from = 1;
- exp = ast_for_expr(c, en);
- }
- else
- exp = ast_for_testlist(c, en);
- if (!exp)
- return NULL;
- }
- if (is_from)
- return YieldFrom(exp, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- return Yield(exp, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- case factor:
- if (NCH(n) == 1) {
- n = CHILD(n, 0);
- goto loop;
- }
- return ast_for_factor(c, n);
- case power:
- return ast_for_power(c, n);
- default:
- PyErr_Format(PyExc_SystemError, "unhandled expr: %d", TYPE(n));
- return NULL;
- }
- /* should never get here unless if error is set */
- return NULL;
-}
-
-static expr_ty
-ast_for_call(struct compiling *c, const node *n, expr_ty func,
- const node *start, const node *maybegenbeg, const node *closepar)
-{
- /*
- arglist: argument (',' argument)* [',']
- argument: ( test [comp_for] | '*' test | test '=' test | '**' test )
- */
-
- int i, nargs, nkeywords;
- int ndoublestars;
- asdl_seq *args;
- asdl_seq *keywords;
-
- REQ(n, arglist);
-
- nargs = 0;
- nkeywords = 0;
- for (i = 0; i < NCH(n); i++) {
- node *ch = CHILD(n, i);
- if (TYPE(ch) == argument) {
- if (NCH(ch) == 1)
- nargs++;
- else if (TYPE(CHILD(ch, 1)) == comp_for) {
- nargs++;
- if (!maybegenbeg) {
- ast_error(c, ch, "invalid syntax");
- return NULL;
- }
- if (NCH(n) > 1) {
- ast_error(c, ch, "Generator expression must be parenthesized");
- return NULL;
- }
- }
- else if (TYPE(CHILD(ch, 0)) == STAR)
- nargs++;
- else if (TYPE(CHILD(ch, 1)) == COLONEQUAL) {
- nargs++;
- }
- else
- /* TYPE(CHILD(ch, 0)) == DOUBLESTAR or keyword argument */
- nkeywords++;
- }
- }
-
- args = _Py_asdl_seq_new(nargs, c->c_arena);
- if (!args)
- return NULL;
- keywords = _Py_asdl_seq_new(nkeywords, c->c_arena);
- if (!keywords)
- return NULL;
-
- nargs = 0; /* positional arguments + iterable argument unpackings */
- nkeywords = 0; /* keyword arguments + keyword argument unpackings */
- ndoublestars = 0; /* just keyword argument unpackings */
- for (i = 0; i < NCH(n); i++) {
- node *ch = CHILD(n, i);
- if (TYPE(ch) == argument) {
- expr_ty e;
- node *chch = CHILD(ch, 0);
- if (NCH(ch) == 1) {
- /* a positional argument */
- if (nkeywords) {
- if (ndoublestars) {
- ast_error(c, chch,
- "positional argument follows "
- "keyword argument unpacking");
- }
- else {
- ast_error(c, chch,
- "positional argument follows "
- "keyword argument");
- }
- return NULL;
- }
- e = ast_for_expr(c, chch);
- if (!e)
- return NULL;
- asdl_seq_SET(args, nargs++, e);
- }
- else if (TYPE(chch) == STAR) {
- /* an iterable argument unpacking */
- expr_ty starred;
- if (ndoublestars) {
- ast_error(c, chch,
- "iterable argument unpacking follows "
- "keyword argument unpacking");
- return NULL;
- }
- e = ast_for_expr(c, CHILD(ch, 1));
- if (!e)
- return NULL;
- starred = Starred(e, Load, LINENO(chch),
- chch->n_col_offset,
- e->end_lineno, e->end_col_offset,
- c->c_arena);
- if (!starred)
- return NULL;
- asdl_seq_SET(args, nargs++, starred);
-
- }
- else if (TYPE(chch) == DOUBLESTAR) {
- /* a keyword argument unpacking */
- keyword_ty kw;
- i++;
- e = ast_for_expr(c, CHILD(ch, 1));
- if (!e)
- return NULL;
- kw = keyword(NULL, e, chch->n_lineno, chch->n_col_offset,
- e->end_lineno, e->end_col_offset, c->c_arena);
- asdl_seq_SET(keywords, nkeywords++, kw);
- ndoublestars++;
- }
- else if (TYPE(CHILD(ch, 1)) == comp_for) {
- /* the lone generator expression */
- e = copy_location(ast_for_genexp(c, ch), maybegenbeg, closepar);
- if (!e)
- return NULL;
- asdl_seq_SET(args, nargs++, e);
- }
- else if (TYPE(CHILD(ch, 1)) == COLONEQUAL) {
- /* treat colon equal as positional argument */
- if (nkeywords) {
- if (ndoublestars) {
- ast_error(c, chch,
- "positional argument follows "
- "keyword argument unpacking");
- }
- else {
- ast_error(c, chch,
- "positional argument follows "
- "keyword argument");
- }
- return NULL;
- }
- e = ast_for_namedexpr(c, ch);
- if (!e)
- return NULL;
- asdl_seq_SET(args, nargs++, e);
- }
- else {
- /* a keyword argument */
- keyword_ty kw;
- identifier key;
-
- // To remain LL(1), the grammar accepts any test (basically, any
- // expression) in the keyword slot of a call site. So, we need
- // to manually enforce that the keyword is a NAME here.
- static const int name_tree[] = {
- test,
- or_test,
- and_test,
- not_test,
- comparison,
- expr,
- xor_expr,
- and_expr,
- shift_expr,
- arith_expr,
- term,
- factor,
- power,
- atom_expr,
- atom,
- 0,
- };
- node *expr_node = chch;
- for (int i = 0; name_tree[i]; i++) {
- if (TYPE(expr_node) != name_tree[i])
- break;
- if (NCH(expr_node) != 1)
- break;
- expr_node = CHILD(expr_node, 0);
- }
- if (TYPE(expr_node) != NAME) {
- ast_error(c, chch,
- "expression cannot contain assignment, "
- "perhaps you meant \"==\"?");
- return NULL;
- }
- key = new_identifier(STR(expr_node), c);
- if (key == NULL) {
- return NULL;
- }
- if (forbidden_name(c, key, chch, 1)) {
- return NULL;
- }
- e = ast_for_expr(c, CHILD(ch, 2));
- if (!e)
- return NULL;
- kw = keyword(key, e, chch->n_lineno, chch->n_col_offset,
- e->end_lineno, e->end_col_offset, c->c_arena);
-
- if (!kw)
- return NULL;
- asdl_seq_SET(keywords, nkeywords++, kw);
- }
- }
- }
-
- return Call(func, args, keywords, LINENO(start), start->n_col_offset,
- closepar->n_end_lineno, closepar->n_end_col_offset, c->c_arena);
-}
-
-static expr_ty
-ast_for_testlist(struct compiling *c, const node* n)
-{
- /* testlist_comp: test (comp_for | (',' test)* [',']) */
- /* testlist: test (',' test)* [','] */
- assert(NCH(n) > 0);
- if (TYPE(n) == testlist_comp) {
- if (NCH(n) > 1)
- assert(TYPE(CHILD(n, 1)) != comp_for);
- }
- else {
- assert(TYPE(n) == testlist ||
- TYPE(n) == testlist_star_expr);
- }
- if (NCH(n) == 1)
- return ast_for_expr(c, CHILD(n, 0));
- else {
- asdl_seq *tmp = seq_for_testlist(c, n);
- if (!tmp)
- return NULL;
- return Tuple(tmp, Load, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
-}
-
-static stmt_ty
-ast_for_expr_stmt(struct compiling *c, const node *n)
-{
- REQ(n, expr_stmt);
- /* expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
- [('=' (yield_expr|testlist_star_expr))+ [TYPE_COMMENT]] )
- annassign: ':' test ['=' (yield_expr|testlist)]
- testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
- augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
- '<<=' | '>>=' | '**=' | '//=')
- test: ... here starts the operator precedence dance
- */
- int num = NCH(n);
-
- if (num == 1) {
- expr_ty e = ast_for_testlist(c, CHILD(n, 0));
- if (!e)
- return NULL;
-
- return Expr(e, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else if (TYPE(CHILD(n, 1)) == augassign) {
- expr_ty expr1, expr2;
- operator_ty newoperator;
- node *ch = CHILD(n, 0);
-
- expr1 = ast_for_testlist(c, ch);
- if (!expr1)
- return NULL;
- /* Augmented assignments can only have a name, a subscript, or an
- attribute on the left, though, so we have to explicitly check for
- those. */
- switch (expr1->kind) {
- case Name_kind:
- case Attribute_kind:
- case Subscript_kind:
- break;
- default:
- ast_error(c, ch, "'%s' is an illegal expression for augmented assignment",
- get_expr_name(expr1));
- return NULL;
- }
-
- /* set_context checks that most expressions are not the left side. */
- if(!set_context(c, expr1, Store, ch)) {
- return NULL;
- }
-
- ch = CHILD(n, 2);
- if (TYPE(ch) == testlist)
- expr2 = ast_for_testlist(c, ch);
- else
- expr2 = ast_for_expr(c, ch);
- if (!expr2)
- return NULL;
-
- newoperator = ast_for_augassign(c, CHILD(n, 1));
- if (!newoperator)
- return NULL;
-
- return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else if (TYPE(CHILD(n, 1)) == annassign) {
- expr_ty expr1, expr2, expr3;
- node *ch = CHILD(n, 0);
- node *deep, *ann = CHILD(n, 1);
- int simple = 1;
-
- /* AnnAssigns are only allowed in Python 3.6 or greater */
- if (c->c_feature_version < 6) {
- ast_error(c, ch,
- "Variable annotation syntax is only supported in Python 3.6 and greater");
- return NULL;
- }
-
- /* we keep track of parens to qualify (x) as expression not name */
- deep = ch;
- while (NCH(deep) == 1) {
- deep = CHILD(deep, 0);
- }
- if (NCH(deep) > 0 && TYPE(CHILD(deep, 0)) == LPAR) {
- simple = 0;
- }
- expr1 = ast_for_testlist(c, ch);
- if (!expr1) {
- return NULL;
- }
- switch (expr1->kind) {
- case Name_kind:
- if (forbidden_name(c, expr1->v.Name.id, n, 0)) {
- return NULL;
- }
- expr1->v.Name.ctx = Store;
- break;
- case Attribute_kind:
- if (forbidden_name(c, expr1->v.Attribute.attr, n, 1)) {
- return NULL;
- }
- expr1->v.Attribute.ctx = Store;
- break;
- case Subscript_kind:
- expr1->v.Subscript.ctx = Store;
- break;
- case List_kind:
- ast_error(c, ch,
- "only single target (not list) can be annotated");
- return NULL;
- case Tuple_kind:
- ast_error(c, ch,
- "only single target (not tuple) can be annotated");
- return NULL;
- default:
- ast_error(c, ch,
- "illegal target for annotation");
- return NULL;
- }
-
- if (expr1->kind != Name_kind) {
- simple = 0;
- }
- ch = CHILD(ann, 1);
- expr2 = ast_for_expr(c, ch);
- if (!expr2) {
- return NULL;
- }
- if (NCH(ann) == 2) {
- return AnnAssign(expr1, expr2, NULL, simple,
- LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else {
- ch = CHILD(ann, 3);
- if (TYPE(ch) == testlist_star_expr) {
- expr3 = ast_for_testlist(c, ch);
- }
- else {
- expr3 = ast_for_expr(c, ch);
- }
- if (!expr3) {
- return NULL;
- }
- return AnnAssign(expr1, expr2, expr3, simple,
- LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- }
- else {
- int i, nch_minus_type, has_type_comment;
- asdl_seq *targets;
- node *value;
- expr_ty expression;
- string type_comment;
-
- /* a normal assignment */
- REQ(CHILD(n, 1), EQUAL);
-
- has_type_comment = TYPE(CHILD(n, num - 1)) == TYPE_COMMENT;
- nch_minus_type = num - has_type_comment;
-
- targets = _Py_asdl_seq_new(nch_minus_type / 2, c->c_arena);
- if (!targets)
- return NULL;
- for (i = 0; i < nch_minus_type - 2; i += 2) {
- expr_ty e;
- node *ch = CHILD(n, i);
- if (TYPE(ch) == yield_expr) {
- ast_error(c, ch, "assignment to yield expression not possible");
- return NULL;
- }
- e = ast_for_testlist(c, ch);
- if (!e)
- return NULL;
-
- /* set context to assign */
- if (!set_context(c, e, Store, CHILD(n, i)))
- return NULL;
-
- asdl_seq_SET(targets, i / 2, e);
- }
- value = CHILD(n, nch_minus_type - 1);
- if (TYPE(value) == testlist_star_expr)
- expression = ast_for_testlist(c, value);
- else
- expression = ast_for_expr(c, value);
- if (!expression)
- return NULL;
- if (has_type_comment) {
- type_comment = NEW_TYPE_COMMENT(CHILD(n, nch_minus_type));
- if (!type_comment)
- return NULL;
- }
- else
- type_comment = NULL;
- return Assign(targets, expression, type_comment, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
-}
-
-
-static asdl_seq *
-ast_for_exprlist(struct compiling *c, const node *n, expr_context_ty context)
-{
- asdl_seq *seq;
- int i;
- expr_ty e;
-
- REQ(n, exprlist);
-
- seq = _Py_asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
- if (!seq)
- return NULL;
- for (i = 0; i < NCH(n); i += 2) {
- e = ast_for_expr(c, CHILD(n, i));
- if (!e)
- return NULL;
- asdl_seq_SET(seq, i / 2, e);
- if (context && !set_context(c, e, context, CHILD(n, i)))
- return NULL;
- }
- return seq;
-}
-
-static stmt_ty
-ast_for_del_stmt(struct compiling *c, const node *n)
-{
- asdl_seq *expr_list;
-
- /* del_stmt: 'del' exprlist */
- REQ(n, del_stmt);
-
- expr_list = ast_for_exprlist(c, CHILD(n, 1), Del);
- if (!expr_list)
- return NULL;
- return Delete(expr_list, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static stmt_ty
-ast_for_flow_stmt(struct compiling *c, const node *n)
-{
- /*
- flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt
- | yield_stmt
- break_stmt: 'break'
- continue_stmt: 'continue'
- return_stmt: 'return' [testlist]
- yield_stmt: yield_expr
- yield_expr: 'yield' testlist | 'yield' 'from' test
- raise_stmt: 'raise' [test [',' test [',' test]]]
- */
- node *ch;
-
- REQ(n, flow_stmt);
- ch = CHILD(n, 0);
- switch (TYPE(ch)) {
- case break_stmt:
- return Break(LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- case continue_stmt:
- return Continue(LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- case yield_stmt: { /* will reduce to yield_expr */
- expr_ty exp = ast_for_expr(c, CHILD(ch, 0));
- if (!exp)
- return NULL;
- return Expr(exp, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- case return_stmt:
- if (NCH(ch) == 1)
- return Return(NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- else {
- expr_ty expression = ast_for_testlist(c, CHILD(ch, 1));
- if (!expression)
- return NULL;
- return Return(expression, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- case raise_stmt:
- if (NCH(ch) == 1)
- return Raise(NULL, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- else if (NCH(ch) >= 2) {
- expr_ty cause = NULL;
- expr_ty expression = ast_for_expr(c, CHILD(ch, 1));
- if (!expression)
- return NULL;
- if (NCH(ch) == 4) {
- cause = ast_for_expr(c, CHILD(ch, 3));
- if (!cause)
- return NULL;
- }
- return Raise(expression, cause, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- /* fall through */
- default:
- PyErr_Format(PyExc_SystemError,
- "unexpected flow_stmt: %d", TYPE(ch));
- return NULL;
- }
-}
-
-static alias_ty
-alias_for_import_name(struct compiling *c, const node *n, int store)
-{
- /*
- import_as_name: NAME ['as' NAME]
- dotted_as_name: dotted_name ['as' NAME]
- dotted_name: NAME ('.' NAME)*
- */
- identifier str, name;
-
- loop:
- switch (TYPE(n)) {
- case import_as_name: {
- node *name_node = CHILD(n, 0);
- str = NULL;
- name = NEW_IDENTIFIER(name_node);
- if (!name)
- return NULL;
- if (NCH(n) == 3) {
- node *str_node = CHILD(n, 2);
- str = NEW_IDENTIFIER(str_node);
- if (!str)
- return NULL;
- if (store && forbidden_name(c, str, str_node, 0))
- return NULL;
- }
- else {
- if (forbidden_name(c, name, name_node, 0))
- return NULL;
- }
- return alias(name, str, c->c_arena);
- }
- case dotted_as_name:
- if (NCH(n) == 1) {
- n = CHILD(n, 0);
- goto loop;
- }
- else {
- node *asname_node = CHILD(n, 2);
- alias_ty a = alias_for_import_name(c, CHILD(n, 0), 0);
- if (!a)
- return NULL;
- assert(!a->asname);
- a->asname = NEW_IDENTIFIER(asname_node);
- if (!a->asname)
- return NULL;
- if (forbidden_name(c, a->asname, asname_node, 0))
- return NULL;
- return a;
- }
- case dotted_name:
- if (NCH(n) == 1) {
- node *name_node = CHILD(n, 0);
- name = NEW_IDENTIFIER(name_node);
- if (!name)
- return NULL;
- if (store && forbidden_name(c, name, name_node, 0))
- return NULL;
- return alias(name, NULL, c->c_arena);
- }
- else {
- /* Create a string of the form "a.b.c" */
- int i;
- size_t len;
- char *s;
- PyObject *uni;
-
- len = 0;
- for (i = 0; i < NCH(n); i += 2)
- /* length of string plus one for the dot */
- len += strlen(STR(CHILD(n, i))) + 1;
- len--; /* the last name doesn't have a dot */
- str = PyBytes_FromStringAndSize(NULL, len);
- if (!str)
- return NULL;
- s = PyBytes_AS_STRING(str);
- if (!s)
- return NULL;
- for (i = 0; i < NCH(n); i += 2) {
- char *sch = STR(CHILD(n, i));
- strcpy(s, STR(CHILD(n, i)));
- s += strlen(sch);
- *s++ = '.';
- }
- --s;
- *s = '\0';
- uni = PyUnicode_DecodeUTF8(PyBytes_AS_STRING(str),
- PyBytes_GET_SIZE(str),
- NULL);
- Py_DECREF(str);
- if (!uni)
- return NULL;
- str = uni;
- PyUnicode_InternInPlace(&str);
- if (PyArena_AddPyObject(c->c_arena, str) < 0) {
- Py_DECREF(str);
- return NULL;
- }
- return alias(str, NULL, c->c_arena);
- }
- case STAR:
- str = PyUnicode_InternFromString("*");
- if (!str)
- return NULL;
- if (PyArena_AddPyObject(c->c_arena, str) < 0) {
- Py_DECREF(str);
- return NULL;
- }
- return alias(str, NULL, c->c_arena);
- default:
- PyErr_Format(PyExc_SystemError,
- "unexpected import name: %d", TYPE(n));
- return NULL;
- }
-}
-
-static stmt_ty
-ast_for_import_stmt(struct compiling *c, const node *n)
-{
- /*
- import_stmt: import_name | import_from
- import_name: 'import' dotted_as_names
- import_from: 'from' (('.' | '...')* dotted_name | ('.' | '...')+)
- 'import' ('*' | '(' import_as_names ')' | import_as_names)
- */
- int lineno;
- int col_offset;
- int i;
- asdl_seq *aliases;
-
- REQ(n, import_stmt);
- lineno = LINENO(n);
- col_offset = n->n_col_offset;
- n = CHILD(n, 0);
- if (TYPE(n) == import_name) {
- n = CHILD(n, 1);
- REQ(n, dotted_as_names);
- aliases = _Py_asdl_seq_new((NCH(n) + 1) / 2, c->c_arena);
- if (!aliases)
- return NULL;
- for (i = 0; i < NCH(n); i += 2) {
- alias_ty import_alias = alias_for_import_name(c, CHILD(n, i), 1);
- if (!import_alias)
- return NULL;
- asdl_seq_SET(aliases, i / 2, import_alias);
- }
- // Even though n is modified above, the end position is not changed
- return Import(aliases, lineno, col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else if (TYPE(n) == import_from) {
- int n_children;
- int idx, ndots = 0;
- const node *n_copy = n;
- alias_ty mod = NULL;
- identifier modname = NULL;
-
- /* Count the number of dots (for relative imports) and check for the
- optional module name */
- for (idx = 1; idx < NCH(n); idx++) {
- if (TYPE(CHILD(n, idx)) == dotted_name) {
- mod = alias_for_import_name(c, CHILD(n, idx), 0);
- if (!mod)
- return NULL;
- idx++;
- break;
- } else if (TYPE(CHILD(n, idx)) == ELLIPSIS) {
- /* three consecutive dots are tokenized as one ELLIPSIS */
- ndots += 3;
- continue;
- } else if (TYPE(CHILD(n, idx)) != DOT) {
- break;
- }
- ndots++;
- }
- idx++; /* skip over the 'import' keyword */
- switch (TYPE(CHILD(n, idx))) {
- case STAR:
- /* from ... import * */
- n = CHILD(n, idx);
- n_children = 1;
- break;
- case LPAR:
- /* from ... import (x, y, z) */
- n = CHILD(n, idx + 1);
- n_children = NCH(n);
- break;
- case import_as_names:
- /* from ... import x, y, z */
- n = CHILD(n, idx);
- n_children = NCH(n);
- if (n_children % 2 == 0) {
- ast_error(c, n,
- "trailing comma not allowed without"
- " surrounding parentheses");
- return NULL;
- }
- break;
- default:
- ast_error(c, n, "Unexpected node-type in from-import");
- return NULL;
- }
-
- aliases = _Py_asdl_seq_new((n_children + 1) / 2, c->c_arena);
- if (!aliases)
- return NULL;
-
- /* handle "from ... import *" special b/c there's no children */
- if (TYPE(n) == STAR) {
- alias_ty import_alias = alias_for_import_name(c, n, 1);
- if (!import_alias)
- return NULL;
- asdl_seq_SET(aliases, 0, import_alias);
- }
- else {
- for (i = 0; i < NCH(n); i += 2) {
- alias_ty import_alias = alias_for_import_name(c, CHILD(n, i), 1);
- if (!import_alias)
- return NULL;
- asdl_seq_SET(aliases, i / 2, import_alias);
- }
- }
- if (mod != NULL)
- modname = mod->name;
- return ImportFrom(modname, aliases, ndots, lineno, col_offset,
- n_copy->n_end_lineno, n_copy->n_end_col_offset,
- c->c_arena);
- }
- PyErr_Format(PyExc_SystemError,
- "unknown import statement: starts with command '%s'",
- STR(CHILD(n, 0)));
- return NULL;
-}
-
-static stmt_ty
-ast_for_global_stmt(struct compiling *c, const node *n)
-{
- /* global_stmt: 'global' NAME (',' NAME)* */
- identifier name;
- asdl_seq *s;
- int i;
-
- REQ(n, global_stmt);
- s = _Py_asdl_seq_new(NCH(n) / 2, c->c_arena);
- if (!s)
- return NULL;
- for (i = 1; i < NCH(n); i += 2) {
- name = NEW_IDENTIFIER(CHILD(n, i));
- if (!name)
- return NULL;
- asdl_seq_SET(s, i / 2, name);
- }
- return Global(s, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static stmt_ty
-ast_for_nonlocal_stmt(struct compiling *c, const node *n)
-{
- /* nonlocal_stmt: 'nonlocal' NAME (',' NAME)* */
- identifier name;
- asdl_seq *s;
- int i;
-
- REQ(n, nonlocal_stmt);
- s = _Py_asdl_seq_new(NCH(n) / 2, c->c_arena);
- if (!s)
- return NULL;
- for (i = 1; i < NCH(n); i += 2) {
- name = NEW_IDENTIFIER(CHILD(n, i));
- if (!name)
- return NULL;
- asdl_seq_SET(s, i / 2, name);
- }
- return Nonlocal(s, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-static stmt_ty
-ast_for_assert_stmt(struct compiling *c, const node *n)
-{
- /* assert_stmt: 'assert' test [',' test] */
- REQ(n, assert_stmt);
- if (NCH(n) == 2) {
- expr_ty expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
- return Assert(expression, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- else if (NCH(n) == 4) {
- expr_ty expr1, expr2;
-
- expr1 = ast_for_expr(c, CHILD(n, 1));
- if (!expr1)
- return NULL;
- expr2 = ast_for_expr(c, CHILD(n, 3));
- if (!expr2)
- return NULL;
-
- return Assert(expr1, expr2, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
- PyErr_Format(PyExc_SystemError,
- "improper number of parts to 'assert' statement: %d",
- NCH(n));
- return NULL;
-}
-
-static asdl_seq *
-ast_for_suite(struct compiling *c, const node *n)
-{
- /* suite: simple_stmt | NEWLINE [TYPE_COMMENT NEWLINE] INDENT stmt+ DEDENT */
- asdl_seq *seq;
- stmt_ty s;
- int i, total, num, end, pos = 0;
- node *ch;
-
- if (TYPE(n) != func_body_suite) {
- REQ(n, suite);
- }
-
- total = num_stmts(n);
- seq = _Py_asdl_seq_new(total, c->c_arena);
- if (!seq)
- return NULL;
- if (TYPE(CHILD(n, 0)) == simple_stmt) {
- n = CHILD(n, 0);
- /* simple_stmt always ends with a NEWLINE,
- and may have a trailing SEMI
- */
- end = NCH(n) - 1;
- if (TYPE(CHILD(n, end - 1)) == SEMI)
- end--;
- /* loop by 2 to skip semi-colons */
- for (i = 0; i < end; i += 2) {
- ch = CHILD(n, i);
- s = ast_for_stmt(c, ch);
- if (!s)
- return NULL;
- asdl_seq_SET(seq, pos++, s);
- }
- }
- else {
- i = 2;
- if (TYPE(CHILD(n, 1)) == TYPE_COMMENT) {
- i += 2;
- REQ(CHILD(n, 2), NEWLINE);
- }
-
- for (; i < (NCH(n) - 1); i++) {
- ch = CHILD(n, i);
- REQ(ch, stmt);
- num = num_stmts(ch);
- if (num == 1) {
- /* small_stmt or compound_stmt with only one child */
- s = ast_for_stmt(c, ch);
- if (!s)
- return NULL;
- asdl_seq_SET(seq, pos++, s);
- }
- else {
- int j;
- ch = CHILD(ch, 0);
- REQ(ch, simple_stmt);
- for (j = 0; j < NCH(ch); j += 2) {
- /* statement terminates with a semi-colon ';' */
- if (NCH(CHILD(ch, j)) == 0) {
- assert((j + 1) == NCH(ch));
- break;
- }
- s = ast_for_stmt(c, CHILD(ch, j));
- if (!s)
- return NULL;
- asdl_seq_SET(seq, pos++, s);
- }
- }
- }
- }
- assert(pos == seq->size);
- return seq;
-}
-
-static void
-get_last_end_pos(asdl_seq *s, int *end_lineno, int *end_col_offset)
-{
- Py_ssize_t tot = asdl_seq_LEN(s);
- // There must be no empty suites.
- assert(tot > 0);
- stmt_ty last = asdl_seq_GET(s, tot - 1);
- *end_lineno = last->end_lineno;
- *end_col_offset = last->end_col_offset;
-}
-
-static stmt_ty
-ast_for_if_stmt(struct compiling *c, const node *n)
-{
- /* if_stmt: 'if' test ':' suite ('elif' test ':' suite)*
- ['else' ':' suite]
- */
- char *s;
- int end_lineno, end_col_offset;
-
- REQ(n, if_stmt);
-
- if (NCH(n) == 4) {
- expr_ty expression;
- asdl_seq *suite_seq;
-
- expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, CHILD(n, 3));
- if (!suite_seq)
- return NULL;
- get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
-
- return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
-
- s = STR(CHILD(n, 4));
- /* s[2], the third character in the string, will be
- 's' for el_s_e, or
- 'i' for el_i_f
- */
- if (s[2] == 's') {
- expr_ty expression;
- asdl_seq *seq1, *seq2;
-
- expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
- seq1 = ast_for_suite(c, CHILD(n, 3));
- if (!seq1)
- return NULL;
- seq2 = ast_for_suite(c, CHILD(n, 6));
- if (!seq2)
- return NULL;
- get_last_end_pos(seq2, &end_lineno, &end_col_offset);
-
- return If(expression, seq1, seq2, LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
- else if (s[2] == 'i') {
- int i, n_elif, has_else = 0;
- expr_ty expression;
- asdl_seq *suite_seq;
- asdl_seq *orelse = NULL;
- n_elif = NCH(n) - 4;
- /* must reference the child n_elif+1 since 'else' token is third,
- not fourth, child from the end. */
- if (TYPE(CHILD(n, (n_elif + 1))) == NAME
- && STR(CHILD(n, (n_elif + 1)))[2] == 's') {
- has_else = 1;
- n_elif -= 3;
- }
- n_elif /= 4;
-
- if (has_else) {
- asdl_seq *suite_seq2;
-
- orelse = _Py_asdl_seq_new(1, c->c_arena);
- if (!orelse)
- return NULL;
- expression = ast_for_expr(c, CHILD(n, NCH(n) - 6));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, CHILD(n, NCH(n) - 4));
- if (!suite_seq)
- return NULL;
- suite_seq2 = ast_for_suite(c, CHILD(n, NCH(n) - 1));
- if (!suite_seq2)
- return NULL;
- get_last_end_pos(suite_seq2, &end_lineno, &end_col_offset);
-
- asdl_seq_SET(orelse, 0,
- If(expression, suite_seq, suite_seq2,
- LINENO(CHILD(n, NCH(n) - 7)),
- CHILD(n, NCH(n) - 7)->n_col_offset,
- end_lineno, end_col_offset, c->c_arena));
- /* the just-created orelse handled the last elif */
- n_elif--;
- }
-
- for (i = 0; i < n_elif; i++) {
- int off = 5 + (n_elif - i - 1) * 4;
- asdl_seq *newobj = _Py_asdl_seq_new(1, c->c_arena);
- if (!newobj)
- return NULL;
- expression = ast_for_expr(c, CHILD(n, off));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, CHILD(n, off + 2));
- if (!suite_seq)
- return NULL;
-
- if (orelse != NULL) {
- get_last_end_pos(orelse, &end_lineno, &end_col_offset);
- } else {
- get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
- }
- asdl_seq_SET(newobj, 0,
- If(expression, suite_seq, orelse,
- LINENO(CHILD(n, off - 1)),
- CHILD(n, off - 1)->n_col_offset,
- end_lineno, end_col_offset, c->c_arena));
- orelse = newobj;
- }
- expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, CHILD(n, 3));
- if (!suite_seq)
- return NULL;
- get_last_end_pos(orelse, &end_lineno, &end_col_offset);
- return If(expression, suite_seq, orelse,
- LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
-
- PyErr_Format(PyExc_SystemError,
- "unexpected token in 'if' statement: %s", s);
- return NULL;
-}
-
-static stmt_ty
-ast_for_while_stmt(struct compiling *c, const node *n)
-{
- /* while_stmt: 'while' test ':' suite ['else' ':' suite] */
- REQ(n, while_stmt);
- int end_lineno, end_col_offset;
-
- if (NCH(n) == 4) {
- expr_ty expression;
- asdl_seq *suite_seq;
-
- expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, CHILD(n, 3));
- if (!suite_seq)
- return NULL;
- get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
- return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
- else if (NCH(n) == 7) {
- expr_ty expression;
- asdl_seq *seq1, *seq2;
-
- expression = ast_for_expr(c, CHILD(n, 1));
- if (!expression)
- return NULL;
- seq1 = ast_for_suite(c, CHILD(n, 3));
- if (!seq1)
- return NULL;
- seq2 = ast_for_suite(c, CHILD(n, 6));
- if (!seq2)
- return NULL;
- get_last_end_pos(seq2, &end_lineno, &end_col_offset);
-
- return While(expression, seq1, seq2, LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
-
- PyErr_Format(PyExc_SystemError,
- "wrong number of tokens for 'while' statement: %d",
- NCH(n));
- return NULL;
-}
-
-static stmt_ty
-ast_for_for_stmt(struct compiling *c, const node *n0, bool is_async)
-{
- const node * const n = is_async ? CHILD(n0, 1) : n0;
- asdl_seq *_target, *seq = NULL, *suite_seq;
- expr_ty expression;
- expr_ty target, first;
- const node *node_target;
- int end_lineno, end_col_offset;
- int has_type_comment;
- string type_comment;
-
- if (is_async && c->c_feature_version < 5) {
- ast_error(c, n,
- "Async for loops are only supported in Python 3.5 and greater");
- return NULL;
- }
-
- /* for_stmt: 'for' exprlist 'in' testlist ':' [TYPE_COMMENT] suite ['else' ':' suite] */
- REQ(n, for_stmt);
-
- has_type_comment = TYPE(CHILD(n, 5)) == TYPE_COMMENT;
-
- if (NCH(n) == 9 + has_type_comment) {
- seq = ast_for_suite(c, CHILD(n, 8 + has_type_comment));
- if (!seq)
- return NULL;
- }
-
- node_target = CHILD(n, 1);
- _target = ast_for_exprlist(c, node_target, Store);
- if (!_target)
- return NULL;
- /* Check the # of children rather than the length of _target, since
- for x, in ... has 1 element in _target, but still requires a Tuple. */
- first = (expr_ty)asdl_seq_GET(_target, 0);
- if (NCH(node_target) == 1)
- target = first;
- else
- target = Tuple(_target, Store, first->lineno, first->col_offset,
- node_target->n_end_lineno, node_target->n_end_col_offset,
- c->c_arena);
-
- expression = ast_for_testlist(c, CHILD(n, 3));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, CHILD(n, 5 + has_type_comment));
- if (!suite_seq)
- return NULL;
-
- if (seq != NULL) {
- get_last_end_pos(seq, &end_lineno, &end_col_offset);
- } else {
- get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
- }
-
- if (has_type_comment) {
- type_comment = NEW_TYPE_COMMENT(CHILD(n, 5));
- if (!type_comment)
- return NULL;
- }
- else
- type_comment = NULL;
-
- if (is_async)
- return AsyncFor(target, expression, suite_seq, seq, type_comment,
- LINENO(n0), n0->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- else
- return For(target, expression, suite_seq, seq, type_comment,
- LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
-}
-
-static excepthandler_ty
-ast_for_except_clause(struct compiling *c, const node *exc, node *body)
-{
- /* except_clause: 'except' [test ['as' test]] */
- int end_lineno, end_col_offset;
- REQ(exc, except_clause);
- REQ(body, suite);
-
- if (NCH(exc) == 1) {
- asdl_seq *suite_seq = ast_for_suite(c, body);
- if (!suite_seq)
- return NULL;
- get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
-
- return ExceptHandler(NULL, NULL, suite_seq, LINENO(exc),
- exc->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
- else if (NCH(exc) == 2) {
- expr_ty expression;
- asdl_seq *suite_seq;
-
- expression = ast_for_expr(c, CHILD(exc, 1));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, body);
- if (!suite_seq)
- return NULL;
- get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
-
- return ExceptHandler(expression, NULL, suite_seq, LINENO(exc),
- exc->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
- else if (NCH(exc) == 4) {
- asdl_seq *suite_seq;
- expr_ty expression;
- identifier e = NEW_IDENTIFIER(CHILD(exc, 3));
- if (!e)
- return NULL;
- if (forbidden_name(c, e, CHILD(exc, 3), 0))
- return NULL;
- expression = ast_for_expr(c, CHILD(exc, 1));
- if (!expression)
- return NULL;
- suite_seq = ast_for_suite(c, body);
- if (!suite_seq)
- return NULL;
- get_last_end_pos(suite_seq, &end_lineno, &end_col_offset);
-
- return ExceptHandler(expression, e, suite_seq, LINENO(exc),
- exc->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
-
- PyErr_Format(PyExc_SystemError,
- "wrong number of children for 'except' clause: %d",
- NCH(exc));
- return NULL;
-}
-
-static stmt_ty
-ast_for_try_stmt(struct compiling *c, const node *n)
-{
- const int nch = NCH(n);
- int end_lineno, end_col_offset, n_except = (nch - 3)/3;
- asdl_seq *body, *handlers = NULL, *orelse = NULL, *finally = NULL;
- excepthandler_ty last_handler;
-
- REQ(n, try_stmt);
-
- body = ast_for_suite(c, CHILD(n, 2));
- if (body == NULL)
- return NULL;
-
- if (TYPE(CHILD(n, nch - 3)) == NAME) {
- if (strcmp(STR(CHILD(n, nch - 3)), "finally") == 0) {
- if (nch >= 9 && TYPE(CHILD(n, nch - 6)) == NAME) {
- /* we can assume it's an "else",
- because nch >= 9 for try-else-finally and
- it would otherwise have a type of except_clause */
- orelse = ast_for_suite(c, CHILD(n, nch - 4));
- if (orelse == NULL)
- return NULL;
- n_except--;
- }
-
- finally = ast_for_suite(c, CHILD(n, nch - 1));
- if (finally == NULL)
- return NULL;
- n_except--;
- }
- else {
- /* we can assume it's an "else",
- otherwise it would have a type of except_clause */
- orelse = ast_for_suite(c, CHILD(n, nch - 1));
- if (orelse == NULL)
- return NULL;
- n_except--;
- }
- }
- else if (TYPE(CHILD(n, nch - 3)) != except_clause) {
- ast_error(c, n, "malformed 'try' statement");
- return NULL;
- }
-
- if (n_except > 0) {
- int i;
- /* process except statements to create a try ... except */
- handlers = _Py_asdl_seq_new(n_except, c->c_arena);
- if (handlers == NULL)
- return NULL;
-
- for (i = 0; i < n_except; i++) {
- excepthandler_ty e = ast_for_except_clause(c, CHILD(n, 3 + i * 3),
- CHILD(n, 5 + i * 3));
- if (!e)
- return NULL;
- asdl_seq_SET(handlers, i, e);
- }
- }
-
- assert(finally != NULL || asdl_seq_LEN(handlers));
- if (finally != NULL) {
- // finally is always last
- get_last_end_pos(finally, &end_lineno, &end_col_offset);
- } else if (orelse != NULL) {
- // otherwise else is last
- get_last_end_pos(orelse, &end_lineno, &end_col_offset);
- } else {
- // inline the get_last_end_pos logic due to layout mismatch
- last_handler = (excepthandler_ty) asdl_seq_GET(handlers, n_except - 1);
- end_lineno = last_handler->end_lineno;
- end_col_offset = last_handler->end_col_offset;
- }
- return Try(body, handlers, orelse, finally, LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
-}
-
-/* with_item: test ['as' expr] */
-static withitem_ty
-ast_for_with_item(struct compiling *c, const node *n)
-{
- expr_ty context_expr, optional_vars = NULL;
-
- REQ(n, with_item);
- context_expr = ast_for_expr(c, CHILD(n, 0));
- if (!context_expr)
- return NULL;
- if (NCH(n) == 3) {
- optional_vars = ast_for_expr(c, CHILD(n, 2));
-
- if (!optional_vars) {
- return NULL;
- }
- if (!set_context(c, optional_vars, Store, n)) {
- return NULL;
- }
- }
-
- return withitem(context_expr, optional_vars, c->c_arena);
-}
-
-/* with_stmt: 'with' with_item (',' with_item)* ':' [TYPE_COMMENT] suite */
-static stmt_ty
-ast_for_with_stmt(struct compiling *c, const node *n0, bool is_async)
-{
- const node * const n = is_async ? CHILD(n0, 1) : n0;
- int i, n_items, nch_minus_type, has_type_comment, end_lineno, end_col_offset;
- asdl_seq *items, *body;
- string type_comment;
-
- if (is_async && c->c_feature_version < 5) {
- ast_error(c, n,
- "Async with statements are only supported in Python 3.5 and greater");
- return NULL;
- }
-
- REQ(n, with_stmt);
-
- has_type_comment = TYPE(CHILD(n, NCH(n) - 2)) == TYPE_COMMENT;
- nch_minus_type = NCH(n) - has_type_comment;
-
- n_items = (nch_minus_type - 2) / 2;
- items = _Py_asdl_seq_new(n_items, c->c_arena);
- if (!items)
- return NULL;
- for (i = 1; i < nch_minus_type - 2; i += 2) {
- withitem_ty item = ast_for_with_item(c, CHILD(n, i));
- if (!item)
- return NULL;
- asdl_seq_SET(items, (i - 1) / 2, item);
- }
-
- body = ast_for_suite(c, CHILD(n, NCH(n) - 1));
- if (!body)
- return NULL;
- get_last_end_pos(body, &end_lineno, &end_col_offset);
-
- if (has_type_comment) {
- type_comment = NEW_TYPE_COMMENT(CHILD(n, NCH(n) - 2));
- if (!type_comment)
- return NULL;
- }
- else
- type_comment = NULL;
-
- if (is_async)
- return AsyncWith(items, body, type_comment, LINENO(n0), n0->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- else
- return With(items, body, type_comment, LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
-}
-
-static stmt_ty
-ast_for_classdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)
-{
- /* classdef: 'class' NAME ['(' arglist ')'] ':' suite */
- PyObject *classname;
- asdl_seq *s;
- expr_ty call;
- int end_lineno, end_col_offset;
-
- REQ(n, classdef);
-
- if (NCH(n) == 4) { /* class NAME ':' suite */
- s = ast_for_suite(c, CHILD(n, 3));
- if (!s)
- return NULL;
- get_last_end_pos(s, &end_lineno, &end_col_offset);
-
- classname = NEW_IDENTIFIER(CHILD(n, 1));
- if (!classname)
- return NULL;
- if (forbidden_name(c, classname, CHILD(n, 3), 0))
- return NULL;
- return ClassDef(classname, NULL, NULL, s, decorator_seq,
- LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
-
- if (TYPE(CHILD(n, 3)) == RPAR) { /* class NAME '(' ')' ':' suite */
- s = ast_for_suite(c, CHILD(n, 5));
- if (!s)
- return NULL;
- get_last_end_pos(s, &end_lineno, &end_col_offset);
-
- classname = NEW_IDENTIFIER(CHILD(n, 1));
- if (!classname)
- return NULL;
- if (forbidden_name(c, classname, CHILD(n, 3), 0))
- return NULL;
- return ClassDef(classname, NULL, NULL, s, decorator_seq,
- LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
- }
-
- /* class NAME '(' arglist ')' ':' suite */
- /* build up a fake Call node so we can extract its pieces */
- {
- PyObject *dummy_name;
- expr_ty dummy;
- dummy_name = NEW_IDENTIFIER(CHILD(n, 1));
- if (!dummy_name)
- return NULL;
- dummy = Name(dummy_name, Load, LINENO(n), n->n_col_offset,
- CHILD(n, 1)->n_end_lineno, CHILD(n, 1)->n_end_col_offset,
- c->c_arena);
- call = ast_for_call(c, CHILD(n, 3), dummy,
- CHILD(n, 1), NULL, CHILD(n, 4));
- if (!call)
- return NULL;
- }
- s = ast_for_suite(c, CHILD(n, 6));
- if (!s)
- return NULL;
- get_last_end_pos(s, &end_lineno, &end_col_offset);
-
- classname = NEW_IDENTIFIER(CHILD(n, 1));
- if (!classname)
- return NULL;
- if (forbidden_name(c, classname, CHILD(n, 1), 0))
- return NULL;
-
- return ClassDef(classname, call->v.Call.args, call->v.Call.keywords, s,
- decorator_seq, LINENO(n), n->n_col_offset,
- end_lineno, end_col_offset, c->c_arena);
-}
-
-static stmt_ty
-ast_for_stmt(struct compiling *c, const node *n)
-{
- if (TYPE(n) == stmt) {
- assert(NCH(n) == 1);
- n = CHILD(n, 0);
- }
- if (TYPE(n) == simple_stmt) {
- assert(num_stmts(n) == 1);
- n = CHILD(n, 0);
- }
- if (TYPE(n) == small_stmt) {
- n = CHILD(n, 0);
- /* small_stmt: expr_stmt | del_stmt | pass_stmt | flow_stmt
- | import_stmt | global_stmt | nonlocal_stmt | assert_stmt
- */
- switch (TYPE(n)) {
- case expr_stmt:
- return ast_for_expr_stmt(c, n);
- case del_stmt:
- return ast_for_del_stmt(c, n);
- case pass_stmt:
- return Pass(LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- case flow_stmt:
- return ast_for_flow_stmt(c, n);
- case import_stmt:
- return ast_for_import_stmt(c, n);
- case global_stmt:
- return ast_for_global_stmt(c, n);
- case nonlocal_stmt:
- return ast_for_nonlocal_stmt(c, n);
- case assert_stmt:
- return ast_for_assert_stmt(c, n);
- default:
- PyErr_Format(PyExc_SystemError,
- "unhandled small_stmt: TYPE=%d NCH=%d\n",
- TYPE(n), NCH(n));
- return NULL;
- }
- }
- else {
- /* compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt
- | funcdef | classdef | decorated | async_stmt
- */
- node *ch = CHILD(n, 0);
- REQ(n, compound_stmt);
- switch (TYPE(ch)) {
- case if_stmt:
- return ast_for_if_stmt(c, ch);
- case while_stmt:
- return ast_for_while_stmt(c, ch);
- case for_stmt:
- return ast_for_for_stmt(c, ch, 0);
- case try_stmt:
- return ast_for_try_stmt(c, ch);
- case with_stmt:
- return ast_for_with_stmt(c, ch, 0);
- case funcdef:
- return ast_for_funcdef(c, ch, NULL);
- case classdef:
- return ast_for_classdef(c, ch, NULL);
- case decorated:
- return ast_for_decorated(c, ch);
- case async_stmt:
- return ast_for_async_stmt(c, ch);
- default:
- PyErr_Format(PyExc_SystemError,
- "unhandled compound_stmt: TYPE=%d NCH=%d\n",
- TYPE(n), NCH(n));
- return NULL;
- }
- }
-}
-
-static PyObject *
-parsenumber_raw(struct compiling *c, const char *s)
-{
- const char *end;
- long x;
- double dx;
- Py_complex compl;
- int imflag;
-
- assert(s != NULL);
- errno = 0;
- end = s + strlen(s) - 1;
- imflag = *end == 'j' || *end == 'J';
- if (s[0] == '0') {
- x = (long) PyOS_strtoul(s, (char **)&end, 0);
- if (x < 0 && errno == 0) {
- return PyLong_FromString(s, (char **)0, 0);
- }
- }
- else
- x = PyOS_strtol(s, (char **)&end, 0);
- if (*end == '\0') {
- if (errno != 0)
- return PyLong_FromString(s, (char **)0, 0);
- return PyLong_FromLong(x);
- }
- /* XXX Huge floats may silently fail */
- if (imflag) {
- compl.real = 0.;
- compl.imag = PyOS_string_to_double(s, (char **)&end, NULL);
- if (compl.imag == -1.0 && PyErr_Occurred())
- return NULL;
- return PyComplex_FromCComplex(compl);
- }
- else
- {
- dx = PyOS_string_to_double(s, NULL, NULL);
- if (dx == -1.0 && PyErr_Occurred())
- return NULL;
- return PyFloat_FromDouble(dx);
- }
-}
-
-static PyObject *
-parsenumber(struct compiling *c, const char *s)
-{
- char *dup, *end;
- PyObject *res = NULL;
-
- assert(s != NULL);
-
- if (strchr(s, '_') == NULL) {
- return parsenumber_raw(c, s);
- }
- /* Create a duplicate without underscores. */
- dup = PyMem_Malloc(strlen(s) + 1);
- if (dup == NULL) {
- return PyErr_NoMemory();
- }
- end = dup;
- for (; *s; s++) {
- if (*s != '_') {
- *end++ = *s;
- }
- }
- *end = '\0';
- res = parsenumber_raw(c, dup);
- PyMem_Free(dup);
- return res;
-}
-
-static PyObject *
-decode_utf8(struct compiling *c, const char **sPtr, const char *end)
-{
- const char *s, *t;
- t = s = *sPtr;
- /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */
- while (s < end && (*s & 0x80)) s++;
- *sPtr = s;
- return PyUnicode_DecodeUTF8(t, s - t, NULL);
-}
-
-static int
-warn_invalid_escape_sequence(struct compiling *c, const node *n,
- unsigned char first_invalid_escape_char)
-{
- PyObject *msg = PyUnicode_FromFormat("invalid escape sequence \\%c",
- first_invalid_escape_char);
- if (msg == NULL) {
- return -1;
- }
- if (PyErr_WarnExplicitObject(PyExc_DeprecationWarning, msg,
- c->c_filename, LINENO(n),
- NULL, NULL) < 0)
- {
- if (PyErr_ExceptionMatches(PyExc_DeprecationWarning)) {
- /* Replace the DeprecationWarning exception with a SyntaxError
- to get a more accurate error report */
- PyErr_Clear();
- ast_error(c, n, "%U", msg);
- }
- Py_DECREF(msg);
- return -1;
- }
- Py_DECREF(msg);
- return 0;
-}
-
-static PyObject *
-decode_unicode_with_escapes(struct compiling *c, const node *n, const char *s,
- size_t len)
-{
- PyObject *v, *u;
- char *buf;
- char *p;
- const char *end;
-
- /* check for integer overflow */
- if (len > SIZE_MAX / 6)
- return NULL;
- /* "ä" (2 bytes) may become "\U000000E4" (10 bytes), or 1:5
- "\ä" (3 bytes) may become "\u005c\U000000E4" (16 bytes), or ~1:6 */
- u = PyBytes_FromStringAndSize((char *)NULL, len * 6);
- if (u == NULL)
- return NULL;
- p = buf = PyBytes_AsString(u);
- end = s + len;
- while (s < end) {
- if (*s == '\\') {
- *p++ = *s++;
- if (s >= end || *s & 0x80) {
- strcpy(p, "u005c");
- p += 5;
- if (s >= end)
- break;
- }
- }
- if (*s & 0x80) { /* XXX inefficient */
- PyObject *w;
- int kind;
- const void *data;
- Py_ssize_t len, i;
- w = decode_utf8(c, &s, end);
- if (w == NULL) {
- Py_DECREF(u);
- return NULL;
- }
- kind = PyUnicode_KIND(w);
- data = PyUnicode_DATA(w);
- len = PyUnicode_GET_LENGTH(w);
- for (i = 0; i < len; i++) {
- Py_UCS4 chr = PyUnicode_READ(kind, data, i);
- sprintf(p, "\\U%08x", chr);
- p += 10;
- }
- /* Should be impossible to overflow */
- assert(p - buf <= PyBytes_GET_SIZE(u));
- Py_DECREF(w);
- } else {
- *p++ = *s++;
- }
- }
- len = p - buf;
- s = buf;
-
- const char *first_invalid_escape;
- v = _PyUnicode_DecodeUnicodeEscape(s, len, NULL, &first_invalid_escape);
-
- if (v != NULL && first_invalid_escape != NULL) {
- if (warn_invalid_escape_sequence(c, n, *first_invalid_escape) < 0) {
- /* We have not decref u before because first_invalid_escape points
- inside u. */
- Py_XDECREF(u);
- Py_DECREF(v);
- return NULL;
- }
- }
- Py_XDECREF(u);
- return v;
-}
-
-static PyObject *
-decode_bytes_with_escapes(struct compiling *c, const node *n, const char *s,
- size_t len)
-{
- const char *first_invalid_escape;
- PyObject *result = _PyBytes_DecodeEscape(s, len, NULL,
- &first_invalid_escape);
- if (result == NULL)
- return NULL;
-
- if (first_invalid_escape != NULL) {
- if (warn_invalid_escape_sequence(c, n, *first_invalid_escape) < 0) {
- Py_DECREF(result);
- return NULL;
- }
- }
- return result;
-}
-
-/* Shift locations for the given node and all its children by adding `lineno`
- and `col_offset` to existing locations. */
-static void fstring_shift_node_locations(node *n, int lineno, int col_offset)
-{
- n->n_col_offset = n->n_col_offset + col_offset;
- n->n_end_col_offset = n->n_end_col_offset + col_offset;
- for (int i = 0; i < NCH(n); ++i) {
- if (n->n_lineno && n->n_lineno < CHILD(n, i)->n_lineno) {
- /* Shifting column offsets unnecessary if there's been newlines. */
- col_offset = 0;
- }
- fstring_shift_node_locations(CHILD(n, i), lineno, col_offset);
- }
- n->n_lineno = n->n_lineno + lineno;
- n->n_end_lineno = n->n_end_lineno + lineno;
-}
-
-/* Fix locations for the given node and its children.
-
- `parent` is the enclosing node.
- `n` is the node which locations are going to be fixed relative to parent.
- `expr_str` is the child node's string representation, including braces.
-*/
-static void
-fstring_fix_node_location(const node *parent, node *n, char *expr_str)
-{
- char *substr = NULL;
- char *start;
- int lines = LINENO(parent) - 1;
- int cols = parent->n_col_offset;
- /* Find the full fstring to fix location information in `n`. */
- while (parent && parent->n_type != STRING)
- parent = parent->n_child;
- if (parent && parent->n_str) {
- substr = strstr(parent->n_str, expr_str);
- if (substr) {
- start = substr;
- while (start > parent->n_str) {
- if (start[0] == '\n')
- break;
- start--;
- }
- cols += (int)(substr - start);
- /* adjust the start based on the number of newlines encountered
- before the f-string expression */
- for (char* p = parent->n_str; p < substr; p++) {
- if (*p == '\n') {
- lines++;
- }
- }
- }
- }
- fstring_shift_node_locations(n, lines, cols);
-}
-
-/* Compile this expression in to an expr_ty. Add parens around the
- expression, in order to allow leading spaces in the expression. */
-static expr_ty
-fstring_compile_expr(const char *expr_start, const char *expr_end,
- struct compiling *c, const node *n)
-
-{
- node *mod_n;
- mod_ty mod;
- char *str;
- Py_ssize_t len;
- const char *s;
-
- assert(expr_end >= expr_start);
- assert(*(expr_start-1) == '{');
- assert(*expr_end == '}' || *expr_end == '!' || *expr_end == ':' ||
- *expr_end == '=');
-
- /* If the substring is all whitespace, it's an error. We need to catch this
- here, and not when we call PyParser_SimpleParseStringFlagsFilename,
- because turning the expression '' in to '()' would go from being invalid
- to valid. */
- for (s = expr_start; s != expr_end; s++) {
- char c = *s;
- /* The Python parser ignores only the following whitespace
- characters (\r already is converted to \n). */
- if (!(c == ' ' || c == '\t' || c == '\n' || c == '\f')) {
- break;
- }
- }
- if (s == expr_end) {
- ast_error(c, n, "f-string: empty expression not allowed");
- return NULL;
- }
-
- len = expr_end - expr_start;
- /* Allocate 3 extra bytes: open paren, close paren, null byte. */
- str = PyMem_RawMalloc(len + 3);
- if (str == NULL) {
- PyErr_NoMemory();
- return NULL;
- }
-
- str[0] = '(';
- memcpy(str+1, expr_start, len);
- str[len+1] = ')';
- str[len+2] = 0;
-
- PyCompilerFlags cf = _PyCompilerFlags_INIT;
- cf.cf_flags = PyCF_ONLY_AST;
- mod_n = PyParser_SimpleParseStringFlagsFilename(str, "<fstring>",
- Py_eval_input, 0);
- if (!mod_n) {
- PyMem_RawFree(str);
- return NULL;
- }
- /* Reuse str to find the correct column offset. */
- str[0] = '{';
- str[len+1] = '}';
- fstring_fix_node_location(n, mod_n, str);
- mod = PyAST_FromNode(mod_n, &cf, "<fstring>", c->c_arena);
- PyMem_RawFree(str);
- PyNode_Free(mod_n);
- if (!mod)
- return NULL;
- return mod->v.Expression.body;
-}
-
-/* Return -1 on error.
-
- Return 0 if we reached the end of the literal.
-
- Return 1 if we haven't reached the end of the literal, but we want
- the caller to process the literal up to this point. Used for
- doubled braces.
-*/
-static int
-fstring_find_literal(const char **str, const char *end, int raw,
- PyObject **literal, int recurse_lvl,
- struct compiling *c, const node *n)
-{
- /* Get any literal string. It ends when we hit an un-doubled left
- brace (which isn't part of a unicode name escape such as
- "\N{EULER CONSTANT}"), or the end of the string. */
-
- const char *s = *str;
- const char *literal_start = s;
- int result = 0;
-
- assert(*literal == NULL);
- while (s < end) {
- char ch = *s++;
- if (!raw && ch == '\\' && s < end) {
- ch = *s++;
- if (ch == 'N') {
- if (s < end && *s++ == '{') {
- while (s < end && *s++ != '}') {
- }
- continue;
- }
- break;
- }
- if (ch == '{' && warn_invalid_escape_sequence(c, n, ch) < 0) {
- return -1;
- }
- }
- if (ch == '{' || ch == '}') {
- /* Check for doubled braces, but only at the top level. If
- we checked at every level, then f'{0:{3}}' would fail
- with the two closing braces. */
- if (recurse_lvl == 0) {
- if (s < end && *s == ch) {
- /* We're going to tell the caller that the literal ends
- here, but that they should continue scanning. But also
- skip over the second brace when we resume scanning. */
- *str = s + 1;
- result = 1;
- goto done;
- }
-
- /* Where a single '{' is the start of a new expression, a
- single '}' is not allowed. */
- if (ch == '}') {
- *str = s - 1;
- ast_error(c, n, "f-string: single '}' is not allowed");
- return -1;
- }
- }
- /* We're either at a '{', which means we're starting another
- expression; or a '}', which means we're at the end of this
- f-string (for a nested format_spec). */
- s--;
- break;
- }
- }
- *str = s;
- assert(s <= end);
- assert(s == end || *s == '{' || *s == '}');
-done:
- if (literal_start != s) {
- if (raw)
- *literal = PyUnicode_DecodeUTF8Stateful(literal_start,
- s - literal_start,
- NULL, NULL);
- else
- *literal = decode_unicode_with_escapes(c, n, literal_start,
- s - literal_start);
- if (!*literal)
- return -1;
- }
- return result;
-}
-
-/* Forward declaration because parsing is recursive. */
-static expr_ty
-fstring_parse(const char **str, const char *end, int raw, int recurse_lvl,
- struct compiling *c, const node *n);
-
-/* Parse the f-string at *str, ending at end. We know *str starts an
- expression (so it must be a '{'). Returns the FormattedValue node, which
- includes the expression, conversion character, format_spec expression, and
- optionally the text of the expression (if = is used).
-
- Note that I don't do a perfect job here: I don't make sure that a
- closing brace doesn't match an opening paren, for example. It
- doesn't need to error on all invalid expressions, just correctly
- find the end of all valid ones. Any errors inside the expression
- will be caught when we parse it later.
-
- *expression is set to the expression. For an '=' "debug" expression,
- *expr_text is set to the debug text (the original text of the expression,
- including the '=' and any whitespace around it, as a string object). If
- not a debug expression, *expr_text set to NULL. */
-static int
-fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
- PyObject **expr_text, expr_ty *expression,
- struct compiling *c, const node *n)
-{
- /* Return -1 on error, else 0. */
-
- const char *expr_start;
- const char *expr_end;
- expr_ty simple_expression;
- expr_ty format_spec = NULL; /* Optional format specifier. */
- int conversion = -1; /* The conversion char. Use default if not
- specified, or !r if using = and no format
- spec. */
-
- /* 0 if we're not in a string, else the quote char we're trying to
- match (single or double quote). */
- char quote_char = 0;
-
- /* If we're inside a string, 1=normal, 3=triple-quoted. */
- int string_type = 0;
-
- /* Keep track of nesting level for braces/parens/brackets in
- expressions. */
- Py_ssize_t nested_depth = 0;
- char parenstack[MAXLEVEL];
-
- *expr_text = NULL;
-
- /* Can only nest one level deep. */
- if (recurse_lvl >= 2) {
- ast_error(c, n, "f-string: expressions nested too deeply");
- goto error;
- }
-
- /* The first char must be a left brace, or we wouldn't have gotten
- here. Skip over it. */
- assert(**str == '{');
- *str += 1;
-
- expr_start = *str;
- for (; *str < end; (*str)++) {
- char ch;
-
- /* Loop invariants. */
- assert(nested_depth >= 0);
- assert(*str >= expr_start && *str < end);
- if (quote_char)
- assert(string_type == 1 || string_type == 3);
- else
- assert(string_type == 0);
-
- ch = **str;
- /* Nowhere inside an expression is a backslash allowed. */
- if (ch == '\\') {
- /* Error: can't include a backslash character, inside
- parens or strings or not. */
- ast_error(c, n,
- "f-string expression part "
- "cannot include a backslash");
- goto error;
- }
- if (quote_char) {
- /* We're inside a string. See if we're at the end. */
- /* This code needs to implement the same non-error logic
- as tok_get from tokenizer.c, at the letter_quote
- label. To actually share that code would be a
- nightmare. But, it's unlikely to change and is small,
- so duplicate it here. Note we don't need to catch all
- of the errors, since they'll be caught when parsing the
- expression. We just need to match the non-error
- cases. Thus we can ignore \n in single-quoted strings,
- for example. Or non-terminated strings. */
- if (ch == quote_char) {
- /* Does this match the string_type (single or triple
- quoted)? */
- if (string_type == 3) {
- if (*str+2 < end && *(*str+1) == ch && *(*str+2) == ch) {
- /* We're at the end of a triple quoted string. */
- *str += 2;
- string_type = 0;
- quote_char = 0;
- continue;
- }
- } else {
- /* We're at the end of a normal string. */
- quote_char = 0;
- string_type = 0;
- continue;
- }
- }
- } else if (ch == '\'' || ch == '"') {
- /* Is this a triple quoted string? */
- if (*str+2 < end && *(*str+1) == ch && *(*str+2) == ch) {
- string_type = 3;
- *str += 2;
- } else {
- /* Start of a normal string. */
- string_type = 1;
- }
- /* Start looking for the end of the string. */
- quote_char = ch;
- } else if (ch == '[' || ch == '{' || ch == '(') {
- if (nested_depth >= MAXLEVEL) {
- ast_error(c, n, "f-string: too many nested parenthesis");
- goto error;
- }
- parenstack[nested_depth] = ch;
- nested_depth++;
- } else if (ch == '#') {
- /* Error: can't include a comment character, inside parens
- or not. */
- ast_error(c, n, "f-string expression part cannot include '#'");
- goto error;
- } else if (nested_depth == 0 &&
- (ch == '!' || ch == ':' || ch == '}' ||
- ch == '=' || ch == '>' || ch == '<')) {
- /* See if there's a next character. */
- if (*str+1 < end) {
- char next = *(*str+1);
-
- /* For "!=". since '=' is not an allowed conversion character,
- nothing is lost in this test. */
- if ((ch == '!' && next == '=') || /* != */
- (ch == '=' && next == '=') || /* == */
- (ch == '<' && next == '=') || /* <= */
- (ch == '>' && next == '=') /* >= */
- ) {
- *str += 1;
- continue;
- }
- /* Don't get out of the loop for these, if they're single
- chars (not part of 2-char tokens). If by themselves, they
- don't end an expression (unlike say '!'). */
- if (ch == '>' || ch == '<') {
- continue;
- }
- }
-
- /* Normal way out of this loop. */
- break;
- } else if (ch == ']' || ch == '}' || ch == ')') {
- if (!nested_depth) {
- ast_error(c, n, "f-string: unmatched '%c'", ch);
- goto error;
- }
- nested_depth--;
- int opening = parenstack[nested_depth];
- if (!((opening == '(' && ch == ')') ||
- (opening == '[' && ch == ']') ||
- (opening == '{' && ch == '}')))
- {
- ast_error(c, n,
- "f-string: closing parenthesis '%c' "
- "does not match opening parenthesis '%c'",
- ch, opening);
- goto error;
- }
- } else {
- /* Just consume this char and loop around. */
- }
- }
- expr_end = *str;
- /* If we leave this loop in a string or with mismatched parens, we
- don't care. We'll get a syntax error when compiling the
- expression. But, we can produce a better error message, so
- let's just do that.*/
- if (quote_char) {
- ast_error(c, n, "f-string: unterminated string");
- goto error;
- }
- if (nested_depth) {
- int opening = parenstack[nested_depth - 1];
- ast_error(c, n, "f-string: unmatched '%c'", opening);
- goto error;
- }
-
- if (*str >= end)
- goto unexpected_end_of_string;
-
- /* Compile the expression as soon as possible, so we show errors
- related to the expression before errors related to the
- conversion or format_spec. */
- simple_expression = fstring_compile_expr(expr_start, expr_end, c, n);
- if (!simple_expression)
- goto error;
-
- /* Check for =, which puts the text value of the expression in
- expr_text. */
- if (**str == '=') {
- if (c->c_feature_version < 8) {
- ast_error(c, n,
- "f-string: self documenting expressions are "
- "only supported in Python 3.8 and greater");
- goto error;
- }
- *str += 1;
-
- /* Skip over ASCII whitespace. No need to test for end of string
- here, since we know there's at least a trailing quote somewhere
- ahead. */
- while (Py_ISSPACE(**str)) {
- *str += 1;
- }
-
- /* Set *expr_text to the text of the expression. */
- *expr_text = PyUnicode_FromStringAndSize(expr_start, *str-expr_start);
- if (!*expr_text) {
- goto error;
- }
- }
-
- /* Check for a conversion char, if present. */
- if (**str == '!') {
- *str += 1;
- if (*str >= end)
- goto unexpected_end_of_string;
-
- conversion = **str;
- *str += 1;
-
- /* Validate the conversion. */
- if (!(conversion == 's' || conversion == 'r' || conversion == 'a')) {
- ast_error(c, n,
- "f-string: invalid conversion character: "
- "expected 's', 'r', or 'a'");
- goto error;
- }
-
- }
-
- /* Check for the format spec, if present. */
- if (*str >= end)
- goto unexpected_end_of_string;
- if (**str == ':') {
- *str += 1;
- if (*str >= end)
- goto unexpected_end_of_string;
-
- /* Parse the format spec. */
- format_spec = fstring_parse(str, end, raw, recurse_lvl+1, c, n);
- if (!format_spec)
- goto error;
- }
-
- if (*str >= end || **str != '}')
- goto unexpected_end_of_string;
-
- /* We're at a right brace. Consume it. */
- assert(*str < end);
- assert(**str == '}');
- *str += 1;
-
- /* If we're in = mode (detected by non-NULL expr_text), and have no format
- spec and no explicit conversion, set the conversion to 'r'. */
- if (*expr_text && format_spec == NULL && conversion == -1) {
- conversion = 'r';
- }
-
- /* And now create the FormattedValue node that represents this
- entire expression with the conversion and format spec. */
- *expression = FormattedValue(simple_expression, conversion,
- format_spec, LINENO(n),
- n->n_col_offset, n->n_end_lineno,
- n->n_end_col_offset, c->c_arena);
- if (!*expression)
- goto error;
-
- return 0;
-
-unexpected_end_of_string:
- ast_error(c, n, "f-string: expecting '}'");
- /* Falls through to error. */
-
-error:
- Py_XDECREF(*expr_text);
- return -1;
-
-}
-
-/* Return -1 on error.
-
- Return 0 if we have a literal (possible zero length) and an
- expression (zero length if at the end of the string.
-
- Return 1 if we have a literal, but no expression, and we want the
- caller to call us again. This is used to deal with doubled
- braces.
-
- When called multiple times on the string 'a{{b{0}c', this function
- will return:
-
- 1. the literal 'a{' with no expression, and a return value
- of 1. Despite the fact that there's no expression, the return
- value of 1 means we're not finished yet.
-
- 2. the literal 'b' and the expression '0', with a return value of
- 0. The fact that there's an expression means we're not finished.
-
- 3. literal 'c' with no expression and a return value of 0. The
- combination of the return value of 0 with no expression means
- we're finished.
-*/
-static int
-fstring_find_literal_and_expr(const char **str, const char *end, int raw,
- int recurse_lvl, PyObject **literal,
- PyObject **expr_text, expr_ty *expression,
- struct compiling *c, const node *n)
-{
- int result;
-
- assert(*literal == NULL && *expression == NULL);
-
- /* Get any literal string. */
- result = fstring_find_literal(str, end, raw, literal, recurse_lvl, c, n);
- if (result < 0)
- goto error;
-
- assert(result == 0 || result == 1);
-
- if (result == 1)
- /* We have a literal, but don't look at the expression. */
- return 1;
-
- if (*str >= end || **str == '}')
- /* We're at the end of the string or the end of a nested
- f-string: no expression. The top-level error case where we
- expect to be at the end of the string but we're at a '}' is
- handled later. */
- return 0;
-
- /* We must now be the start of an expression, on a '{'. */
- assert(**str == '{');
-
- if (fstring_find_expr(str, end, raw, recurse_lvl, expr_text,
- expression, c, n) < 0)
- goto error;
-
- return 0;
-
-error:
- Py_CLEAR(*literal);
- return -1;
-}
-
-#define EXPRLIST_N_CACHED 64
-
-typedef struct {
- /* Incrementally build an array of expr_ty, so be used in an
- asdl_seq. Cache some small but reasonably sized number of
- expr_ty's, and then after that start dynamically allocating,
- doubling the number allocated each time. Note that the f-string
- f'{0}a{1}' contains 3 expr_ty's: 2 FormattedValue's, and one
- Constant for the literal 'a'. So you add expr_ty's about twice as
- fast as you add expressions in an f-string. */
-
- Py_ssize_t allocated; /* Number we've allocated. */
- Py_ssize_t size; /* Number we've used. */
- expr_ty *p; /* Pointer to the memory we're actually
- using. Will point to 'data' until we
- start dynamically allocating. */
- expr_ty data[EXPRLIST_N_CACHED];
-} ExprList;
-
-#ifdef NDEBUG
-#define ExprList_check_invariants(l)
-#else
-static void
-ExprList_check_invariants(ExprList *l)
-{
- /* Check our invariants. Make sure this object is "live", and
- hasn't been deallocated. */
- assert(l->size >= 0);
- assert(l->p != NULL);
- if (l->size <= EXPRLIST_N_CACHED)
- assert(l->data == l->p);
-}
-#endif
-
-static void
-ExprList_Init(ExprList *l)
-{
- l->allocated = EXPRLIST_N_CACHED;
- l->size = 0;
-
- /* Until we start allocating dynamically, p points to data. */
- l->p = l->data;
-
- ExprList_check_invariants(l);
-}
-
-static int
-ExprList_Append(ExprList *l, expr_ty exp)
-{
- ExprList_check_invariants(l);
- if (l->size >= l->allocated) {
- /* We need to alloc (or realloc) the memory. */
- Py_ssize_t new_size = l->allocated * 2;
-
- /* See if we've ever allocated anything dynamically. */
- if (l->p == l->data) {
- Py_ssize_t i;
- /* We're still using the cached data. Switch to
- alloc-ing. */
- l->p = PyMem_RawMalloc(sizeof(expr_ty) * new_size);
- if (!l->p)
- return -1;
- /* Copy the cached data into the new buffer. */
- for (i = 0; i < l->size; i++)
- l->p[i] = l->data[i];
- } else {
- /* Just realloc. */
- expr_ty *tmp = PyMem_RawRealloc(l->p, sizeof(expr_ty) * new_size);
- if (!tmp) {
- PyMem_RawFree(l->p);
- l->p = NULL;
- return -1;
- }
- l->p = tmp;
- }
-
- l->allocated = new_size;
- assert(l->allocated == 2 * l->size);
- }
-
- l->p[l->size++] = exp;
-
- ExprList_check_invariants(l);
- return 0;
-}
-
-static void
-ExprList_Dealloc(ExprList *l)
-{
- ExprList_check_invariants(l);
-
- /* If there's been an error, or we've never dynamically allocated,
- do nothing. */
- if (!l->p || l->p == l->data) {
- /* Do nothing. */
- } else {
- /* We have dynamically allocated. Free the memory. */
- PyMem_RawFree(l->p);
- }
- l->p = NULL;
- l->size = -1;
-}
-
-static asdl_seq *
-ExprList_Finish(ExprList *l, PyArena *arena)
-{
- asdl_seq *seq;
-
- ExprList_check_invariants(l);
-
- /* Allocate the asdl_seq and copy the expressions in to it. */
- seq = _Py_asdl_seq_new(l->size, arena);
- if (seq) {
- Py_ssize_t i;
- for (i = 0; i < l->size; i++)
- asdl_seq_SET(seq, i, l->p[i]);
- }
- ExprList_Dealloc(l);
- return seq;
-}
-
-/* The FstringParser is designed to add a mix of strings and
- f-strings, and concat them together as needed. Ultimately, it
- generates an expr_ty. */
-typedef struct {
- PyObject *last_str;
- ExprList expr_list;
- int fmode;
-} FstringParser;
-
-#ifdef NDEBUG
-#define FstringParser_check_invariants(state)
-#else
-static void
-FstringParser_check_invariants(FstringParser *state)
-{
- if (state->last_str)
- assert(PyUnicode_CheckExact(state->last_str));
- ExprList_check_invariants(&state->expr_list);
-}
-#endif
-
-static void
-FstringParser_Init(FstringParser *state)
-{
- state->last_str = NULL;
- state->fmode = 0;
- ExprList_Init(&state->expr_list);
- FstringParser_check_invariants(state);
-}
-
-static void
-FstringParser_Dealloc(FstringParser *state)
-{
- FstringParser_check_invariants(state);
-
- Py_XDECREF(state->last_str);
- ExprList_Dealloc(&state->expr_list);
-}
-
-/* Constants for the following */
-static PyObject *u_kind;
-
-/* Compute 'kind' field for string Constant (either 'u' or None) */
-static PyObject *
-make_kind(struct compiling *c, const node *n)
-{
- char *s = NULL;
- PyObject *kind = NULL;
-
- /* Find the first string literal, if any */
- while (TYPE(n) != STRING) {
- if (NCH(n) == 0)
- return NULL;
- n = CHILD(n, 0);
- }
- REQ(n, STRING);
-
- /* If it starts with 'u', return a PyUnicode "u" string */
- s = STR(n);
- if (s && *s == 'u') {
- if (!u_kind) {
- u_kind = PyUnicode_InternFromString("u");
- if (!u_kind)
- return NULL;
- }
- kind = u_kind;
- if (PyArena_AddPyObject(c->c_arena, kind) < 0) {
- return NULL;
- }
- Py_INCREF(kind);
- }
- return kind;
-}
-
-/* Make a Constant node, but decref the PyUnicode object being added. */
-static expr_ty
-make_str_node_and_del(PyObject **str, struct compiling *c, const node* n)
-{
- PyObject *s = *str;
- PyObject *kind = NULL;
- *str = NULL;
- assert(PyUnicode_CheckExact(s));
- if (PyArena_AddPyObject(c->c_arena, s) < 0) {
- Py_DECREF(s);
- return NULL;
- }
- kind = make_kind(c, n);
- if (kind == NULL && PyErr_Occurred())
- return NULL;
- return Constant(s, kind, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-}
-
-/* Add a non-f-string (that is, a regular literal string). str is
- decref'd. */
-static int
-FstringParser_ConcatAndDel(FstringParser *state, PyObject *str)
-{
- FstringParser_check_invariants(state);
-
- assert(PyUnicode_CheckExact(str));
-
- if (PyUnicode_GET_LENGTH(str) == 0) {
- Py_DECREF(str);
- return 0;
- }
-
- if (!state->last_str) {
- /* We didn't have a string before, so just remember this one. */
- state->last_str = str;
- } else {
- /* Concatenate this with the previous string. */
- PyUnicode_AppendAndDel(&state->last_str, str);
- if (!state->last_str)
- return -1;
- }
- FstringParser_check_invariants(state);
- return 0;
-}
-
-/* Parse an f-string. The f-string is in *str to end, with no
- 'f' or quotes. */
-static int
-FstringParser_ConcatFstring(FstringParser *state, const char **str,
- const char *end, int raw, int recurse_lvl,
- struct compiling *c, const node *n)
-{
- FstringParser_check_invariants(state);
- state->fmode = 1;
-
- /* Parse the f-string. */
- while (1) {
- PyObject *literal = NULL;
- PyObject *expr_text = NULL;
- expr_ty expression = NULL;
-
- /* If there's a zero length literal in front of the
- expression, literal will be NULL. If we're at the end of
- the f-string, expression will be NULL (unless result == 1,
- see below). */
- int result = fstring_find_literal_and_expr(str, end, raw, recurse_lvl,
- &literal, &expr_text,
- &expression, c, n);
- if (result < 0)
- return -1;
-
- /* Add the literal, if any. */
- if (literal && FstringParser_ConcatAndDel(state, literal) < 0) {
- Py_XDECREF(expr_text);
- return -1;
- }
- /* Add the expr_text, if any. */
- if (expr_text && FstringParser_ConcatAndDel(state, expr_text) < 0) {
- return -1;
- }
-
- /* We've dealt with the literal and expr_text, their ownership has
- been transferred to the state object. Don't look at them again. */
-
- /* See if we should just loop around to get the next literal
- and expression, while ignoring the expression this
- time. This is used for un-doubling braces, as an
- optimization. */
- if (result == 1)
- continue;
-
- if (!expression)
- /* We're done with this f-string. */
- break;
-
- /* We know we have an expression. Convert any existing string
- to a Constant node. */
- if (!state->last_str) {
- /* Do nothing. No previous literal. */
- } else {
- /* Convert the existing last_str literal to a Constant node. */
- expr_ty str = make_str_node_and_del(&state->last_str, c, n);
- if (!str || ExprList_Append(&state->expr_list, str) < 0)
- return -1;
- }
-
- if (ExprList_Append(&state->expr_list, expression) < 0)
- return -1;
- }
-
- /* If recurse_lvl is zero, then we must be at the end of the
- string. Otherwise, we must be at a right brace. */
-
- if (recurse_lvl == 0 && *str < end-1) {
- ast_error(c, n, "f-string: unexpected end of string");
- return -1;
- }
- if (recurse_lvl != 0 && **str != '}') {
- ast_error(c, n, "f-string: expecting '}'");
- return -1;
- }
-
- FstringParser_check_invariants(state);
- return 0;
-}
-
-/* Convert the partial state reflected in last_str and expr_list to an
- expr_ty. The expr_ty can be a Constant, or a JoinedStr. */
-static expr_ty
-FstringParser_Finish(FstringParser *state, struct compiling *c,
- const node *n)
-{
- asdl_seq *seq;
-
- FstringParser_check_invariants(state);
-
- /* If we're just a constant string with no expressions, return
- that. */
- if (!state->fmode) {
- assert(!state->expr_list.size);
- if (!state->last_str) {
- /* Create a zero length string. */
- state->last_str = PyUnicode_FromStringAndSize(NULL, 0);
- if (!state->last_str)
- goto error;
- }
- return make_str_node_and_del(&state->last_str, c, n);
- }
-
- /* Create a Constant node out of last_str, if needed. It will be the
- last node in our expression list. */
- if (state->last_str) {
- expr_ty str = make_str_node_and_del(&state->last_str, c, n);
- if (!str || ExprList_Append(&state->expr_list, str) < 0)
- goto error;
- }
- /* This has already been freed. */
- assert(state->last_str == NULL);
-
- seq = ExprList_Finish(&state->expr_list, c->c_arena);
- if (!seq)
- goto error;
-
- return JoinedStr(seq, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
-
-error:
- FstringParser_Dealloc(state);
- return NULL;
-}
-
-/* Given an f-string (with no 'f' or quotes) that's in *str and ends
- at end, parse it into an expr_ty. Return NULL on error. Adjust
- str to point past the parsed portion. */
-static expr_ty
-fstring_parse(const char **str, const char *end, int raw, int recurse_lvl,
- struct compiling *c, const node *n)
-{
- FstringParser state;
-
- FstringParser_Init(&state);
- if (FstringParser_ConcatFstring(&state, str, end, raw, recurse_lvl,
- c, n) < 0) {
- FstringParser_Dealloc(&state);
- return NULL;
- }
-
- return FstringParser_Finish(&state, c, n);
-}
-
-/* n is a Python string literal, including the bracketing quote
- characters, and r, b, u, &/or f prefixes (if any), and embedded
- escape sequences (if any). parsestr parses it, and sets *result to
- decoded Python string object. If the string is an f-string, set
- *fstr and *fstrlen to the unparsed string object. Return 0 if no
- errors occurred.
-*/
-static int
-parsestr(struct compiling *c, const node *n, int *bytesmode, int *rawmode,
- PyObject **result, const char **fstr, Py_ssize_t *fstrlen)
-{
- size_t len;
- const char *s = STR(n);
- int quote = Py_CHARMASK(*s);
- int fmode = 0;
- *bytesmode = 0;
- *rawmode = 0;
- *result = NULL;
- *fstr = NULL;
- if (Py_ISALPHA(quote)) {
- while (!*bytesmode || !*rawmode) {
- if (quote == 'b' || quote == 'B') {
- quote = *++s;
- *bytesmode = 1;
- }
- else if (quote == 'u' || quote == 'U') {
- quote = *++s;
- }
- else if (quote == 'r' || quote == 'R') {
- quote = *++s;
- *rawmode = 1;
- }
- else if (quote == 'f' || quote == 'F') {
- quote = *++s;
- fmode = 1;
- }
- else {
- break;
- }
- }
- }
-
- /* fstrings are only allowed in Python 3.6 and greater */
- if (fmode && c->c_feature_version < 6) {
- ast_error(c, n, "Format strings are only supported in Python 3.6 and greater");
- return -1;
- }
-
- if (fmode && *bytesmode) {
- PyErr_BadInternalCall();
- return -1;
- }
- if (quote != '\'' && quote != '\"') {
- PyErr_BadInternalCall();
- return -1;
- }
- /* Skip the leading quote char. */
- s++;
- len = strlen(s);
- if (len > INT_MAX) {
- PyErr_SetString(PyExc_OverflowError,
- "string to parse is too long");
- return -1;
- }
- if (s[--len] != quote) {
- /* Last quote char must match the first. */
- PyErr_BadInternalCall();
- return -1;
- }
- if (len >= 4 && s[0] == quote && s[1] == quote) {
- /* A triple quoted string. We've already skipped one quote at
- the start and one at the end of the string. Now skip the
- two at the start. */
- s += 2;
- len -= 2;
- /* And check that the last two match. */
- if (s[--len] != quote || s[--len] != quote) {
- PyErr_BadInternalCall();
- return -1;
- }
- }
-
- if (fmode) {
- /* Just return the bytes. The caller will parse the resulting
- string. */
- *fstr = s;
- *fstrlen = len;
- return 0;
- }
-
- /* Not an f-string. */
- /* Avoid invoking escape decoding routines if possible. */
- *rawmode = *rawmode || strchr(s, '\\') == NULL;
- if (*bytesmode) {
- /* Disallow non-ASCII characters. */
- const char *ch;
- for (ch = s; *ch; ch++) {
- if (Py_CHARMASK(*ch) >= 0x80) {
- ast_error(c, n,
- "bytes can only contain ASCII "
- "literal characters.");
- return -1;
- }
- }
- if (*rawmode)
- *result = PyBytes_FromStringAndSize(s, len);
- else
- *result = decode_bytes_with_escapes(c, n, s, len);
- } else {
- if (*rawmode)
- *result = PyUnicode_DecodeUTF8Stateful(s, len, NULL, NULL);
- else
- *result = decode_unicode_with_escapes(c, n, s, len);
- }
- return *result == NULL ? -1 : 0;
-}
-
-/* Accepts a STRING+ atom, and produces an expr_ty node. Run through
- each STRING atom, and process it as needed. For bytes, just
- concatenate them together, and the result will be a Constant node. For
- normal strings and f-strings, concatenate them together. The result
- will be a Constant node if there were no f-strings; a FormattedValue
- node if there's just an f-string (with no leading or trailing
- literals), or a JoinedStr node if there are multiple f-strings or
- any literals involved. */
-static expr_ty
-parsestrplus(struct compiling *c, const node *n)
-{
- int bytesmode = 0;
- PyObject *bytes_str = NULL;
- int i;
-
- FstringParser state;
- FstringParser_Init(&state);
-
- for (i = 0; i < NCH(n); i++) {
- int this_bytesmode;
- int this_rawmode;
- PyObject *s;
- const char *fstr;
- Py_ssize_t fstrlen = -1; /* Silence a compiler warning. */
-
- REQ(CHILD(n, i), STRING);
- if (parsestr(c, CHILD(n, i), &this_bytesmode, &this_rawmode, &s,
- &fstr, &fstrlen) != 0)
- goto error;
-
- /* Check that we're not mixing bytes with unicode. */
- if (i != 0 && bytesmode != this_bytesmode) {
- ast_error(c, n, "cannot mix bytes and nonbytes literals");
- /* s is NULL if the current string part is an f-string. */
- Py_XDECREF(s);
- goto error;
- }
- bytesmode = this_bytesmode;
-
- if (fstr != NULL) {
- int result;
- assert(s == NULL && !bytesmode);
- /* This is an f-string. Parse and concatenate it. */
- result = FstringParser_ConcatFstring(&state, &fstr, fstr+fstrlen,
- this_rawmode, 0, c, n);
- if (result < 0)
- goto error;
- } else {
- /* A string or byte string. */
- assert(s != NULL && fstr == NULL);
-
- assert(bytesmode ? PyBytes_CheckExact(s) :
- PyUnicode_CheckExact(s));
-
- if (bytesmode) {
- /* For bytes, concat as we go. */
- if (i == 0) {
- /* First time, just remember this value. */
- bytes_str = s;
- } else {
- PyBytes_ConcatAndDel(&bytes_str, s);
- if (!bytes_str)
- goto error;
- }
- } else {
- /* This is a regular string. Concatenate it. */
- if (FstringParser_ConcatAndDel(&state, s) < 0)
- goto error;
- }
- }
- }
- if (bytesmode) {
- /* Just return the bytes object and we're done. */
- if (PyArena_AddPyObject(c->c_arena, bytes_str) < 0)
- goto error;
- return Constant(bytes_str, NULL, LINENO(n), n->n_col_offset,
- n->n_end_lineno, n->n_end_col_offset, c->c_arena);
- }
-
- /* We're not a bytes string, bytes_str should never have been set. */
- assert(bytes_str == NULL);
-
- return FstringParser_Finish(&state, c, n);
-
-error:
- Py_XDECREF(bytes_str);
- FstringParser_Dealloc(&state);
- return NULL;
-}
-
PyObject *
_PyAST_GetDocString(asdl_seq *body)
{
diff --git a/Python/compile.c b/Python/compile.c
index fccc688..8fe82f9 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -390,21 +390,6 @@ PyAST_CompileEx(mod_ty mod, const char *filename_str, PyCompilerFlags *flags,
}
-PyCodeObject *
-PyNode_Compile(struct _node *n, const char *filename)
-{
- PyCodeObject *co = NULL;
- mod_ty mod;
- PyArena *arena = PyArena_New();
- if (!arena)
- return NULL;
- mod = PyAST_FromNode(n, NULL, filename, arena);
- if (mod)
- co = PyAST_Compile(mod, filename, NULL, arena);
- PyArena_Free(arena);
- return co;
-}
-
static void
compiler_free(struct compiler *c)
{
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 998ceb7..d8b3df8 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -72,7 +72,6 @@ static const char usage_3[] = "\
-X opt : set implementation-specific option. The following options are available:\n\
\n\
-X faulthandler: enable faulthandler\n\
- -X oldparser: enable the traditional LL(1) parser; also PYTHONOLDPARSER\n\
-X showrefcount: output the total reference count and number of used\n\
memory blocks when the program finishes or after each statement in the\n\
interactive interpreter. This only works on debug builds\n\
@@ -640,7 +639,6 @@ _PyConfig_InitCompatConfig(PyConfig *config)
#ifdef MS_WINDOWS
config->legacy_windows_stdio = -1;
#endif
- config->_use_peg_parser = 1;
}
@@ -798,7 +796,6 @@ _PyConfig_Copy(PyConfig *config, const PyConfig *config2)
COPY_ATTR(isolated);
COPY_ATTR(use_environment);
COPY_ATTR(dev_mode);
- COPY_ATTR(_use_peg_parser);
COPY_ATTR(install_signal_handlers);
COPY_ATTR(use_hash_seed);
COPY_ATTR(hash_seed);
@@ -905,7 +902,6 @@ config_as_dict(const PyConfig *config)
SET_ITEM_INT(isolated);
SET_ITEM_INT(use_environment);
SET_ITEM_INT(dev_mode);
- SET_ITEM_INT(_use_peg_parser);
SET_ITEM_INT(install_signal_handlers);
SET_ITEM_INT(use_hash_seed);
SET_ITEM_UINT(hash_seed);
@@ -1451,11 +1447,6 @@ config_read_complex_options(PyConfig *config)
config->import_time = 1;
}
- if (config_get_env(config, "PYTHONOLDPARSER")
- || config_get_xoption(config, L"oldparser")) {
- config->_use_peg_parser = 0;
- }
-
PyStatus status;
if (config->tracemalloc < 0) {
status = config_init_tracemalloc(config);
@@ -2549,7 +2540,6 @@ PyConfig_Read(PyConfig *config)
assert(config->isolated >= 0);
assert(config->use_environment >= 0);
assert(config->dev_mode >= 0);
- assert(config->_use_peg_parser >= 0);
assert(config->install_signal_handlers >= 0);
assert(config->use_hash_seed >= 0);
assert(config->faulthandler >= 0);
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index f2f7d58..c754f21 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -18,7 +18,6 @@
#include "pycore_sysmodule.h" // _PySys_ClearAuditHooks()
#include "pycore_traceback.h" // _Py_DumpTracebackThreads()
-#include "grammar.h" // PyGrammar_RemoveAccelerators()
#include <locale.h> // setlocale()
#ifdef HAVE_SIGNAL_H
@@ -50,7 +49,6 @@ _Py_IDENTIFIER(threading);
extern "C" {
#endif
-extern grammar _PyParser_Grammar; /* From graminit.c */
/* Forward declarations */
static PyStatus add_main_module(PyInterpreterState *interp);
@@ -1301,7 +1299,6 @@ finalize_interp_clear(PyThreadState *tstate)
_PyWarnings_Fini(tstate->interp);
if (is_main_interp) {
- PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
_PyExc_Fini();
}
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index cb0e3b0..7a3b5b5 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -58,16 +58,12 @@ _Py_static_string(PyId_string, "<string>");
extern "C" {
#endif
-extern Py_EXPORTED_SYMBOL grammar _PyParser_Grammar; /* From graminit.c */
-
/* Forward */
static void flush_io(void);
static PyObject *run_mod(mod_ty, PyObject *, PyObject *, PyObject *,
PyCompilerFlags *, PyArena *);
static PyObject *run_pyc_file(FILE *, const char *, PyObject *, PyObject *,
PyCompilerFlags *);
-static void err_input(perrdetail *);
-static void err_free(perrdetail *);
static int PyRun_InteractiveOneObjectEx(FILE *, PyObject *, PyCompilerFlags *);
/* Parse input from a file and execute it */
@@ -148,32 +144,6 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *
return err;
}
-/* compute parser flags based on compiler flags */
-static int PARSER_FLAGS(PyCompilerFlags *flags)
-{
- int parser_flags = 0;
- if (!flags)
- return 0;
- if (flags->cf_flags & PyCF_DONT_IMPLY_DEDENT)
- parser_flags |= PyPARSE_DONT_IMPLY_DEDENT;
- if (flags->cf_flags & PyCF_IGNORE_COOKIE)
- parser_flags |= PyPARSE_IGNORE_COOKIE;
- if (flags->cf_flags & CO_FUTURE_BARRY_AS_BDFL)
- parser_flags |= PyPARSE_BARRY_AS_BDFL;
- if (flags->cf_flags & PyCF_TYPE_COMMENTS)
- parser_flags |= PyPARSE_TYPE_COMMENTS;
- return parser_flags;
-}
-
-#if 0
-/* Keep an example of flags with future keyword support. */
-#define PARSER_FLAGS(flags) \
- ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \
- PyPARSE_DONT_IMPLY_DEDENT : 0) \
- | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \
- PyPARSE_WITH_IS_KEYWORD : 0)) : 0)
-#endif
-
/* A PyRun_InteractiveOneObject() auxiliary function that does not print the
* error on failure. */
static int
@@ -185,7 +155,6 @@ PyRun_InteractiveOneObjectEx(FILE *fp, PyObject *filename,
PyArena *arena;
const char *ps1 = "", *ps2 = "", *enc = NULL;
int errcode = 0;
- int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
_Py_IDENTIFIER(encoding);
_Py_IDENTIFIER(__main__);
@@ -239,15 +208,8 @@ PyRun_InteractiveOneObjectEx(FILE *fp, PyObject *filename,
return -1;
}
- if (use_peg) {
- mod = PyPegen_ASTFromFileObject(fp, filename, Py_single_input,
- enc, ps1, ps2, flags, &errcode, arena);
- }
- else {
- mod = PyParser_ASTFromFileObject(fp, filename, enc,
- Py_single_input, ps1, ps2,
- flags, &errcode, arena);
- }
+ mod = PyPegen_ASTFromFileObject(fp, filename, Py_single_input,
+ enc, ps1, ps2, flags, &errcode, arena);
Py_XDECREF(v);
Py_XDECREF(w);
@@ -1058,7 +1020,6 @@ PyRun_StringFlags(const char *str, int start, PyObject *globals,
mod_ty mod;
PyArena *arena;
PyObject *filename;
- int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
filename = _PyUnicode_FromId(&PyId_string); /* borrowed */
if (filename == NULL)
@@ -1068,12 +1029,7 @@ PyRun_StringFlags(const char *str, int start, PyObject *globals,
if (arena == NULL)
return NULL;
- if (use_peg) {
- mod = PyPegen_ASTFromStringObject(str, filename, start, flags, arena);
- }
- else {
- mod = PyParser_ASTFromStringObject(str, filename, start, flags, arena);
- }
+ mod = PyPegen_ASTFromStringObject(str, filename, start, flags, arena);
if (mod != NULL)
ret = run_mod(mod, filename, globals, locals, flags, arena);
@@ -1089,7 +1045,6 @@ PyRun_FileExFlags(FILE *fp, const char *filename_str, int start, PyObject *globa
mod_ty mod;
PyArena *arena = NULL;
PyObject *filename;
- int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
filename = PyUnicode_DecodeFSDefault(filename_str);
if (filename == NULL)
@@ -1099,14 +1054,8 @@ PyRun_FileExFlags(FILE *fp, const char *filename_str, int start, PyObject *globa
if (arena == NULL)
goto exit;
- if (use_peg) {
- mod = PyPegen_ASTFromFileObject(fp, filename, start, NULL, NULL, NULL,
+ mod = PyPegen_ASTFromFileObject(fp, filename, start, NULL, NULL, NULL,
flags, NULL, arena);
- }
- else {
- mod = PyParser_ASTFromFileObject(fp, filename, NULL, start, 0, 0,
- flags, NULL, arena);
- }
if (closeit)
fclose(fp);
@@ -1250,17 +1199,11 @@ Py_CompileStringObject(const char *str, PyObject *filename, int start,
{
PyCodeObject *co;
mod_ty mod;
- int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
PyArena *arena = PyArena_New();
if (arena == NULL)
return NULL;
- if (use_peg) {
- mod = PyPegen_ASTFromStringObject(str, filename, start, flags, arena);
- }
- else {
- mod = PyParser_ASTFromStringObject(str, filename, start, flags, arena);
- }
+ mod = PyPegen_ASTFromStringObject(str, filename, start, flags, arena);
if (mod == NULL) {
PyArena_Free(arena);
return NULL;
@@ -1357,19 +1300,13 @@ _Py_SymtableStringObjectFlags(const char *str, PyObject *filename, int start, Py
{
struct symtable *st;
mod_ty mod;
- int use_peg = _PyInterpreterState_GET()->config._use_peg_parser;
PyArena *arena;
arena = PyArena_New();
if (arena == NULL)
return NULL;
- if (use_peg) {
- mod = PyPegen_ASTFromStringObject(str, filename, start, flags, arena);
- }
- else {
- mod = PyParser_ASTFromStringObject(str, filename, start, flags, arena);
- }
+ mod = PyPegen_ASTFromStringObject(str, filename, start, flags, arena);
if (mod == NULL) {
PyArena_Free(arena);
return NULL;
@@ -1393,291 +1330,6 @@ Py_SymtableString(const char *str, const char *filename_str, int start)
return st;
}
-/* Preferred access to parser is through AST. */
-mod_ty
-PyParser_ASTFromStringObject(const char *s, PyObject *filename, int start,
- PyCompilerFlags *flags, PyArena *arena)
-{
- mod_ty mod;
- PyCompilerFlags localflags = _PyCompilerFlags_INIT;
- perrdetail err;
- int iflags = PARSER_FLAGS(flags);
- if (flags && flags->cf_feature_version < 7)
- iflags |= PyPARSE_ASYNC_HACKS;
-
- node *n = PyParser_ParseStringObject(s, filename,
- &_PyParser_Grammar, start, &err,
- &iflags);
- if (flags == NULL) {
- flags = &localflags;
- }
- if (n) {
- flags->cf_flags |= iflags & PyCF_MASK;
- mod = PyAST_FromNodeObject(n, flags, filename, arena);
- PyNode_Free(n);
- }
- else {
- err_input(&err);
- mod = NULL;
- }
- err_free(&err);
- return mod;
-}
-
-mod_ty
-PyParser_ASTFromString(const char *s, const char *filename_str, int start,
- PyCompilerFlags *flags, PyArena *arena)
-{
- PyObject *filename;
- mod_ty mod;
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL)
- return NULL;
- mod = PyParser_ASTFromStringObject(s, filename, start, flags, arena);
- Py_DECREF(filename);
- return mod;
-}
-
-mod_ty
-PyParser_ASTFromFileObject(FILE *fp, PyObject *filename, const char* enc,
- int start, const char *ps1,
- const char *ps2, PyCompilerFlags *flags, int *errcode,
- PyArena *arena)
-{
- mod_ty mod;
- PyCompilerFlags localflags = _PyCompilerFlags_INIT;
- perrdetail err;
- int iflags = PARSER_FLAGS(flags);
-
- node *n = PyParser_ParseFileObject(fp, filename, enc,
- &_PyParser_Grammar,
- start, ps1, ps2, &err, &iflags);
- if (flags == NULL) {
- flags = &localflags;
- }
- if (n) {
- flags->cf_flags |= iflags & PyCF_MASK;
- mod = PyAST_FromNodeObject(n, flags, filename, arena);
- PyNode_Free(n);
- }
- else {
- err_input(&err);
- if (errcode)
- *errcode = err.error;
- mod = NULL;
- }
- err_free(&err);
- return mod;
-}
-
-mod_ty
-PyParser_ASTFromFile(FILE *fp, const char *filename_str, const char* enc,
- int start, const char *ps1,
- const char *ps2, PyCompilerFlags *flags, int *errcode,
- PyArena *arena)
-{
- mod_ty mod;
- PyObject *filename;
- filename = PyUnicode_DecodeFSDefault(filename_str);
- if (filename == NULL)
- return NULL;
- mod = PyParser_ASTFromFileObject(fp, filename, enc, start, ps1, ps2,
- flags, errcode, arena);
- Py_DECREF(filename);
- return mod;
-}
-
-/* Simplified interface to parsefile -- return node or set exception */
-
-node *
-PyParser_SimpleParseFileFlags(FILE *fp, const char *filename, int start, int flags)
-{
- perrdetail err;
- node *n = PyParser_ParseFileFlags(fp, filename, NULL,
- &_PyParser_Grammar,
- start, NULL, NULL, &err, flags);
- if (n == NULL)
- err_input(&err);
- err_free(&err);
-
- return n;
-}
-
-/* Simplified interface to parsestring -- return node or set exception */
-
-node *
-PyParser_SimpleParseStringFlags(const char *str, int start, int flags)
-{
- perrdetail err;
- node *n = PyParser_ParseStringFlags(str, &_PyParser_Grammar,
- start, &err, flags);
- if (n == NULL)
- err_input(&err);
- err_free(&err);
- return n;
-}
-
-node *
-PyParser_SimpleParseStringFlagsFilename(const char *str, const char *filename,
- int start, int flags)
-{
- perrdetail err;
- node *n = PyParser_ParseStringFlagsFilename(str, filename,
- &_PyParser_Grammar, start, &err, flags);
- if (n == NULL)
- err_input(&err);
- err_free(&err);
- return n;
-}
-
-/* May want to move a more generalized form of this to parsetok.c or
- even parser modules. */
-
-void
-PyParser_ClearError(perrdetail *err)
-{
- err_free(err);
-}
-
-void
-PyParser_SetError(perrdetail *err)
-{
- err_input(err);
-}
-
-static void
-err_free(perrdetail *err)
-{
- Py_CLEAR(err->filename);
-}
-
-/* Set the error appropriate to the given input error code (see errcode.h) */
-
-static void
-err_input(perrdetail *err)
-{
- PyObject *v, *w, *errtype, *errtext;
- PyObject *msg_obj = NULL;
- const char *msg = NULL;
- int offset = err->offset;
-
- errtype = PyExc_SyntaxError;
- switch (err->error) {
- case E_ERROR:
- goto cleanup;
- case E_SYNTAX:
- errtype = PyExc_IndentationError;
- if (err->expected == INDENT)
- msg = "expected an indented block";
- else if (err->token == INDENT)
- msg = "unexpected indent";
- else if (err->token == DEDENT)
- msg = "unexpected unindent";
- else if (err->expected == NOTEQUAL) {
- errtype = PyExc_SyntaxError;
- msg = "with Barry as BDFL, use '<>' instead of '!='";
- }
- else {
- errtype = PyExc_SyntaxError;
- msg = "invalid syntax";
- }
- break;
- case E_TOKEN:
- msg = "invalid token";
- break;
- case E_EOFS:
- msg = "EOF while scanning triple-quoted string literal";
- break;
- case E_EOLS:
- msg = "EOL while scanning string literal";
- break;
- case E_INTR:
- if (!PyErr_Occurred())
- PyErr_SetNone(PyExc_KeyboardInterrupt);
- goto cleanup;
- case E_NOMEM:
- PyErr_NoMemory();
- goto cleanup;
- case E_EOF:
- msg = "unexpected EOF while parsing";
- break;
- case E_TABSPACE:
- errtype = PyExc_TabError;
- msg = "inconsistent use of tabs and spaces in indentation";
- break;
- case E_OVERFLOW:
- msg = "expression too long";
- break;
- case E_DEDENT:
- errtype = PyExc_IndentationError;
- msg = "unindent does not match any outer indentation level";
- break;
- case E_TOODEEP:
- errtype = PyExc_IndentationError;
- msg = "too many levels of indentation";
- break;
- case E_DECODE: {
- PyObject *type, *value, *tb;
- PyErr_Fetch(&type, &value, &tb);
- msg = "unknown decode error";
- if (value != NULL)
- msg_obj = PyObject_Str(value);
- Py_XDECREF(type);
- Py_XDECREF(value);
- Py_XDECREF(tb);
- break;
- }
- case E_LINECONT:
- msg = "unexpected character after line continuation character";
- break;
-
- case E_BADSINGLE:
- msg = "multiple statements found while compiling a single statement";
- break;
- default:
- fprintf(stderr, "error=%d\n", err->error);
- msg = "unknown parsing error";
- break;
- }
- /* err->text may not be UTF-8 in case of decoding errors.
- Explicitly convert to an object. */
- if (!err->text) {
- errtext = Py_None;
- Py_INCREF(Py_None);
- } else {
- errtext = PyUnicode_DecodeUTF8(err->text, err->offset,
- "replace");
- if (errtext != NULL) {
- Py_ssize_t len = strlen(err->text);
- offset = (int)PyUnicode_GET_LENGTH(errtext);
- if (len != err->offset) {
- Py_DECREF(errtext);
- errtext = PyUnicode_DecodeUTF8(err->text, len,
- "replace");
- }
- }
- }
- v = Py_BuildValue("(OiiN)", err->filename,
- err->lineno, offset, errtext);
- if (v != NULL) {
- if (msg_obj)
- w = Py_BuildValue("(OO)", msg_obj, v);
- else
- w = Py_BuildValue("(sO)", msg, v);
- } else
- w = NULL;
- Py_XDECREF(v);
- PyErr_SetObject(errtype, w);
- Py_XDECREF(w);
-cleanup:
- Py_XDECREF(msg_obj);
- if (err->text != NULL) {
- PyObject_FREE(err->text);
- err->text = NULL;
- }
-}
-
-
#if defined(USE_STACKCHECK)
#if defined(WIN32) && defined(_MSC_VER)
@@ -1715,123 +1367,6 @@ PyOS_CheckStack(void)
#endif /* USE_STACKCHECK */
-/* Deprecated C API functions still provided for binary compatibility */
-
-#undef PyParser_SimpleParseFile
-PyAPI_FUNC(node *)
-PyParser_SimpleParseFile(FILE *fp, const char *filename, int start)
-{
- return PyParser_SimpleParseFileFlags(fp, filename, start, 0);
-}
-
-#undef PyParser_SimpleParseString
-PyAPI_FUNC(node *)
-PyParser_SimpleParseString(const char *str, int start)
-{
- return PyParser_SimpleParseStringFlags(str, start, 0);
-}
-
-#undef PyRun_AnyFile
-PyAPI_FUNC(int)
-PyRun_AnyFile(FILE *fp, const char *name)
-{
- return PyRun_AnyFileExFlags(fp, name, 0, NULL);
-}
-
-#undef PyRun_AnyFileEx
-PyAPI_FUNC(int)
-PyRun_AnyFileEx(FILE *fp, const char *name, int closeit)
-{
- return PyRun_AnyFileExFlags(fp, name, closeit, NULL);
-}
-
-#undef PyRun_AnyFileFlags
-PyAPI_FUNC(int)
-PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags)
-{
- return PyRun_AnyFileExFlags(fp, name, 0, flags);
-}
-
-#undef PyRun_File
-PyAPI_FUNC(PyObject *)
-PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l)
-{
- return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);
-}
-
-#undef PyRun_FileEx
-PyAPI_FUNC(PyObject *)
-PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c)
-{
- return PyRun_FileExFlags(fp, p, s, g, l, c, NULL);
-}
-
-#undef PyRun_FileFlags
-PyAPI_FUNC(PyObject *)
-PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,
- PyCompilerFlags *flags)
-{
- return PyRun_FileExFlags(fp, p, s, g, l, 0, flags);
-}
-
-#undef PyRun_SimpleFile
-PyAPI_FUNC(int)
-PyRun_SimpleFile(FILE *f, const char *p)
-{
- return PyRun_SimpleFileExFlags(f, p, 0, NULL);
-}
-
-#undef PyRun_SimpleFileEx
-PyAPI_FUNC(int)
-PyRun_SimpleFileEx(FILE *f, const char *p, int c)
-{
- return PyRun_SimpleFileExFlags(f, p, c, NULL);
-}
-
-
-#undef PyRun_String
-PyAPI_FUNC(PyObject *)
-PyRun_String(const char *str, int s, PyObject *g, PyObject *l)
-{
- return PyRun_StringFlags(str, s, g, l, NULL);
-}
-
-#undef PyRun_SimpleString
-PyAPI_FUNC(int)
-PyRun_SimpleString(const char *s)
-{
- return PyRun_SimpleStringFlags(s, NULL);
-}
-
-#undef Py_CompileString
-PyAPI_FUNC(PyObject *)
-Py_CompileString(const char *str, const char *p, int s)
-{
- return Py_CompileStringExFlags(str, p, s, NULL, -1);
-}
-
-#undef Py_CompileStringFlags
-PyAPI_FUNC(PyObject *)
-Py_CompileStringFlags(const char *str, const char *p, int s,
- PyCompilerFlags *flags)
-{
- return Py_CompileStringExFlags(str, p, s, flags, -1);
-}
-
-#undef PyRun_InteractiveOne
-PyAPI_FUNC(int)
-PyRun_InteractiveOne(FILE *f, const char *p)
-{
- return PyRun_InteractiveOneFlags(f, p, NULL);
-}
-
-#undef PyRun_InteractiveLoop
-PyAPI_FUNC(int)
-PyRun_InteractiveLoop(FILE *f, const char *p)
-{
- return PyRun_InteractiveLoopFlags(f, p, NULL);
-}
-
#ifdef __cplusplus
}
#endif
diff --git a/Tools/peg_generator/pegen/build.py b/Tools/peg_generator/pegen/build.py
index 931ffc7..9edde37 100644
--- a/Tools/peg_generator/pegen/build.py
+++ b/Tools/peg_generator/pegen/build.py
@@ -66,15 +66,14 @@ def compile_c_extension(
str(MOD_DIR.parent.parent.parent / "Python" / "Python-ast.c"),
str(MOD_DIR.parent.parent.parent / "Python" / "asdl.c"),
str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer.c"),
- str(MOD_DIR.parent.parent.parent / "Parser" / "pegen" / "pegen.c"),
- str(MOD_DIR.parent.parent.parent / "Parser" / "pegen" / "parse_string.c"),
+ str(MOD_DIR.parent.parent.parent / "Parser" / "pegen.c"),
+ str(MOD_DIR.parent.parent.parent / "Parser" / "string_parser.c"),
str(MOD_DIR.parent / "peg_extension" / "peg_extension.c"),
generated_source_path,
],
include_dirs=[
str(MOD_DIR.parent.parent.parent / "Include" / "internal"),
str(MOD_DIR.parent.parent.parent / "Parser"),
- str(MOD_DIR.parent.parent.parent / "Parser" / "pegen"),
],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
diff --git a/configure.ac b/configure.ac
index 30856c8..3001cc8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5438,7 +5438,7 @@ do
done
AC_SUBST(SRCDIRS)
-SRCDIRS="Parser Parser/pegen Objects Python Modules Modules/_io Programs"
+SRCDIRS="Parser Objects Python Modules Modules/_io Programs"
AC_MSG_CHECKING(for build directories)
for dir in $SRCDIRS; do
if test ! -d $dir; then
diff --git a/setup.py b/setup.py
index a220f366..ef2faf6 100644
--- a/setup.py
+++ b/setup.py
@@ -917,9 +917,6 @@ class PyBuildExt(build_ext):
# select(2); not on ancient System V
self.add(Extension('select', ['selectmodule.c']))
- # Fred Drake's interface to the Python parser
- self.add(Extension('parser', ['parsermodule.c']))
-
# Memory-mapped files (also works on Win32).
self.add(Extension('mmap', ['mmapmodule.c']))