Skip to content

fixed eof was not popped on pop_start()#25

Merged
ehwan merged 1 commit into
mainfrom
eof_pop
Aug 20, 2025
Merged

fixed eof was not popped on pop_start()#25
ehwan merged 1 commit into
mainfrom
eof_pop

Conversation

@ehwan

@ehwan ehwan commented Aug 20, 2025

Copy link
Copy Markdown
Owner

No description provided.

@ehwan
ehwan requested a review from Copilot August 20, 2025 14:21
@ehwan
ehwan merged commit 3c96cc9 into main Aug 20, 2025
1 check passed
@ehwan
ehwan deleted the eof_pop branch August 20, 2025 14:22

Copilot AI 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.

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

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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);
}

Copilot uses AI. Check for mistakes.

// 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

Copilot AI Aug 20, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
self.data_stack.pop(); // pop eof
let popped = self.data_stack.pop();
if popped != Some(parser.eof()) {
return Err(ParseError::StackCorrupted);
}

Copilot uses AI. Check for mistakes.
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.

2 participants