Skip to content

Complete Perl regex parity with Joni: source semantics - #999

Merged
fglock merged 25 commits into
masterfrom
feature/phase37-full-regex-parity
Aug 17, 2026
Merged

Complete Perl regex parity with Joni: source semantics#999
fglock merged 25 commits into
masterfrom
feature/phase37-full-regex-parity

Conversation

@fglock

@fglock fglock commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • make the forked Joni engine the default Perl regex backend
  • implement Perl regex control flow, conditions, Unicode properties, /n, /aa, branch-reset groups, split semantics, and match-time retry behavior in Joni
  • preserve the explicit Java backend for differential testing while the remaining Perl regex corpus phases are completed
  • keep the forward-looking implementation plan in dev/design/phase36-regex-parity.md

Verification

  • warning-free make
  • forced-Joni full unit suite
  • default-Joni full unit suite
  • focused JVM and interpreter parity tests for the new regex behavior

WIP follow-up

  • complete the 80-file perl5_t/t/re differential gate against the recorded baseline
  • close the remaining advanced control, Unicode/diagnostic, /aa, and re_eval gaps
  • remove obsolete Java-backend and preprocessor paths only after the corpus gates pass

Generated with Codex

fglock and others added 24 commits August 17, 2026 10:44
Replace the Phase 36 design with the forward-looking full-parity plan, add
durable baseline comparison and resource-aware regex test scheduling, and add a
temporary forced-backend seam for differential testing.

Move Perl option parsing and several ordinary-pattern translations to the Joni
boundary. Extend the vendored fork with named control-verb operands, MARK
bytecode and backtracking state, named SKIP targets, and Perl-visible REGMARK and
REGERROR state while retaining all upstream copyright notices.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Expose every capture number in a Joni duplicate-name entry through the
backend-neutral matcher so Perl's %- arrays retain unmatched placeholders and
the selected branch across matches and substitutions.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Teach the vendored Joni fork Perl bare property escapes, Unicode octal and
hex escapes, delimiter-free numeric g backreferences, and whitespace inside
interval quantifiers. This completes the forced-Joni required literal gate.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Enable Joni's existing possessive interval capability in the PerlOnJava syntax
so Perl ranges such as {2,4}+ retain their atomic backtracking behavior.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Mask trusted callback conditions with temporary named-capture conditions while
runtime regex source is parsed, then remove the synthetic captures before final
Joni compilation. This keeps mixed dynamic source and callback branches intact.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Resolve user-defined Unicode properties in PerlOnJava's source-policy layer and
pass character classes to Joni. Preserve forward references by carrying the
existing first-use recompilation signal through the Joni backend.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Resolve Script_Extensions through the bundled Unicode layer and teach the
vendored Joni compiler to emit exact alternatives for finite quantified
positive and negative lookbehind up to Perl's 255-character bound.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Strip ANSI terminal control sequences before classifying TAP lines so lexical
re debugcolor output cannot turn a passing top-level assertion into a false
incomplete result.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Remove blanket mutation snapshots from Joni callouts so ordinary assignments
survive whole-match failure and callback exceptions, while dynamic locals,
provisional regex state, and callback result state still unwind separately.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Compile assertion conditions with capture-preserving stack state and track
semantic subpattern-call frames for (R), (R1), and (R&name) conditions.
Route recursion conditions directly to Joni and cover both execution backends.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Analyze finite compound lookbehind ranges up to Perl's 255-character bound
and enforce the original endpoint while trying each candidate length. Route
all lookbehind syntax through Joni and cover positive and negative forms on
both execution backends.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Add fork-level regression coverage for assertion and recursion conditions,
capture-preserving branch selection, and finite compound lookbehind endpoints.
Retain the original Joni MIT notice on every added or modified test source.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Continue at the following character when a named SKIP resolves to the current
search start, matching Perl's repeated-search progression. Cover multi-path
SKIP, MARK captures, named COMMIT errors, and THEN behavior on both backends.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Separate exact Age semantics from cumulative In and Present_In aliases using
the Perl 5.44 Unicode release sequence. Support loose and V-prefixed version
spellings and verify matching on both execution backends.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Preserve Script, Block, and Blk property/value pairs for ICU and translate
them, script extensions, and age aliases before Joni parsing. Update the
feature matrix and parity plan with the completed condition and Unicode work.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Reset capture allocation for each top-level (?|...) branch and retain the
maximum branch allocation so matcher regions expose Perl-native numbering.
Cover optional and higher captures on JVM and interpreter backends.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Use the backend-neutral matcher for split separators, captures, leading
whitespace handling, and zero-width consuming retries. This removes the Java
placeholder dependency when Joni is selected and preserves scalar/list split
semantics on both execution backends.

Update the full-parity plan to repeat the Joni-default whole-suite gate after
the known routing blockers were closed.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Honor match-time FIND_NOT_EMPTY inside the vendored Joni bytecode machine so
global substitution can backtrack to a consuming alternative at the same
offset. Add an upstream-style regression test with the original Joni license.

Keep named-character escapes literal under extended mode and consume internal
surrogate scalar markers as one Perl character in negated classes.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Teach the vendored Joni Perl option parser to execute (?n), scoped (?n:...),
negative toggles, and (?^) using native capture-allocation state. Preserve the
original Joni license in focused parser tests.

Quote literal opening brackets inside Perl character classes so RFC-style
classes with unbraced hex ranges compile identically on the Joni backend.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Translate Java-style Is and gc property spellings emitted inside composite
Unicode classes to Joni's native aliases. This keeps built-in Perl properties
such as IsWord out of the user-property fallback and preserves their behavior
on both execution backends.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Add a native Joni option for Perl /aa semantics. Reject ASCII/non-ASCII fold
crossings in literals and classes, suppress multi-character folding, and keep
the original identity of Unicode simple folds that cross into ASCII.

Cover the fork behavior with an upstream-style test retaining Joni's original
license and verify full-fold and crossing cases on both PerlOnJava backends.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Select Joni for ordinary patterns unless explicit Java differential mode is
requested. Compile byte and Unicode Joni variants so default /d character
classes follow the target scalar, and preserve Perl POSIX-class nesting,
leading class syntax, and compile-time malformed-class diagnostics.

Update the full-parity design to reflect the permanent default while retaining
the temporary Java selector for corpus comparison.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Parse nested /aa and Unicode fold policy changes as native Joni options,
carry those options through matcher backtracking, and preserve the source
identity of Unicode characters whose folds cross into ASCII. Remove the
equivalent PerlOnJava pattern rewrite so nested modifier restoration remains
correct.

Document MARK state and Joni-owned capture/fold modifiers in the feature
matrix. Update the forward-looking regex parity plan with the current engine
boundary.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Keep callback and dynamic-program source in stringified qr objects, preserve
literal extended-mode comments, and remove the source-destroying dynamic
constant fold. Update the full regex parity plan with incremental retirement of
the imported pat.t compatibility patch.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
@fglock
fglock marked this pull request as ready for review August 17, 2026 14:31
@fglock fglock changed the title WIP: Complete Perl regex parity with Joni Complete Perl regex parity with Joni: source semantics Aug 17, 2026
Resolve the perl test runner conflict by retaining the weighted scheduler as
the default while preserving the explicitly requested dedicated CPU-heavy
lane. Keep both runner regression suites passing.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
@fglock
fglock merged commit f194d9c into master Aug 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant