Skip to content

python.lark failed to pare special forms of with_stmt #1570

@Joxos

Description

@Joxos

Describe the bug

python.lark failed to pare special forms of with_stmt

To Reproduce

I'm using the newest python.lark in grammar/ and tried to parse:

with (open("a.txt") as a,
      open("b.txt") as b):
    pass

which is valid in Python 3.13. However, the grammar in python.lark is:

with_stmt: "with" with_items ":" suite
with_items: with_item ("," with_item)*
with_item: test ["as" name]

It seems like this file doesn't realized such grammar. When using lark to parse the codes it raises something like:
lark.exceptions.UnexpectedToken: Unexpected token Token('AS', 'as') at line 291, column 21.

Though this grammar file can parse this feature in another form:

with open("a.txt") as a, open("b.txt") as b):
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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