-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Addition of unrelated, unused parser rule to grammar causes different parsing results #3851
Comments
It looks like the similar bug was already reported: #2179 But it's about weird error instead of different parsing result. |
A random unused rule can cause FOLLOW sets to be different if I recall. Yeah, this grammar is pretty messed up. The issue relates to whether or not lookahead "falls off the edge" ever. Because of the tangle of rules (ref to |
Ah. i think it's the LL(1) analyzer. See comments on |
This is legal in Antlr. What does it mean?
I'm not sure whether it's a good idea to allow rules with EOF that
If it is allowed, it must be crystal clear what they mean. (I have an xpath that should flag such rules, but trxgrep has a bug that I now have to fix.) |
I think such code should be disallowed. |
True, but then you'd also want to disable combination of rules that have an EOF not at the end. Tricky imho... |
Yes, it looks like it also doesn't make sense. If it's encountered, the grammar should be rewritten to prevent potential weird behaviour and errors.
Agree with that. It's nonsense since the part after
At least not ending I suggest introducing the new errors together with warnings from #3626, they are processed in the same way. |
#3763 -- we could just take it out of the hands of users. :) |
Hi guys...any change to the secret sauce parsing algorithm would require me to fully understand it again. Not sure I am willing to dig deep enough. Changing the grammar semantics for EOF is less risky but would likely break backward compatibility. Also I've just never had a problem putting EOF on end of a start rule or leaving it off so I can parse partial phrases. |
I'd rather we focus on larger issues than grammar warnings that I might find too risky to merge. Maybe help with antlr4-lab? |
Some good news.
|
This is related to a SO question https://stackoverflow.com/q/73522066/4779853
The grammar is poorly written as an EOF-start rule, but that is irrelevant because parsing results should always be consistent when a completely unrelated, unused parser rule is added or deleted. Therefore there is something wrong in the runtime.
Input
H C D C C D
Commented rule
p
causes parser to work one way, uncomment rulep
works another way. It is illogical for a rule that is unused to influence a parse because it's never used in a derivation. It must be investigated.The text was updated successfully, but these errors were encountered: