feat: Runtime and JVM compiler improvements for context and regex handling#208
Closed
fglock wants to merge 1 commit into
Closed
feat: Runtime and JVM compiler improvements for context and regex handling#208fglock wants to merge 1 commit into
fglock wants to merge 1 commit into
Conversation
…dling
This commit consolidates runtime and JVM compiler enhancements:
Features:
- Add escapeInvalidQuantifierBraces function for Perl regex compatibility
(currently disabled due to test regressions - needs more work)
- Add DEBUG_REGEX environment variable support for regex debugging
Fixes:
- Preserve RUNTIME context for RHS of logical operators in JVM compiler
- Evaluate LHS of logical operators in SCALAR context (for boolean test)
- Add debug logging to RuntimeRegex.compile() and matchRegexDirect()
Implementation Details:
- EmitLogicalOperator: Changed context handling for logical operators
- LHS evaluated in SCALAR context for boolean test
- RHS preserves RUNTIME context when in RUNTIME mode
- Prevents context loss at subroutine exits
- RegexPreprocessor: Added escapeInvalidQuantifierBraces()
- Handles Perl-style quantifier braces like {1}, {,3}, {2,5}
- Escapes invalid braces that would cause Java Pattern.compile() errors
- Currently disabled (line 82-84) due to edge case regressions
- Function ready for future refinement and re-enabling
- RuntimeRegex: Added DEBUG_REGEX support
- Set DEBUG_REGEX=1 environment variable to enable regex debug output
- Logs pattern compilation, cache hits/misses, and matching operations
- Helps diagnose regex preprocessing and matching issues
Files Modified:
- EmitLogicalOperator.java: +17/-12 lines
- RegexPreprocessor.java: +212/-0 lines
- RegexPreprocessorHelper.java: +123/-71 lines (refactored)
- RuntimeRegex.java: +41/-13 lines
Test Results (vs master):
- re/regexp.t: 1788/2210 (+2)
- re/pat.t: 896/1296 (+1)
- re/pat_rt_report.t: 2384/2514 (+3)
- re/reg_mesg.t: 1642/2479 (no change)
- Net: +6 improvements, 0 regressions
Co-Authored-By: Claude Opus 4.6 <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.
Summary
This PR consolidates runtime and JVM compiler enhancements, providing net improvements across regex and other test suites with no new regressions.
Features Added
Fixes
Implementation Details
EmitLogicalOperator: Changed context handling for logical operators
RegexPreprocessor: Added escapeInvalidQuantifierBraces()
RuntimeRegex: Added DEBUG_REGEX support
Files Modified
EmitLogicalOperator.java: +17/-12 linesRegexPreprocessor.java: +212/-0 linesRegexPreprocessorHelper.java: +123/-71 lines (refactored)RuntimeRegex.java: +41/-13 linesTotal: 4 files changed, 323 insertions(+), 70 deletions(-)
Test Results (vs master)
Regex Tests
re/regexp.t: 1788/2210 (+2)re/pat.t: 896/1296 (+1)re/pat_rt_report.t: 2384/2514 (+3)re/reg_mesg.t: 1642/2479 (no change)Other Tests
io/open.t: 181/216 (+2)op/filetest.t: 227/436 (+1)op/signatures.t: 594/908 (no change)test_pl/examples.t: 7/17 (no change)Net result: +9 improvements, 0 new regressions
Test Plan
maketo verify build and unit tests🤖 Generated with Claude Code