Skip to content

pegen --help should mention that it needs different grammar files  #116991

@sobolevn

Description

@sobolevn

Bug report

I've got contacted by a user who tried to generate a pure-python parser with pegen from https://github.com/python/cpython/blob/main/Grammar/python.gram

It was failing with

python -m pegen -o parser.py cpython\Grammar\python.gram
  File "<unknown>", line 1
    _PyAST_Interactive ( a , p -> arena )
                               ^^
SyntaxError: invalid syntax

I think that --help for python subparser should mention something like this:

» 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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions