Repository navigation
Fix missing IELR splits for multi-symbol reductions - #867
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
State#item_lookahead_setused only the first predecessor's goto follows for an item one symbol into its rule. Lookaheads from other incoming paths were lost, which could prevent necessary IELR state splitting and make the generated parser reject valid inputs.For example:
Previously this produced 15 states with a reduce/reduce conflict and rejected axye and bxyd. It now produces 17 states without conflicts and accepts all four valid inputs, matching Bison 3.8.2.
Union the goto-follow sets from every predecessor, as in Bison's lookahead calculation (https://github.com/akimd/bison/blob/v3.8.2/src/ielr.c#L412-L423). Add regression coverage for predecessor order, shared right-hand sides of one to three symbols, and acceptance by the generated parser.
Correcting the initial lookaheads can also change splitting for existing grammars. The
always_contributionsfixture now produces 17 states and five S/R conflicts instead of 15 states and four; its R/R count remains one. All 32,767 tested strings overaandbagree between the old parser, the fixed parser, and Bison. Update the fixture's state/conflict expectations accordingly. State minimality is not addressed here.