Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
========================================
Coverage 85.1% 85.2%
- Complexity 1 272 +271
========================================
Files 169 172 +3
Lines 50037 50205 +168
Branches 7712 7760 +48
========================================
+ Hits 42616 42783 +167
+ Misses 5406 5400 -6
- Partials 2015 2022 +7
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
\X matching
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.
What does this PR do?
Add a stateless native matcher for the exact pattern
\X, available throughReggie.compile()and@RegexPattern. Each match consumes one grapheme cluster using the executing JDK's rules.\Xon"e\u0301"matches both code points\X(\X)\X(?:\X)\X\X+\Xa\X(?i)\XReggie.compile("\\X", ReggieFlags.CASE_INSENSITIVE)Reggie.compile("\\X")@RegexPattern("\\X")ReggieCompiledPattern.tryCompile(...)rejects\XUnsupportedPatternExceptionReggie.compileAllowingFallback("\\X")on JDK 28 EAfindBoundsFrom(text, 0, reusedBounds)findMatch(text)creates a result and group arraysUnsupported profiles retain strict refusal and explicit opt-in JDK fallback. The specialised LTS API keeps its existing admission rules.
Motivation
Provide correct grapheme boundaries for combining characters, emoji sequences and CRLF, with no per-cluster allocation during bounds traversal.
Remaining features and implementation path
The dedicated scanner handles exact
\Xbefore AST/NFA construction. General composition needs broader changes across the parser and AST, a native execution path that supports variable-width atoms, pattern analysis and strategy selection. Length calculations, capture metadata and structural cache keys must reflect grapheme consumption in both runtime compilation and annotation processing.These changes must preserve UTF-16 offsets and greedy/lazy behaviour, with JDK differential tests, Unicode conformance tests and benchmarks for mixed patterns. Supporting new JDK profiles also involves Unicode data maintenance; reusable rich results need a public API contract for ownership and lifetime.
(?:\X)\X.(\X)\X+,a\X(?i)\XReggieCompiledPatternadmits its own full-capture linear-token-sequence profile.CharSequenceguarantees.These are follow-up changes. General composition needs correctness and performance checks for mixed character/grapheme transitions, captures and repeated scans.
Related Issue(s)
None.
Change Type
Checklist
./gradlew build)Performance Impact
On Java 27 / Apple M4 Max, complete bounds traversal was 1.3x-6x faster than a reused JDK matcher across eight tested corpora. A matching-thread allocation probe measured zero bytes; rich results still allocate.
Measurements and reproduction commands.
Additional Notes
Runtime and Java 21-generated accessors passed the JDK 21-27 matrix. JDK 28 EA covers refusal, fallback and repeated accessor failures. Hosted CI is pending. Unicode conformance fixtures are vendored unchanged.