Repository navigation
fix!: keep each run of string literal text in one fragment - #94
Merged
Merged
Conversation
The external scanner stopped string and text block fragments after 256 characters, so long literals were split into several fragments. Error recovery no longer reads string fragments, so the bound is unneeded. Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The external scanner stopped every string and text block fragment after 256 characters (
MAX_FRAGMENT_LENGTH), soclass A { String s = "<700 × a>"; }yielded threestring_fragmentnodes, and a 440-character literal yielded[17–273]and[273–439]. Other WillBooster grammars (JavaScript, C#, Go) yield one fragment per run of text. The bound was added in #83 to stop error recovery from scanning the rest of a malformed record header as one long fragment; since #93, the scanner reads no string fragment during error recovery, so the bound only splits valid literals.Requirements
string_fragment(onemultiline_string_fragmentin text blocks); escape sequences and other legitimate splits stay as they arefix!:commit so that it is released as a new major versionCustomer Summary
A long string literal or text block now has one fragment node per run of plain text instead of one every 256 characters. This changes the tree shape, so it needs a major release.
Technical Summary
scan_fragment_charactersinsrc/scanner.cnow reads up to the next quote, backslash, or (outside text blocks) line terminator without a length bound. It served both string literals and text blocks, including text block fragments that start with one or two quotes. No other token is capped: character literals are lexed by the generated lexer as one token, and the scanner's comment, whitespace, and identifier scans have no length bound (the identifier's fixed spelling buffer only disables the keyword comparison once it overflows).src/parser.cchanged only because the generation profile includes the new corpus entry.Testing
bun run verifypassed.bun wb teston the performance, corpus, string literal, text block escape, error location, real-world example, Unicode literal, and string template tests passed (113 tests), including the existing linear-time check for malformed record components that motivated the bound.long string literals(342-character runs in a string, around an escape, in a multi-line text block, and after a leading quote in a text block); it fails with the previous scanner.script/tree-sitter parse --timeon 0.18 MB, 1.8 MB, and 18 MB inputs took 1.7 ms, 12 ms, and 119 ms.