Skip to content

"python3 -m pegen python" generates a Python parser that contains invalid code #133560

@alexprengere

Description

@alexprengere

Bug report

Bug description:

I am currently experimenting with the cpython parser/tokenizer, following the parser documentation:

$ python3.14 -m pegen python  ../../Grammar/python.gram

This generates a parser.py file, that contains remnants of C code:

# line 34
return _PyAST_FunctionType ( a , b , p -> arena )

# end of file
void *
_PyPegen_parse(Parser *p)
{
    // Initialize keywords
    p->keywords = reserved_keywords;
    p->n_keyword_lists = n_keyword_lists;
    p->soft_keywords = soft_keywords;

    // Run parser

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions