Skip to content

feat: add createLexerAndParser helper for unified error listening#87

Merged
nawforce merged 1 commit into
mainfrom
feat/issue-83-error-listener-helper
Apr 22, 2026
Merged

feat: add createLexerAndParser helper for unified error listening#87
nawforce merged 1 commit into
mainfrom
feat/issue-83-error-listener-helper

Conversation

@kjonescertinia

@kjonescertinia kjonescertinia commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds ApexParserFactory.createLexerAndParser(source, listener) to both the TS and Java packages. The listener is required and wired to both the lexer and the parser, so a single ApexErrorListener instance captures lexer-level errors (e.g. invalid string escapes) alongside parser errors.
  • Widens the TS ApexErrorListener base class generic to Token | number so one listener instance can be attached to both recognizers.
  • Updates README with a "Capturing syntax errors" section showing the recommended pattern in both languages.

Closes #83

Test plan

  • mvn test (jvm) — 73 tests pass
  • npm test (npm) — 74 tests pass
  • npx prettier --check and npx eslint on changed files — clean
  • CI green

Adds a new ApexParserFactory.createLexerAndParser(source, listener)
helper in both the TS and Java packages. It attaches the required
ApexErrorListener to both the lexer and the parser so a single
listener instance captures lexer-level errors (e.g. invalid string
escapes) as well as parser errors.

The TS ApexErrorListener base class generic is widened to
`Token | number` so one listener can be attached to both recognizers.

Closes #83
@kjonescertinia kjonescertinia requested a review from nawforce April 22, 2026 09:45
@nawforce

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@nawforce nawforce merged commit 5f8897f into main Apr 22, 2026
1 check passed
@nawforce nawforce deleted the feat/issue-83-error-listener-helper branch April 22, 2026 12:48
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.

Document attaching error listener to both lexer and parser

2 participants