Class TRegexBacktrackingNFAExecutorNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.regex.tregex.nodes.TRegexExecutorBaseNode
com.oracle.truffle.regex.tregex.nodes.TRegexExecutorNode
com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackerSubExecutorNode
com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackingNFAExecutorNode
- All Implemented Interfaces:
com.oracle.truffle.api.instrumentation.InstrumentableNode,com.oracle.truffle.api.nodes.NodeInterface,Cloneable
This regex executor uses a backtracking algorithm on the NFA. It is used for all expressions that
cannot be matched with the DFA, such as expressions with backreferences.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.nodes.Node.Child, com.oracle.truffle.api.nodes.Node.ChildrenNested classes/interfaces inherited from interface com.oracle.truffle.api.instrumentation.InstrumentableNode
com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode -
Field Summary
Fields inherited from class com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackerSubExecutorNode
NO_SUB_EXECUTORS, subExecutorsFields inherited from class com.oracle.truffle.regex.tregex.nodes.TRegexExecutorNode
ASTRAL_PROBABILITY, BMP_PROBABILITY, CONTINUE_PROBABILITY, EXIT_PROBABILITY, LATIN1_PROBABILITY -
Constructor Summary
ConstructorsConstructorDescriptionTRegexBacktrackingNFAExecutorNode(RegexAST ast, PureNFA nfa, int numberOfStates, int numberOfTransitions, TRegexExecutorBaseNode[] subExecutors, boolean mustAdvance, CompilationBuffer compilationBuffer) -
Method Summary
Modifier and TypeMethodDescriptioncreateLocals(com.oracle.truffle.api.strings.TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, int index) execute(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexExecutorLocals abstractLocals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange) protected static intgetBackRefBoundary(TRegexBacktrackingNFAExecutorLocals locals, PureNFATransition transition, int cgIndex, int index) getName()intbooleanbooleanShould a backreference to an unmatched capture group succeed or fail?booleanbooleanbooleanbooleanbooleanShould the empty check inexitZeroWidthquantifier guards also check the contents of capture groups? If the capture groups were modified, the empty check passes, even if only the empty string was matched.booleanbooleanbooleanbooleanWhen generating NFAs for Ruby regular expressions, the sequence of quantifier guards on a single transition can become quite complex.booleanprotected booleanbooleanShould the reported lastGroup point to the first group that *begins* instead of the last group that *ends*? This is needed when executing Python lookbehind expressions.protected int[]runSubMatcher(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexBacktrackingNFAExecutorLocals subLocals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange, PureNFAState subMatcherState) protected static booleansubMatchFailed(PureNFAState curState, Object subMatchResult) protected booleantransitionMatches(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexBacktrackingNFAExecutorLocals locals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange, PureNFATransition transition, int index, boolean atEnd, int c) protected booleantryUpdateState(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexBacktrackingNFAExecutorLocals locals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange, PureNFATransition transition, int index, boolean atEnd, int c) This method composestransitionMatches(com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackingNFAExecutorLocals, com.oracle.truffle.api.strings.TruffleString.CodeRange, com.oracle.truffle.regex.tregex.nfa.PureNFATransition, int, boolean, int)withupdateState(com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackingNFAExecutorLocals, com.oracle.truffle.regex.tregex.nfa.PureNFATransition, int).protected voidupdateState(TRegexBacktrackingNFAExecutorLocals locals, PureNFATransition transition, int index) booleanReturnstrueif this executor may write any new capture group boundaries.Methods inherited from class com.oracle.truffle.regex.tregex.nodes.TRegexExecutorNode
countUpTo, getAstralProfile, getBMPProfile, getMaxIndex, getMinIndex, getNumberOfCaptureGroups, getNumberOfTransitions, getSource, inputAdvance, inputAtBegin, inputAtEnd, inputGetCodePointSize, inputGetCodePointSize, inputHasNext, inputHasNext, inputHasNext, inputIncNextIndexRaw, inputIncNextIndexRaw, inputIncRaw, inputIncRaw, inputIncRaw, inputIncRaw, inputIncRaw, inputIncRaw, inputReadAndDecode, inputReadAndDecode, inputReadRaw, inputReadRaw, inputReadRaw, inputReadRaw, inputSkip, inputSkipIntl, inputSkipReverse, inputUTF16IsHighSurrogate, inputUTF16IsLowSurrogate, inputUTF16ToCodePoint, isSimpleCG, rewindUpToMethods inherited from class com.oracle.truffle.regex.tregex.nodes.TRegexExecutorBaseNode
createWrapper, getEncoding, isBooleanMatch, isInstrumentable, isTrivial, isUTF16, isUTF32, isUTF8, unwrapMethods inherited from class com.oracle.truffle.api.nodes.Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.truffle.api.instrumentation.InstrumentableNode
findNearestNodeAt, findNearestNodeAt, getNodeObject, hasTag, materializeInstrumentableNodes
-
Constructor Details
-
TRegexBacktrackingNFAExecutorNode
public TRegexBacktrackingNFAExecutorNode(RegexAST ast, PureNFA nfa, int numberOfStates, int numberOfTransitions, TRegexExecutorBaseNode[] subExecutors, boolean mustAdvance, CompilationBuffer compilationBuffer)
-
-
Method Details
-
shallowCopy
- Specified by:
shallowCopyin classTRegexBacktrackerSubExecutorNode
-
getNumberOfStates
public int getNumberOfStates()- Specified by:
getNumberOfStatesin classTRegexExecutorBaseNode
-
writesCaptureGroups
public boolean writesCaptureGroups()Description copied from class:TRegexExecutorBaseNodeReturnstrueif this executor may write any new capture group boundaries.- Specified by:
writesCaptureGroupsin classTRegexExecutorBaseNode
-
getName
- Specified by:
getNamein classTRegexExecutorBaseNode
-
isForward
public boolean isForward()- Specified by:
isForwardin classTRegexExecutorBaseNode
-
isBackrefWithNullTargetFails
public boolean isBackrefWithNullTargetFails()Should a backreference to an unmatched capture group succeed or fail? -
isMonitorCaptureGroupsInEmptyCheck
public boolean isMonitorCaptureGroupsInEmptyCheck()Should the empty check inexitZeroWidthquantifier guards also check the contents of capture groups? If the capture groups were modified, the empty check passes, even if only the empty string was matched. -
isTransitionMatchesStepByStep
public boolean isTransitionMatchesStepByStep()When generating NFAs for Ruby regular expressions, the sequence of quantifier guards on a single transition can become quite complex. This necessitates evaluating the effects of each guard one by one in order to arrive at the correct answer. This flag controls whether such detailed handling of the quantifiers is to be used or not. -
isEmptyChecksOnMandatoryLoopIterations
public boolean isEmptyChecksOnMandatoryLoopIterations() -
isTrackLastGroup
public boolean isTrackLastGroup() -
isMustAdvance
public boolean isMustAdvance() -
isLoneSurrogates
public boolean isLoneSurrogates() -
isLoopbackInitialState
public boolean isLoopbackInitialState() -
isUseMergeExplode
public boolean isUseMergeExplode() -
isRecursiveBackreferences
public boolean isRecursiveBackreferences() -
isBackreferenceIgnoreCaseMultiCharExpansion
public boolean isBackreferenceIgnoreCaseMultiCharExpansion() -
createLocals
public TRegexExecutorLocals createLocals(com.oracle.truffle.api.strings.TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, int index) - Specified by:
createLocalsin classTRegexExecutorBaseNode
-
execute
public Object execute(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexExecutorLocals abstractLocals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange) - Specified by:
executein classTRegexExecutorBaseNode
-
returnsFirstGroup
public boolean returnsFirstGroup()Should the reported lastGroup point to the first group that *begins* instead of the last group that *ends*? This is needed when executing Python lookbehind expressions. The semantics of the lastGroup field should correspond to the left-to-right evaluation of lookbehind assertions in Python, but we run lookbehinds in the right-to-left direction. -
lookAroundExecutorIsLiteral
-
runSubMatcher
protected int[] runSubMatcher(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexBacktrackingNFAExecutorLocals subLocals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange, PureNFAState subMatcherState) -
subMatchFailed
-
transitionMatches
protected boolean transitionMatches(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexBacktrackingNFAExecutorLocals locals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange, PureNFATransition transition, int index, boolean atEnd, int c) -
getBackRefBoundary
protected static int getBackRefBoundary(TRegexBacktrackingNFAExecutorLocals locals, PureNFATransition transition, int cgIndex, int index) -
updateState
protected void updateState(TRegexBacktrackingNFAExecutorLocals locals, PureNFATransition transition, int index) -
tryUpdateState
protected boolean tryUpdateState(com.oracle.truffle.api.frame.VirtualFrame frame, TRegexBacktrackingNFAExecutorLocals locals, com.oracle.truffle.api.strings.TruffleString.CodeRange codeRange, PureNFATransition transition, int index, boolean atEnd, int c) This method composestransitionMatches(com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackingNFAExecutorLocals, com.oracle.truffle.api.strings.TruffleString.CodeRange, com.oracle.truffle.regex.tregex.nfa.PureNFATransition, int, boolean, int)withupdateState(com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackingNFAExecutorLocals, com.oracle.truffle.regex.tregex.nfa.PureNFATransition, int). It is somewhat equivalent to the following:if (transitionMatches(locals, compactString, transition, index, atEnd, c)) { updateState(locals, transition, index); return true; } else { return false; }The key difference is that in this method, theupdateState(com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackingNFAExecutorLocals, com.oracle.truffle.regex.tregex.nfa.PureNFATransition, int)effects of quantifier guards are evaluated in parallel with theirtransitionMatches(com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.regex.tregex.nodes.nfa.TRegexBacktrackingNFAExecutorLocals, com.oracle.truffle.api.strings.TruffleString.CodeRange, com.oracle.truffle.regex.tregex.nfa.PureNFATransition, int, boolean, int)assertions. This more detailed behavior is necessary when working with NFA transitions that have complex chains of quantifier guards, such as the ones used in Ruby.NB: This method writes to
localseven if it returnsfalse.
-