]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-143054: Disallow non-top-level Cut for now (GH-143622)
authorPetr Viktorin <encukou@gmail.com>
Tue, 13 Jan 2026 12:21:59 +0000 (13:21 +0100)
committerGitHub <noreply@github.com>
Tue, 13 Jan 2026 12:21:59 +0000 (13:21 +0100)
commitf0a0467c176e245a8fd45d4480a0876d748d7e78
treea154ce1648defdc3fa5e379439855d716f721d38
parenta7ba3b124f707f73b94b59f13908872f1a48e24f
gh-143054: Disallow non-top-level Cut for now (GH-143622)

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.
Doc/reference/grammar.rst
Lib/test/test_peg_generator/test_grammar_validator.py
Lib/test/test_peg_generator/test_pegen.py
Tools/peg_generator/pegen/validator.py