Repository navigation
Conversation
jgaleotti
approved these changes
Oct 6, 2026
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.
Fixes for Java regex back references and one NPE fix for
RegexHandlererror listener.RegexHandlererror listenerANTLR can call
syntaxErrorwith nullRecognitionException, the parameter for this method was declared as non-nullable so we got NPE. Made that parameter nullable (RecognitionException?) so that we getParseCancellationExceptioninstead ofNullPointerException.Non-capturing group increased capture group count (Java visitor)
visitAtomadded a placeholder tocaptureGroupsfor every group but only filled it for capturing ones. This shifts the group counts after a non-capturing group. For example, on(?:abc)(def)\1\1should point to the only capture group(def)but because of this issue(?:abc)(a non-capturing group) was placing a placeholder oncaptureGroups' first position which would not get replaced as it is not a capture group,(def)would get placed as a second group which is incorrect. The placeholders are now added only when the group is a capturing group.Fix back references
Currently back references worked by saving a reference to the captured group (
val captureGroup: DisjunctionListRxGene?onBackReferenceRxGene's constructor). The problem with this is that when we usecopy()onBackReferenceRxGenewe would get the same reference. This is an issue when copying a regex gene tree, because we would get the back references on the copied tree pointing to the groups from the first tree. This is also a problem for quantified groups, as the groups are part of the quantifier template and we add atoms to quantifier genes by usingtemplate.copy(), and the reference would still point to the group within the template.To fix this:
DisjunctionListRxGenesaves its group number (null if non-capturing).RegexGeneon the regex gene tree root, this is cleared when rendering the tree from the root.BackReferenceRxGenes read their group's last captured value fromRegexGene. This gene now saves a boolean (instead of the capture group's gene) indicating whether the backref is unsatisfiable or not, this is used to prune unsatisfiable branches. In Java backrefs are unsatisfiable when forward or self reference, unsatisfiable or missing group.Patterncheck onRegexGenewould make mismatches re-sample.AssertionRxGenealso render theirinnerGenewhen they contain a capture group (for example(?=(a)*)), so that those groups get recorded.