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
The lane table algorithm is technically incorrect, is this an issue ? #768
Comments
Is this related to #391? Note the comment with the minimized grammar #391 (comment) |
I've looked at this grammar on grammophone and I don't quite understand what's so special about it that the lane table algorithm rejects it? |
They look similar, but there is in fact a key difference. In summary, I believe the lane table algorithm should be able to handle the grammar you linked, but I think it has a fundamental limitation which prevents it from accepting the grammar I proposed. Precisions(To be clear: this is based on my understanding of the algorithm, which is very close (if not the same) to nikomatsakis (based on this comment)) Roughly speaking, the lane table algorithm works by identifying reduce/reduce conflicts, and then:
Right ? BUT: this is not correct! Indeed, the two sides of a conflict can come from the same state, but different configurations. This is what my example shows: we have a conflict in
In this case, the algorithm will consider state 0 to be conflicting, and unsplittable, but this isn't quite true: the real conflict only manifest itself in Now, we could imagine that this could be fixed, by saying that we associate lookaheads to a pair of state + configuration (instead of just a state). I don't really remember the exact details, but I tried to do this and failed miserably: the resulting algorithm explodes in complexity. Hopefully this is understandable 😅 |
Ah, thanks for the detailed explanation! Happy to keep this issue open then. |
The following grammar is rejected by lalrpop (because it is rejected by the lane table algorithm), but it is in fact LR(1):
Details:
The LALR tables look like this (only representing the states that interest us):Then the lane table algorithm refuses to split state 3, resulting in a reduce/reduce conflict.
Note that this particular pattern seems exceedingly rare, so it may not be an issue: I cannot really imagine a real life grammar that would exhibit this error. But you never know...
The text was updated successfully, but these errors were encountered: