]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-118235: Move RAISE_SYNTAX_ERROR actions to invalid rules and make sure they stay...
authorPetr Viktorin <encukou@gmail.com>
Thu, 30 May 2024 07:27:32 +0000 (09:27 +0200)
committerGitHub <noreply@github.com>
Thu, 30 May 2024 07:27:32 +0000 (09:27 +0200)
commit48f21b3631eb20871fe234e9714b19aa76cf3a49
treebcd17f5b614f11fa18fa92dd2ce1865fdf96af34
parenta5fef800d31648d19cecc240a2fa0dc71371753e
gh-118235: Move RAISE_SYNTAX_ERROR actions to invalid rules and make sure they stay there (GH-119731)

The Full Grammar specification in the docs omits rule actions, so grammar rules that raise a syntax error looked like valid syntax.
This was solved in ef940de by hiding those rules in the custom syntax highlighter.

This moves all syntax-error alternatives to invalid rules, adds a validator that ensures that actions containing RAISE_SYNTAX_ERROR are in invalid rules, and reverts the syntax highlighter hack.
Doc/tools/extensions/peg_highlight.py
Grammar/python.gram
Lib/test/test_peg_generator/test_grammar_validator.py
Parser/parser.c
Tools/peg_generator/pegen/validator.py