Repository navigation
Walk the parser's own tree - #2
Merged
yoeunes merged 1 commit intoOct 23, 2026
Merged
Conversation
yoeunes
force-pushed
the
read-regex-shapes-through-phpregex
branch
from
October 23, 2026 18:25
affc97a to
53cc9c4
Compare
yoeunes
force-pushed
the
walk-the-phpregex-ast
branch
from
October 23, 2026 18:27
aab0f8b to
40a0270
Compare
The translation layer between the parser's AST and the shape walkers
is gone: the walkers read the nodes the parser built, the alternations
come without their separator tokens and the empty branches without
their patch-up passes, and the quantifier bounds come from the parser's
own reading instead of a re-parse of the token text. IgnoredRegexValidator
reads the same tree, its branch text sliced from the source between
node positions so escapes come back as they were written. A padded hex
escape still types 'ax{ 41 }' for PHP 7.4 and the letter A on 8.x, the
inline (?i:...) groups still drop the constants their caseless body
cannot promise, and every resolver fixture says the same thing it said
through the translation: 1873 of 1873.
yoeunes
force-pushed
the
walk-the-phpregex-ast
branch
from
October 23, 2026 18:29
40a0270 to
c3b490f
Compare
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.
Stacked on #1 — review that one first.
What
Drops the translation layer the first PR kept so its diff stayed minimal: the shape walkers read the nodes the parser built, no intermediate tree, no vocabulary conversion.
PHPRegexReaderreturns the parser's ownRegexNode; the target it judges for (analysed PHP, bundled engine, pin that only narrows) is unchanged.RegexGroupParserwalks the native nodes: the separator tokens and the empty-branch patches the old grammar needed are gone by construction, and the quantifier bounds come from the parser's own reading.IgnoredRegexValidatorwalks the same tree; branch text is sliced from the source between node positions, so escapes come back as written.RegexTreeNodeand the builder are deleted: −949 net lines, zero references left.Why now and not in #1
The first PR ships the reader behind the seam so its diff only swaps the source of the trees the walkers already consumed. This one removes the seam — reviewing them together would ask the reviewer to check a new parser and a walker rewrite in one pass; stacked, each diff says one thing.
Test plan
Same judges as #1: the shape pins (backreference, verbs,
\Q..\E,(?J),/x, version-shaped escapes,PcreVersionarchitecture) and the resolver suite — 1873/1873, every fixture saying what it said through the translation.