You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add structured ParseError with O(log n) position lookup (#274)
Replace the stringly-typed parse error and its per-error full-input
rescan with a typed *ParseError that carries the byte offset, 1-based
line/column, the offending token, and the expected token kinds/keyword.
- error.go: ParseError type; Error() renders the line:col message plus a
caret, matching the previous CLI presentation.
- source.go: lineStarts type maps a byte offset to a 1-based line/column
via binary search over line-start offsets, built once on the first
error instead of rescanning the input every time.
- parser_common.go: expectTokenKind/expectKeyword capture position and
expected tokens at the failure site; wrapError finalizes any error
into a *ParseError, leaving the long tail of fmt.Errorf sites working
via the Msg field.
Note: line/column are now 1-based (previously 0-based) and error
messages were reworded; callers can now errors.As(err, &ParseError{}).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments