Enhance Parser Errors with Source Location Context #7
Labels
No labels
Epic
GHA
Release
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
major
question
rust
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
NiXTheDev/Ogex#7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal: Provide rich error messages with line/column information using spans.
After adding spans to tokens (Issue #5), the parser should produce
SpannedErrorinstances instead of plainParseError.Current State:
parser::parsereturnsResult<Expr, ParseError>.ParseErrorlacks location info.Proposed Change:
parseto returnResult<Expr, SpannedError>.SpannedErrorusing the span of the offending token or the current position.Regex::new,transpile) to handleSpannedError.Example Error Display:
Implementation Steps:
error.rsto possibly include multiple spans for context (e.g., for duplicate names, include the first definition's span).parser.rs, track the current token's span and use it when constructing errors.RegexErrorto includeSpannedErrorvariant or integrate spans into existing variants.