Skip to content

Let the lexer start from a given position - #160

Merged
chrisjenkinson merged 1 commit into
masterfrom
claude/lexer-start-position
Sep 25, 2026
Merged

chrisjenkinson merged 1 commit into
masterfrom
claude/lexer-start-position

Conversation

@chrisjenkinson

@chrisjenkinson chrisjenkinson commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Parsers for formats like Markdown usually lex a document twice: once for blocks, then again over each paragraph's text for inline syntax. The second pass always started at line 1, column 1, so its token positions and error messages referred to the paragraph rather than the document.

tokenise() now takes an optional TokenPosition for where the text starts, and Cursor takes a starting line and column. Positions in the second pass then match the original document. Without the argument, lexing starts at line 1, column 1 as before, so existing callers are unaffected.

@chrisjenkinson
chrisjenkinson merged commit 58e5c31 into master Sep 25, 2026
4 checks passed
@chrisjenkinson
chrisjenkinson deleted the claude/lexer-start-position branch September 25, 2026 10:37
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.

1 participant