-
-
Notifications
You must be signed in to change notification settings - Fork 0
add state field to ParseError #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 adds a state
field to ParseError
structures across both deterministic and nondeterministic parsers. The change improves error reporting by providing state information where parsing errors occur, making debugging and error handling more informative.
Key Changes:
- Refactored
ParseError
to be generic overTerm
,Location
, andReduceActionError
types instead of generic overDataStack
- Added state information to all error variants and contexts
- Updated type aliases throughout the codebase to use the new generic parameters
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
rusty_lr_core/src/parser/deterministic/error.rs |
Restructures deterministic ParseError to use separate error structs with state fields |
rusty_lr_core/src/parser/nondeterministic/error.rs |
Updates nondeterministic ParseError to include states field and simplifies generics |
rusty_lr_core/src/parser/deterministic/context.rs |
Updates context methods to use new error types and includes state information in errors |
rusty_lr_core/src/parser/nondeterministic/context.rs |
Adds state tracking methods and updates error handling to include state information |
rusty_lr_parser/src/emit.rs |
Updates code generation to emit new generic type aliases for ParseError |
Multiple generated files | Updates type aliases to use new generic parameters instead of DataStack |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
ParseError::ReduceAction(err) => { | ||
write!( | ||
f, | ||
"ReduceAction: {}, State: {}\nSource: {}", |
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newline character \\n
in the error message format string creates inconsistent formatting compared to other error messages. Consider using a consistent separator like '; ' instead.
"ReduceAction: {}, State: {}\nSource: {}", | |
"ReduceAction: {}, State: {}; Source: {}", |
Copilot uses AI. Check for mistakes.
/// States when the error occurred (from every diverged paths) | ||
pub(crate) states: Vec<usize>, |
Copilot
AI
Sep 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has a grammatical error. It should be 'from every diverged path' (singular) or 'from all diverged paths' instead of 'from every diverged paths'.
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.