Uh oh!
There was an error while loading. Please reload this page.
bpo-40939: Add the new grammar to the grammar specification documentation - #19969
Conversation
gvanrossum
left a comment
There was a problem hiding this comment.
I worry about some of the rather verbose comments in the grammar file, and the various error rules. Also there are some cases where lookaheads are essential (notably the way formal parameters are now parsed). And maybe the ordering and formatting of some of the rules could be better.
PS. Your initial comments still shows variables (a=...) but the script correctly erases those.
Uh oh!
There was an error while loading. Please reload this page.
I can try to eliminate alternatives if they start with "invalid_" but I think it will not be super resilient :(
Would you like to bring lookaheads back?
Not much we can do here with a custom lexer unless we touch the original file.
Yeah, I removed the variables in the last amend after I realized that we wanted to get rid of them. |
gvanrossum
commented
May 6, 2020
Plus, you'd have to eliminate both the alternatives and the rules. But these really do not deserve to be listed in the reference manual.
Only the ones that are significant -- and those in formal parameters are significant (without them,
Yeah, we can do that later. |
pablogsal
commented
May 6, 2020
Hmmm.... is there any obvious automatic way (using regular expressions) to detect the ones we want from the ones we don't want? Otherwise, we may need to maintain a copy of the grammar for displaying here and manually trim what we need. |
gvanrossum
commented
May 6, 2020
via email
I dunno. Let's think about this some more before rushing into it. (We'd
have to explain a big about PEG's ordering of alternatives too, to guide
people using this as a basis for anything.) |
lysnikolaou
commented
May 6, 2020
A heuristic that is currently 100% correct is that a lookahead is only used for optimisation and can be skipped if and only if it is a positive lookahead and it appears first in its alternative. Although this is currently correct, it seems like something that could very easily be invalidated in the future, so I don't know if it can be used in the script. |
willingc
left a comment
There was a problem hiding this comment.
Overall, I like the approach. There are a few places where color makes a line choppy and hard to follow and may make it more difficult to read than just black text.
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
gvanrossum
commented
Jul 26, 2020
I think I'm going to do something with this after all. Let's see if we can't make the highlighter also remove |
gvanrossum
commented
Jul 26, 2020
Okay, @lysnikolaou we may need your review because now it's both Pablo's and my code. |
pablogsal
commented
Jul 27, 2020
I think it makes sense to do the backport. What do you think @lysnikolaou ? |
gvanrossum
commented
Jul 27, 2020
Okay then @pablogsal what do you think of my version? |
willingc
left a comment
There was a problem hiding this comment.
LGTM. Thanks @pablogsal and @gvanrossum.
pablogsal
left a comment
There was a problem hiding this comment.
Okay then @pablogsal what do you think of my version?
I think is great :) I left a minor question, but feel free to ignore
Note: I cannot approve my own PR, so go ahead and merge!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
lysnikolaou
commented
Jul 27, 2020
I also think that backporting this to 3.9 makes sense. |
gvanrossum
commented
Jul 27, 2020
The new version I pushed has a longer intro in grammar.rst, both to explain (some of) what's omitted and to clarify the notation. It also restores most lookaheads, except for the positive ones that are purely optimizations (as a heuristic I use |
miss-islington
commented
Jul 27, 2020
Thanks @pablogsal for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
miss-islington
commented
Jul 27, 2020
Sorry, @pablogsal and @gvanrossum, I could not cleanly backport this to |
bedevere-bot
commented
Jul 27, 2020
GH-21641 is a backport of this pull request to the 3.9 branch. |
…ation (pythonGH-19969) (We censor the heck out of actions and some other stuff using a custom "highlighter".) Co-authored-by: Guido van Rossum <guido@python.org>
…ation (pythonGH-19969) (We censor the heck out of actions and some other stuff using a custom "highlighter".) Co-authored-by: Guido van Rossum <guido@python.org>
…ation (pythonGH-19969) (We censor the heck out of actions and some other stuff using a custom "highlighter".) Co-authored-by: Guido van Rossum <guido@python.org>
Example of how it looks like when using the new lexer:
https://bugs.python.org/issue40939