ERE parity: escapes, POSIX classes, {n,m} intervals, re_replace + builtin-shaped compat layer#4
Merged
Merged
Conversation
…place + builtin-shaped compat layer (S8)
Closes the four gaps between the Pike-VM engine and EigenScript's
libc-backed regex builtins, so lib/regex_compat.eigs can drop in for
regex_match/regex_find/regex_replace in the freestanding (EigenOS)
profile where libc regcomp is gone:
- parser: backslash escapes (\. \* \\ etc. literal; \w \W \s \S
classes; \d stays a literal 'd' — glibc ERE parity, verified against
the builtin oracle; trailing backslash errors)
- parser: POSIX [[:alpha:]]-style classes (12 names + [:word:]),
composable with ranges and negation; unknown names error
- parser: {n} {n,} {n,m} intervals with lazy '?' variants, desugared to
existing AST forms (no new VM ops). The repeated subtree is shared —
safe because the compiler never mutates AST nodes — which reproduces
glibc's last-repetition-wins capture semantics. Invalid/unclosed
specs are parse errors like glibc; bounds cap at 255.
- lib/regex.eigs: re_replace (literal replacement, zero-width matches
pass one char through — byte-matches the builtin's "-a-b-c-" shape)
- lib/regex_compat.eigs (new): regex_match/regex_find/regex_replace
with the builtins' exact names, arg shapes, substring returns, and
quirks (group list truncates at first non-participating group, caps
at 16; bad pattern → []/input). Known divergences documented in the
header: POSIX leftmost-longest vs Pike-VM leftmost-first, no \b.
Tests: S6 (40) + S7 (39) + S8 (48, including a 42-check differential
suite running shim-vs-builtin over shared inputs with the libc builtins
as the oracle). Suite 347/347 green on EigenScript v0.23.0.
Docs: README + CLAUDE.md feature/status/layout refresh; stale EIGS_REF
note corrected to v0.23.0.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Closes the gaps between the Pike-VM engine and the libc-backed
regex_*builtins solib/regex_compat.eigscan drop in for them in EigenScript's freestanding (EigenOS) profile — the regex disposition in EigenScript'sdocs/FREESTANDING.mdledger.What's in
\.-style literal escapes,\w \W \s \S, 12[[:name:]]classes composable with ranges/negation. Glibc-parity trap preserved deliberately:\dis a literaldin ERE (verified against the builtin oracle).{n} {n,} {n,m}intervals (with lazy?variants): pure parser desugaring to existing AST forms — no new VM ops, the O(n·m) guarantee is untouched. Shared-subtree repetition reproduces glibc's last-repetition-wins capture semantics (^(a|b){2}$on"ab"captures"b", oracle-verified). Invalid specs are parse errors like glibc; bounds cap at 255.re_replace(literal replacement, builtin-identical zero-width behavior:x*overabc→-a-b-c-) andlib/regex_compat.eigs:regex_match/regex_find/regex_replacewith the builtins' exact names, shapes, and quirks (group-list truncation at first non-participating group, 16-entry cap, bad-pattern →[]/input).Verification
{0,0}) all agree with the oracle.Documented divergences (in the compat header)
POSIX leftmost-longest vs Pike-VM leftmost-first (
a|abdiffers); no\b/\B(needs text access in the VM's epsilon-closure — deferred); the builtins' NOTBOL^re-anchoring quirk in find/replace is not replicated.🤖 Generated with Claude Code