-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143054: Disallow non-top-level Cut for now #143622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The behaviour of Cut in nested parentheses, Repeat, Opt, and similar is somewhat chaotic. Apparently even the academic papers on PEG aren't as clear as they could be. And it doesn't really matter. Python only uses top-level cuts. When that changes, we can clarify as much as necessary (and even change the implementation to make sense for what we'll need). Document that this is deliberately unspecified, and add a test to make sure any decision is deliberate, tested and documented.
pablogsal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM! I feel you regarding how chaotic this is and how unintuitive the consequences are so I think adding these tests and the docs is perfect and improves the situation. Thanks a lot!
I will recommend to wait for @lysnikolaou to take a look if possible
lysnikolaou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! This certainly is an improvement over leaving stuff undocumented. I doubt there'll be the need for non-top-level cuts anytime soon anyway.
|
Thank you for the reviews -- and for pegen itself! |
|
Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
The behaviour of Cut in nested parentheses, Repeat, Opt, and similar is somewhat chaotic. Apparently even the academic papers on PEG aren't as clear as they could be. And it doesn't really matter. Python only uses top-level cuts. When that changes, we can clarify as much as necessary (and even change the implementation to make sense for what we'll need). Document that this is deliberately unspecified, and add a test to make sure any decision is deliberate, tested and documented. (cherry picked from commit f0a0467) Co-authored-by: Petr Viktorin <encukou@gmail.com>
|
GH-143790 is a backport of this pull request to the 3.14 branch. |
The behaviour of Cut in nested parentheses, Repeat, Opt, and similar is somewhat chaotic. Apparently even the academic papers on PEG aren't as clear as they could be.
And it doesn't really matter. Python only uses top-level cuts. When/if that changes, we can clarify as much as necessary (and even change the implementation to make sense for what we'll need).
For now, document that this is deliberately unspecified, and add a test to make sure any decision is deliberate, tested and documented.
📚 Documentation preview 📚: https://cpython-previews--143622.org.readthedocs.build/