Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cut (~) operator in grammar unclear #143054

Open
Labels
docsDocumentation in the Doc dir topic-parser
@99991

Description

Python's Full Grammar specification and PEP 617 states:

~ ("cut"): commit to the current alternative and fail the rule (削除) even (削除ここまで) [NB: typo?] if this [alternative] fails to parse

It is not clear to me whether the cut applies to all alternatives in the current parse tree or only the latest alternative. Apparently, there are both types of cuts, as has been discussed in this issue, and I think (?) the conclusion by Guido was

Your first quote convinces me that cut is meant to act locally (which is how I have implemented it).

But the current grammar contains rules where the cut appears (to me) to be useless, for example:

assignment_expression:
 | NAME ':=' ~ expression 

If cut only acts locally on this single rule, wouldn't the rule be the same without the cut, since there are no alternatives to skip over in case expression fails to parse?

Either way, it would be nice if the documentation could be clarified with regard to which kind of cut is used in Python's grammar.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir topic-parser

    Projects

    Status

    Todo

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /