python -m pegen -o parser.py cpython\Grammar\python.gram
File "<unknown>", line 1
_PyAST_Interactive ( a , p -> arena )
^^
SyntaxError: invalid syntax
» PYTHONPATH=$PWD/Tools/peg_generator python3 -m pegen --help
usage: pegen [-h] [-q] [-v] {c,python} ...
Experimental PEG-like parser generator
positional arguments:
{c,python} target language for the generated code
c Generate C code for inclusion into CPython
python Generate Python code, needs grammar definition with Python actions, see
`we-like-parsers/pegen`
options:
-h, --help show this help message and exit
-q, --quiet Don't print the parsed grammar
-v, --verbose Print timing stats; repeat for more debug output
I have a PR ready.
Bug report
I've got contacted by a user who tried to generate a pure-python parser with
pegenfrom https://github.com/python/cpython/blob/main/Grammar/python.gramIt was failing with
I think that
--helpforpythonsubparser should mention something like this:I have a PR ready.
Linked PRs
pygen --helpforpythonsubparser #116992