add state field to ParseError#35
Conversation
There was a problem hiding this comment.
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
ParseErrorto be generic overTerm,Location, andReduceActionErrortypes 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: {}", |
There was a problem hiding this comment.
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: {}", |
| /// States when the error occurred (from every diverged paths) | ||
| pub(crate) states: Vec<usize>, |
There was a problem hiding this comment.
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'.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.