Skip to content

gh-153569: finish tokenizer offsets and the opaque API cutover - #156654

Draft
pablogsal wants to merge 12 commits into
python:mainfrom
pablogsal:gh-153569-tokenizer-source-ftstring-clean
Draft

gh-153569: finish tokenizer offsets and the opaque API cutover#156654
pablogsal wants to merge 12 commits into
python:mainfrom
pablogsal:gh-153569-tokenizer-source-ftstring-clean

Conversation

@pablogsal

@pablogsal pablogsal commented Aug 30, 2026

Copy link
Copy Markdown
Member

Complete the tokenizer API cutover after #156484.

Represent persistent scanner positions as offsets into decoded source storage, removing pointer save/restore during buffer growth. Give errors explicit reporting locations and source text, independent of the scanner cursor, including the context needed for incomplete-input diagnostics.

Make tok_state opaque to pegen and _tokenize. Consumers use token, source-view, diagnostic, configuration, and interactive-input operations through tokenizer.h, with no dependency on lexer layout or live formatted-string frames.

Return each token with its final kind, span, source locations, and raw-string context. Token views use that result directly, and reusing a token releases its previous metadata. Remove the unused cursor, source line index, and obsolete view APIs as part of this cutover.

@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-source-ftstring-clean branch 4 times, most recently from b2bc8d1 to d9b2b16 Compare August 30, 2026 13:16
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-source-ftstring-clean branch 4 times, most recently from 9ce1fd9 to afd9d72 Compare September 5, 2026 17:46
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-source-ftstring-clean branch from afd9d72 to f72cb2b Compare September 5, 2026 19:17
@pablogsal pablogsal changed the title gh-153569: simplify tokenizer source and formatted-string state gh-153569: finish tokenizer offsets, diagnostics, and opaque API Sep 5, 2026
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-source-ftstring-clean branch 3 times, most recently from 7e5d82c to 9240806 Compare September 6, 2026 20:57
@pablogsal pablogsal changed the title gh-153569: finish tokenizer offsets, diagnostics, and opaque API gh-153569: finish tokenizer offsets and the opaque API cutover Sep 6, 2026
Formatted-string expressions and comments can outlive the buffer window where
scanning began. Pointer boundaries require buffer relocation to repair tokenizer
state.

Record logical source ranges instead. Retain the active input window while a
formatted string is open, give each mode ownership of its comment spans, and
materialize text through shared span views.
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-source-ftstring-clean branch from 9240806 to fefec39 Compare September 6, 2026 21:37
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-source-ftstring-clean branch from fefec39 to a497ca0 Compare September 6, 2026 22:30
@pablogsal
pablogsal force-pushed the gh-153569-tokenizer-source-ftstring-clean branch from a497ca0 to 0eb2ce0 Compare September 6, 2026 23:21
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.

1 participant