Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the EOF token was not being properly popped from the data stack in the pop_start() operation. The fix ensures that both deterministic and nondeterministic parser contexts correctly remove the EOF token before extracting the start symbol.
- Adds explicit EOF token popping in both parser context implementations
- Updates the package version from 3.35.0 to 3.35.1 to reflect the bug fix
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| rusty_lr_core/src/parser/nondeterministic/context.rs | Adds EOF token popping before calling pop_start() |
| rusty_lr_core/src/parser/deterministic/context.rs | Adds EOF token popping before calling pop_start() |
| rusty_lr_core/Cargo.toml | Bumps version to 3.35.1 for the bug fix release |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| Ok(nodes.into_iter().map(move |eof_node| { | ||
| let node = self.pop(eof_node).unwrap(); | ||
| // Since <EOF> does not have ruletype, no need to pop | ||
| self.nodes_pool[node].data_stack.pop(); // pop eof |
There was a problem hiding this comment.
The pop() call should verify that the popped token is indeed EOF. Without validation, this could silently corrupt the stack if the expected EOF token is not present.
| self.nodes_pool[node].data_stack.pop(); // pop eof | |
| let popped = self.nodes_pool[node].data_stack.pop(); // pop eof | |
| if popped != Some(parser.eof()) { | |
| panic!("Expected EOF token on top of the stack, found {:?}", popped); | |
| } |
|
|
||
| // data_stack must be <Start> <EOF> in this point | ||
| // Since <EOF> does not have ruletype, no need to pop | ||
| self.data_stack.pop(); // pop eof |
There was a problem hiding this comment.
The pop() call should verify that the popped token is indeed EOF. Without validation, this could silently corrupt the stack if the expected EOF token is not present.
| self.data_stack.pop(); // pop eof | |
| let popped = self.data_stack.pop(); | |
| if popped != Some(parser.eof()) { | |
| return Err(ParseError::StackCorrupted); | |
| } |
No description provided.