Class NFAState
java.lang.Object
com.oracle.truffle.regex.tregex.automaton.BasicState<NFAState,NFAStateTransition>
com.oracle.truffle.regex.tregex.nfa.NFAState
- All Implemented Interfaces:
AbstractState<NFAState,,NFAStateTransition> JsonConvertible
public final class NFAState
extends BasicState<NFAState,NFAStateTransition>
implements JsonConvertible
Represents a single state in the NFA form of a regular expression. States may either be matcher
states or final states, where a matcher state matches a set of characters and a final state
indicates that a match has been found. A state may represent multiple nodes of a regex AST, if it
is the result of a product automaton composition of the "regular" regular expression and its
lookaround assertions, e.g. the NFA of an expression like /(?=[ab])a/ will contain a state that
matches both the 'a' in the lookahead assertion as well as following 'a' in the expression, and
therefore will have a state set containing two AST nodes.
-
Field Summary
Fields inherited from class com.oracle.truffle.regex.tregex.automaton.BasicState
FLAG_ANCHORED_FINAL_STATE, FLAG_ANCHORED_INITIAL_STATE, FLAG_ANY_FINAL_STATE, FLAG_ANY_INITIAL_OR_FINAL_STATE, FLAG_ANY_INITIAL_STATE, FLAG_UN_ANCHORED_FINAL_STATE, FLAG_UN_ANCHORED_INITIAL_STATE, N_FLAGS -
Constructor Summary
ConstructorsConstructorDescriptionNFAState(short id, StateSet<RegexAST, ? extends RegexASTNode> stateSet, CodePointSet matcherBuilder, Set<LookBehindAssertion> finishedLookBehinds, boolean hasPrefixStates, boolean mustAdvance) NFAState(short id, StateSet<RegexAST, ? extends RegexASTNode> stateSet, CodePointSet matcherBuilder, Set<LookBehindAssertion> finishedLookBehinds, boolean hasPrefixStates, boolean mustAdvance, org.graalvm.collections.EconomicMap<Integer, TBitSet> matchedConditionGroupsMap) Creates a copy of theoriginalstate. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLoopBackNext(NFAStateTransition transition) voidaddPossibleResult(int index) createTraceFinderCopy(short copyID) protected NFAStateTransition[]createTransitionsArray(int length) booleangetFirstTransitionToFinalState(boolean forward) intgetFirstTransitionToFinalStateIndex(boolean forward) Set of possible pre-calculated result indices as generated by theNFATraceFinderGenerator.StateSet<RegexAST, ? extends RegexASTNode> getTransitionToAnchoredFinalState(boolean forward) shortgetTransitionToAnchoredFinalStateId(boolean forward) getTransitionToUnAnchoredFinalState(boolean forward) shortgetTransitionToUnAnchoredFinalStateId(boolean forward) inthashCode()booleanbooleanbooleanhasTransitionToAnchoredFinalState(boolean forward) booleanhasTransitionToFinalState(boolean forward) booleanhasTransitionToUnAnchoredFinalState(boolean forward) booleanvoidvoidvoidremoveSuccessor(NFAState state) voidsetHasPrefixStates(boolean value) voidsetMustAdvance(boolean value) voidsetSuccessors(NFAStateTransition[] transitions, boolean createReverseTransitions) toJson()toJson(boolean forward) toString()Methods inherited from class com.oracle.truffle.regex.tregex.automaton.BasicState
addPredecessor, addPredecessorUnchecked, getFlag, getFlags, getId, getNPredecessors, getPredecessors, getPredecessors, getSuccessors, getSuccessors, hasPredecessors, hasSuccessors, incPredecessors, isAnchoredFinalState, isAnchoredFinalState, isAnchoredInitialState, isAnchoredInitialState, isDead, isFinalState, isFinalState, isInitialState, isInitialState, isUnAnchoredFinalState, isUnAnchoredFinalState, isUnAnchoredInitialState, isUnAnchoredInitialState, setAnchoredFinalState, setAnchoredInitialState, setFlag, setFlag, setPredecessors, setSuccessors, setUnAnchoredFinalState, setUnAnchoredInitialState, setUnAnchoredInitialState
-
Constructor Details
-
NFAState
public NFAState(short id, StateSet<RegexAST, ? extends RegexASTNode> stateSet, CodePointSet matcherBuilder, Set<LookBehindAssertion> finishedLookBehinds, boolean hasPrefixStates, boolean mustAdvance) -
NFAState
public NFAState(short id, StateSet<RegexAST, ? extends RegexASTNode> stateSet, CodePointSet matcherBuilder, Set<LookBehindAssertion> finishedLookBehinds, boolean hasPrefixStates, boolean mustAdvance, org.graalvm.collections.EconomicMap<Integer, TBitSet> matchedConditionGroupsMap) -
NFAState
Creates a copy of theoriginalstate. This copy is shallow as the state is just a part of a larger cyclic graph. However, it has its own copy of theBasicState.getSuccessors()andBasicState.getPredecessors()arrays. When copying the entire NFA, theBasicState.getSuccessors()andBasicState.getPredecessors()must be updated to point to transitions in the new NFA.
-
-
Method Details
-
createTraceFinderCopy
-
getCharSet
-
getFinishedLookBehinds
-
getStateSet
-
hasPrefixStates
public boolean hasPrefixStates() -
setHasPrefixStates
public void setHasPrefixStates(boolean value) -
isMustAdvance
public boolean isMustAdvance() -
setMustAdvance
public void setMustAdvance(boolean value) -
getMatchedConditionGroupsMap
-
getMatchedConditionGroups
-
getMatchedConditionGroupsDebug
-
hasTransitionToAnchoredFinalState
public boolean hasTransitionToAnchoredFinalState(boolean forward) -
getTransitionToAnchoredFinalStateId
public short getTransitionToAnchoredFinalStateId(boolean forward) -
getTransitionToAnchoredFinalState
-
hasTransitionToUnAnchoredFinalState
public boolean hasTransitionToUnAnchoredFinalState(boolean forward) - Specified by:
hasTransitionToUnAnchoredFinalStatein classBasicState<NFAState,NFAStateTransition>
-
getTransitionToUnAnchoredFinalState
-
getTransitionToUnAnchoredFinalStateId
public short getTransitionToUnAnchoredFinalStateId(boolean forward) -
hasTransitionToFinalState
public boolean hasTransitionToFinalState(boolean forward) -
getFirstTransitionToFinalStateIndex
public int getFirstTransitionToFinalStateIndex(boolean forward) -
getFirstTransitionToFinalState
-
addLoopBackNext
-
removeLoopBackNext
public void removeLoopBackNext() -
setSuccessors
-
removeSuccessor
-
linkPredecessors
public void linkPredecessors() -
getPossibleResults
Set of possible pre-calculated result indices as generated by theNFATraceFinderGenerator. This set must be sorted, since the index values indicate the priority of their respective pre-calculated results. Example: /(a)|([ab])/ will yield two possible results, where the one corresponding to capture group 1 will have the higher priority, so when a single 'a' is encountered when searching for a match, the pre-calculated result corresponding to capture group 1 must be preferred. -
hasPossibleResults
public boolean hasPossibleResults() -
addPossibleResult
public void addPossibleResult(int index) -
idToString
-
toString
-
equals
-
hashCode
-
createTransitionsArray
- Specified by:
createTransitionsArrayin classBasicState<NFAState,NFAStateTransition>
-
toJson
- Specified by:
toJsonin interfaceJsonConvertible
-
toJson
-