-
Notifications
You must be signed in to change notification settings - Fork 41
Optimized compilation of string patterns #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
chengluyu
wants to merge
34
commits into
hkust-taco:hkmc2
Choose a base branch
from
chengluyu:compiled-string-patterns
base: hkmc2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
105fa99
Compile string patterns with automata
chengluyu 592c813
Shrink compiled string automata tables
chengluyu e2fa0f7
Merge branch 'hkmc2' into compiled-string-patterns
LPTK a4f702f
Add opt-in size measurement for compiled string pattern tables
chengluyu eb7a728
Fuse op-carrying single-edge states in string automata
chengluyu 4ab837a
Minimize the reverse DFA in recognition-only string tables
chengluyu cc60472
Pack string-table integer sections as base64 varints
chengluyu 8aefa77
Support astral code points in character range patterns
chengluyu f6026af
Warn when string patterns fall back to backtracking matching
chengluyu 10dfb09
Compile negations of pure patterns in string regions
chengluyu 8caf76d
Compile conjunctions with one impure branch in string regions
chengluyu 2967a33
Merge upstream in
chengluyu df8ba26
Merge branch 'hkmc2' into compiled-string-patterns
LPTK 838ec0d
Restore indented blank lines stripped by the string-pattern commits
claude 71e1715
Add regression tests for compiled string pattern bugs
claude 5cbc7fd
Add review notes for the compiled string pattern PR
claude 42a1829
Fix three miscompilations in compiled string patterns
claude 330a095
Reorganize the string pattern tests
claude c83320a
Keep constructs the string automaton rejects on the legacy path
claude 3c80103
Drop the empty alphabet class and an unused helper
claude 05920e9
Stop swallowing internal errors when compiling `unapplyStringPrefix`
claude c58e2b8
Correct the `unapplyStringPrefix` doc: it is always generated
claude 6095982
Collapse empty int ranges to `Never` instead of the wildcard
claude 98995d9
Reject guards and chained patterns within string patterns
claude 994f9a8
Merge branch 'hkmc2' into compiled-string-patterns
LPTK 476705f
Drop the empty-int-range guard, subsumed by the encoding fix
claude df3eed0
Record the post-review fix status in the PR540 findings
claude 8f66ead
Give range patterns their intended typed, single-character semantics
claude 90e213e
Run transforms under `@compile` even in match-only mode
claude 0173355
Fix four more string-pattern miscompilations from the review
claude 95343ed
Harden diagnostics, invariants, and coverage of the string compiler
claude 07b5987
Pin the poisoned-definition semantics and record the follow-up fix round
claude 21cc53c
Pin the mixed string/class definition the whole-body-region gate prot…
claude 0db6ba6
Merge the PR #540 review round into the string-compiler work
chengluyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Claude] Critical — compiler crash when two labels of one multi-matcher reach the same transform.
Each label gets its own
StringCompilerhere, andExtractclosures are interned per instance (actionSources.indexWhere(_ eq term)). A definition reached from two labels therefore emits its transform lambda twice, and both copies bind the sameVarSymbols, becausecorrespondencecomes straight off the shared AST node.The whole definition is lost and every later use fails with
ReferenceError: f2 is not defined. Minimal pair: one label (Box(T ~ "c")alone) compiles and runs; the sameP2without@compilecompiles and runs; two labels in one multi-matcher crashes.This makes the
TODOabove theExtractcase inStringCompileroptimistic — the hazard is not only "when a simplifier pass duplicates a subtree containing both", it fires on ordinary two-label input. Threading one interning table through all labels of a multi-matcher body would fix it; theTODO's own suggestion — hosting each definition's transforms as methods on the pattern object and referencing them by selection — fixes it properly.