emit-portable: windowed relexing for template lexers (S5b, #57)#67
Merged
Conversation
… S5b). Co-authored-by: Cursor <cursoragent@cursor.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.
Summary
Slice 5b of #57 (portable incremental
edit). Completes windowed-relexing coverage by extending it to template-literal lexers and the combined regex-context + template case (templatejs, javascript):AlignMetarecordstd— the stack depth after emission — and both restart anchors and resync points are restricted totd == 0tokens, where the stack is provably empty. An edit inside a template therefore anchors before its head and relexes the whole literal, resyncing after the tail.td == 0and an empty live stack; adopted suffix tokens inherit their recordedtdunchanged (a suffix may containtd > 0tokens from a later template, exercised by a dedicated gate scenario).fullRelex(+1 hole-edit scenario), templatejs gains 6 scenarios (hole edit, nested braces in hole,${deletion collapsing head/hole/tail into one token, middle-text edit proving deferred resync, large doc withrelexed ≤ 15, suffix adoption across a second template).Validation
node test/portable-targets.ts— 34 scenarios (calc 8, javascript 6, regexjs 6, templatejs 6, envspec 8) × 3 targets, allstreamEqtrue; large-docrelexed2–4node test/check.ts emit-parity— 5/5;node test/newline-mode.ts— 29/29;npx tsc --noEmit— cleantd == 0anchor walk-back fails the middle-edit scenario (anchor lands on a head, relexes with an empty stack, stream diverges); forcing adopted-suffixtdto 0 fails the second-template scenario via thestreamEqtdcomparison — both reverted before commit$without{(stays literal), regex+template combined edit, tagged-template edit, two-batch chain re-anchoring on inherited tokens — all parity with oracle-derived expectations; edits that create unterminated templates fail identically to fresh parses on the windowed path