-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Full Grammar specification lists invalid syntax #118235
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
Comments
…ythonGH-118237) (cherry picked from commit ef940de) Co-authored-by: Petr Viktorin <[email protected]>
…validate Add a validator that makes sure RAISE_SYNTAX_ERROR only appears in invalid rules. This looks at the action text, as a string. Move all such actions to invalid rules. This works for two of them, but not the type_param rules, where the SyntaxError that ends up being raised is the one from &&'(' in the function definition.
@pablogsal said on #118237 (comment):
I tried to do this, but I got stuck moving the Whenever you have time, could you look at main...encukou:cpython:invalid-grammar and give me a hint at what I'm doing wrong? That PR fails with:
(No rush at all.) |
I just found the discussion about that issue in #118091; I'll read it when I get back to grammar-in-docs. |
… spec (pythonGH-118237)" This reverts commit ef940de. The highlighter change is no longer needed, since all RAISE_SYNTAX_ERROR actions are in invalid rules.
…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.
… make sure they stay there (pythonGH-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.
… make sure they stay there (pythonGH-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.
Uh oh!
There was an error while loading. Please reload this page.
The Full Grammar specification lists these production rules:
However, some of the alternatives are actually invalid syntax: in the grammar file we can find that they're handled by raising a syntax error. For example:
These should be hidden in the same way as other invalid rules.
Linked PRs
The text was updated successfully, but these errors were encountered: