Visitar URL original
Tools/peg_generator/pegen produces invalid python in parse.py · Issue #104366 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20260609171419/https://github.com/python/cpython/issues/104366
Skip to content
/ cpython Public

Tools/peg_generator/pegen produces invalid python in parse.py #104366

@noahbkim

Description

@noahbkim

Bug report

Following the [https://devguide.python.org/internals/parser/#making-experiments](CPython devguide) to create a Python grammar parser (parse.py) produces invalid Python:

$ make -j
$ cd Tools/peg_generator
$ ../../python -m pegen -v python ../../Grammar/python.gram
  File "/usr/scratch/noah/python/Tools/peg_generator/./parse.py", line 34
    return _PyAST_Interactive ( a , p -> arena )
                                      ^^
SyntaxError: invalid syntax

Notably, the trailer gets copied in wholesale (definitely not gonna run):

void *
_PyPegen_parse(Parser *p)
{
    // Initialize keywords
    p->keywords = reserved_keywords;
    p->n_keyword_lists = n_keyword_lists;
    p->soft_keywords = soft_keywords;
    ...

Your environment

This appears to be environment agnostic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions