Skip to content

feat: add optional parse error locations#34

Open
cijiugechu wants to merge 6 commits intonodejs:mainfrom
cijiugechu:error-location
Open

feat: add optional parse error locations#34
cijiugechu wants to merge 6 commits intonodejs:mainfrom
cijiugechu:error-location

Conversation

@cijiugechu
Copy link
Contributor

  • Add optional parse error location support (line, column, offset) behind MERVE_ENABLE_ERROR_LOCATION / Rust error-location feature.
  • Add C API merve_parse_commonjs_ex(..., merve_error_loc* out_err) while keeping existing merve_parse_commonjs unchanged.
  • Add Rust location-aware API (parse_commonjs_with_location) and LocatedLexerError.
  • Fix EOF unmatched token errors to report UNTERMINATED_PAREN / UNTERMINATED_BRACE consistently.

Resolves #26 .

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.
@cijiugechu
Copy link
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?

@anonrig
Copy link
Member

anonrig commented Feb 27, 2026

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?

Yeah I don't think we need offset. Line/column should be sufficient enough afaik.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include location of errors

2 participants