Skip to content

Resolve IELR annotation conflicts in rule order - #880

Open
ydah wants to merge 1 commit into
masterfrom
fix/resolve-ielr-annotation-actions-in-rule-order
Open

ydah wants to merge 1 commit into
masterfrom
fix/resolve-ielr-annotation-actions-in-rule-order

Conversation

@ydah

@ydah ydah commented Nov 24, 2026

Copy link
Copy Markdown
Member

IELR uses annotations to decide whether two states can share a parser action. When a shift conflicts with multiple reductions, the annotation could keep comparing the shift after discarding it, or treat a %nonassoc error as a surviving reduction. In the regression grammar this merged two states: x+ should be a syntax error, but ax+ should be accepted.

Compare reductions in grammar rule order, as parser table construction does. Stop when a reduction discards the shift. Return an empty action set for an explicit nonassociative error so state compatibility can distinguish it from a missing contribution.

Regression grammar Before After Bison 3.8.2 IELR
ax+ Syntax error Accepted Accepted
x+ Syntax error Syntax error Syntax error
States 16 17 17

The generated parser agrees with Bison IELR and canonical LR on all 9,841 inputs over the grammar's three tokens through length eight. Across 6,144 combinations of precedence, associativity and action order, mismatches between annotations and parser table conflict resolution fall from 1,992 to zero.

Measured on Ruby 4.0.9, arm64 macOS, with YJIT disabled. Each mode used 12 paired runs of master (5d79308) and this change (d12d419) in balanced, randomized order.

Ruby parse.y (IELR) Before After
CLI elapsed time 1.471 s 1.486 s
Warm CPU time 1.308 s 1.295 s
Warm allocated objects 3,862,629 3,771,554
CLI peak RSS 158.4 MiB 159.0 MiB

The paired change in CLI time on Ruby's parse.y was +1.07% (bootstrap 95% CI −0.24% to +2.57%). Warm allocations fell by 2.36%. On a synthetic grammar with many state splits, CLI time rose by 4.68% in the first block and 2.49% in a repeat (repeat 95% CI −0.13% to +5.41%).

This branch has not been deployed

No deployments
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