Skip to content

Avoid stack overflow when generating IELR parsers for long rules - #868

Merged
ydah merged 1 commit into
masterfrom
fix/ielr-long-rule-lookaheads
Nov 11, 2026
Merged

ydah merged 1 commit into
masterfrom
fix/ielr-long-rule-lookaheads

Conversation

@ydah

@ydah ydah commented Nov 11, 2026

Copy link
Copy Markdown
Member

State#item_lookahead_set recursively visits predecessor states. A long right-hand side can exhaust Ruby's stack during IELR generation. Expanding the shared right-hand sides in multiple_predecessor_lookaheads.y to 3,000 symbols raises SystemStackError, while LALR generation succeeds.

Use an explicit stack to visit predecessor states before completing their lookahead sets. Preserve the depth-first traversal order and the handling of states whose lookaheads are still being computed.

@ydah
ydah merged commit 7033b73 into master Nov 11, 2026
45 checks passed
@ydah
ydah deleted the fix/ielr-long-rule-lookaheads branch November 11, 2026 07:20
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