Class ConditionalBackReferenceGroup
java.lang.Object
com.oracle.truffle.regex.tregex.parser.ast.RegexASTNode
com.oracle.truffle.regex.tregex.parser.ast.Term
com.oracle.truffle.regex.tregex.parser.ast.QuantifiableTerm
com.oracle.truffle.regex.tregex.parser.ast.Group
com.oracle.truffle.regex.tregex.parser.ast.ConditionalBackReferenceGroup
- All Implemented Interfaces:
AbstractState<Term,,ASTTransition> RegexASTVisitorIterable,JsonConvertible
Conditional back-reference groups represent the following construct found, e.g., in Python:
(?(group_name)then_branch|else_branch
Every conditional back-reference group has exactly 2 alternatives. The first alternative can only be taken if the referenced group was matched and the second alternative can be taken only if the referenced group was *not* matched.
-
Constructor Summary
ConstructorsConstructorDescriptionConditionalBackReferenceGroup(int referencedGroupNumber) Creates an empty conditional back-reference group. -
Method Summary
Modifier and TypeMethodDescriptionCopy this node only, without any child nodes.copyRecursive(RegexAST ast, CompilationBuffer compilationBuffer) Recursively copy this subtree.booleanequalsSemantic(RegexASTNode obj, boolean ignoreQuantifier) intReturns the index of the capture group that is referenced by this conditional expression.toJson()toString()Methods inherited from class com.oracle.truffle.regex.tregex.parser.ast.Group
add, addSequence, alternativesToString, clearGroupNumber, getAlternatives, getBoundaryIndexEnd, getBoundaryIndexStart, getCaptureGroupsHigh, getCaptureGroupsLow, getEnclosedCaptureGroupsHigh, getEnclosedCaptureGroupsLow, getFirstAlternative, getGroupNumber, getGroupsWithGuardsIndex, getLastAlternative, groupNumberToBoundaryIndexEnd, groupNumberToBoundaryIndexStart, hasEnclosedCaptureGroups, hasGroupWithGuardsIndex, insertFirst, isAlwaysZeroWidth, isCapturing, isEmpty, isLiteral, isLocalFlags, isLoop, isUnrollingCandidate, loopToString, removeLastSequence, resetVisitorIterator, setAlternatives, setEnclosedCaptureGroupsHigh, setEnclosedCaptureGroupsLow, setGroupNumber, setGroupsWithGuardsIndex, setLocalFlags, setLoop, size, visitorGetNext, visitorHasNextMethods inherited from class com.oracle.truffle.regex.tregex.parser.ast.QuantifiableTerm
equalsSemantic, getQuantifier, getSubTreeParent, hasNotUnrolledQuantifier, hasQuantifier, quantifierToString, setQuantifierMethods inherited from class com.oracle.truffle.regex.tregex.parser.ast.Term
getSeqIndex, setSeqIndexMethods inherited from class com.oracle.truffle.regex.tregex.parser.ast.RegexASTNode
asAtomicGroup, asBackReference, asCharacterClass, asConditionalBackReferenceGroup, asGroup, asLookAheadAssertion, asLookAroundAssertion, asLookBehindAssertion, asMatchFound, asPositionAssertion, asQuantifiableTerm, asSequence, asSubexpressionCall, asSubtreeRootNode, astNodeId, endsWithDollar, getFlags, getId, getMaxPath, getMinPath, getParent, getPrefixLengthMax, getPrefixLengthMin, hasBackReferences, hasCaptureGroups, hasCaret, hasDollar, hasEmptyGuard, hasLookAheads, hasLookBehinds, hasLoops, hasQuantifiers, hasVariablePrefixLength, idInitialized, incMaxPath, incMaxPath, incMinPath, incMinPath, isAtomicGroup, isBackReference, isCaret, isCharacterClass, isConditionalBackReferenceGroup, isDead, isDollar, isExpandedQuantifier, isFlagSet, isGroup, isGroupWithGuards, isInLookAheadAssertion, isInLookBehindAssertion, isLookAheadAssertion, isLookAroundAssertion, isLookBehindAssertion, isMandatoryUnrolledQuantifier, isMatchFound, isPositionAssertion, isPrefix, isQuantifiableTerm, isQuantifierPassThroughSequence, isRoot, isSequence, isSubexpressionCall, isSubtreeRoot, markAsDead, setDead, setEmptyGuard, setEndsWithDollar, setEndsWithDollar, setExpandedQuantifier, setFlag, setFlag, setFlags, setHasBackReferences, setHasCaptureGroups, setHasCaret, setHasCaret, setHasDollar, setHasDollar, setHasLookAheads, setHasLookBehinds, setHasLoops, setHasLoops, setHasQuantifiers, setId, setMandatoryUnrolledQuantifier, setMaxPath, setMinPath, setParent, setPrefix, setPrefixLengthMax, setPrefixLengthMin, setQuantifierPassThroughSequence, setStartsWithCaret, setStartsWithCaret, startsWithCaret, toJson, toStringWithIDMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.truffle.regex.tregex.automaton.AbstractState
getId
-
Constructor Details
-
ConditionalBackReferenceGroup
public ConditionalBackReferenceGroup(int referencedGroupNumber) Creates an empty conditional back-reference group. It should later be filled with exactly 2Sequences as its alternatives.- Parameters:
referencedGroupNumber- The number of the capture group referenced in the condition.
-
-
Method Details
-
getReferencedGroupNumber
public int getReferencedGroupNumber()Returns the index of the capture group that is referenced by this conditional expression. -
copy
Description copied from class:RegexASTNodeCopy this node only, without any child nodes. The ID and minPath of the copied nodes is left unset. -
copyRecursive
public ConditionalBackReferenceGroup copyRecursive(RegexAST ast, CompilationBuffer compilationBuffer) Description copied from class:RegexASTNodeRecursively copy this subtree. This method should be used instead ofCopyVisitorif the copying process is required to be thread-safe. The ID and minPath of the copied nodes is left unset.- Overrides:
copyRecursivein classGroup- Parameters:
ast- RegexAST the new nodes should belong to.- Returns:
- A deep copy of this node.
-
equalsSemantic
- Overrides:
equalsSemanticin classGroup
-
toString
-
toJson
- Specified by:
toJsonin interfaceJsonConvertible- Overrides:
toJsonin classGroup
-