Skip to content

Fix missing IELR splits for nested rules - #871

Merged
ydah merged 1 commit into
masterfrom
fix/ielr-nested-lookahead-contributions
Nov 12, 2026
Merged

ydah merged 1 commit into
masterfrom
fix/ielr-nested-lookahead-contributions

Conversation

@ydah

@ydah ydah commented Nov 12, 2026

Copy link
Copy Markdown
Member

State#annotate_predecessor only propagated conditional contributions through predecessor kernels on the transition lane. For an item one symbol into its rule, lookaheads can come from enclosing rules whose kernels are outside that lane. Dropping those contributions prevented necessary IELR state splitting and made the generated parser reject valid inputs.

Propagate all conditional kernels returned by lhs_contributions for these items, following Bison's predecessor-annotation calculation (https://github.com/akimd/bison/blob/v3.8.2/src/AnnotationList.c#L249-L273).

For example:

%define lr.type ielr
%%
start: 'a' left 'd' | 'a' right 'e'
     | 'b' left 'e' | 'b' right 'd';
left: 'x' left_tail;
right: 'x' right_tail;
left_tail: 'y';
right_tail: 'y';

Previously this produced 17 states with a reduce/reduce conflict and rejected axye and bxyd. It now produces 19 states without conflicts and accepts all four valid inputs, matching Bison 3.8.2. Add regression coverage for contributions outside the transition lane, nested tails of one to three symbols, and the generated parser.

@ydah
ydah merged commit 804bc5f into master Nov 12, 2026
45 checks passed
@ydah
ydah deleted the fix/ielr-nested-lookahead-contributions branch November 12, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant