Skip to content

gh-153569: Add tokenizer source and cursor primitives#153587

Open
pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:gh-153569-tokenizer-offset-api
Open

gh-153569: Add tokenizer source and cursor primitives#153587
pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:gh-153569-tokenizer-offset-api

Conversation

@pablogsal

@pablogsal pablogsal commented Jul 11, 2026

Copy link
Copy Markdown
Member

Add the decoded source store, offset spans, and an offset-only cursor as the foundation for moving tokenizer state away from buffer pointers.

@pablogsal pablogsal marked this pull request as ready for review July 11, 2026 19:26
@pablogsal pablogsal marked this pull request as draft July 11, 2026 19:27
@pablogsal pablogsal force-pushed the gh-153569-tokenizer-offset-api branch from bce3caa to 2682fe5 Compare July 11, 2026 19:38
@pablogsal pablogsal changed the title gh-153569: Base the tokenizer API on source offsets gh-153569: Add tokenizer source and cursor primitives Jul 11, 2026
@pablogsal pablogsal marked this pull request as ready for review July 11, 2026 20:37
@pablogsal pablogsal force-pushed the gh-153569-tokenizer-offset-api branch from 2682fe5 to 1bf43aa Compare July 11, 2026 21:15
Comment thread Parser/tokenizer/source.c
Comment on lines +237 to +239
while (current < lineno) {
const char *newline = memchr(
source->bytes + start, '\n', source->len - start);

@maurycy maurycy Jul 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pablogsal Do you think this could use a helper? Similar new line search logic seems to be in four places:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants