feat: add optional parse error locations#34
Open
cijiugechu wants to merge 6 commits intonodejs:mainfrom
Open
Conversation
Expose location-aware error reporting through new C and Rust entry points while preserving existing parse APIs. Also add CI coverage for error-location builds/features and tighten lexer EOF error reporting so location assertions are reliable.
Contributor
Author
|
I’m not very sure whether we should include both line/column and offset… Maybe it’d be better to provide one, and derive the other via calculation? |
Member
Yeah I don't think we need offset. Line/column should be sufficient enough afaik. |
anonrig
reviewed
Feb 27, 2026
Line/column are sufficient for error reporting; drop byte offsets across C and Rust APIs.
Expose error line/column via an optional out parameter on merve_parse_commonjs and remove the separate *_ex entrypoint. Always track locations and drop the CMake/Rust feature gates, updating docs, tests, and CI accordingly.
Drop the separate parse_commonjs_with_location entrypoint and make parse_commonjs return LocatedLexerError, so callers always get kind plus optional line/column.
Stop amalgamating merve_c.cpp into rust/deps/merve.cpp; vendor it as rust/deps/merve_c.cpp and compile both translation units. This keeps merve_error_loc helpers in the C API layer and matches the upstream file layout.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
line,column,offset) behindMERVE_ENABLE_ERROR_LOCATION/ Rusterror-locationfeature.merve_parse_commonjs_ex(..., merve_error_loc* out_err)while keeping existingmerve_parse_commonjsunchanged.parse_commonjs_with_location) andLocatedLexerError.UNTERMINATED_PAREN/UNTERMINATED_BRACEconsistently.Resolves #26 .