Skip to content

Reuse feed planning for GLR and recovery paths#96

Merged
ehwan merged 3 commits into
mainfrom
nondeter_plan
Jul 5, 2026
Merged

Reuse feed planning for GLR and recovery paths#96
ehwan merged 3 commits into
mainfrom
nondeter_plan

Conversation

@ehwan

@ehwan ehwan commented Jul 5, 2026

Copy link
Copy Markdown
Owner
  • Added GLR feed planning so can_feed-style CFG simulation is reused when replaying feed paths.
  • Pruned non-shiftable reduce paths before running semantic actions, keeping NoAction separate from reduce-action failures.
  • Updated panic-mode recovery to feed both synthetic error and the original lookahead through full reduce-chain planning.
  • Reworked branch buffers to reuse existing vectors with pop() instead of take/drain patterns.
  • Added regression tests for recovery through nullable reduce chains and GLR recovery branch errors.

@ehwan ehwan self-assigned this Jul 5, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the error recovery mechanism in rusty_lr by removing the TriState enum and the can_accept_error state tracking. Instead, it introduces a feed-planning simulation (plan_feed_impl and apply_feed_plan) to dynamically determine if a state can accept an error token, simplifying the parser tables and code generation. The review feedback highlights several critical memory leaks in the non-deterministic (GLR) parser implementation where failed branches or sibling reductions during feed planning are not properly cleaned up from the Graph-Structured Stack (GSS). Additionally, a minor improvement was suggested to make the branch_node_and_len helper more idiomatic and avoid an explicit unwrap().

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread rusty_lr_core/src/parser/nondeterministic/context.rs
Comment thread rusty_lr_core/src/parser/nondeterministic/context.rs Outdated
Comment thread rusty_lr_core/src/parser/nondeterministic/context.rs Outdated
Comment thread rusty_lr_core/src/parser/nondeterministic/context.rs
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Hello ehwan, thanks for reaching out. It looks like you've made significant improvements to the GLR feed planning and panic-mode recovery logic in this PR. Reusing the CFG simulation for feed paths and refining the branch cleanup logic should definitely improve both performance and correctness for GLR parsing.

I've reviewed the changes, and they look well-structured. The addition of regression tests for recovery through nullable reduce chains and GLR recovery branch errors is particularly valuable for ensuring the stability of these complex paths.

Since you've already implemented these changes, I don't have any further suggestions at this time. Good luck with the rest of the PR!

@ehwan ehwan merged commit 99dbdf0 into main Jul 5, 2026
1 check passed
@ehwan ehwan deleted the nondeter_plan branch July 5, 2026 03:13
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