Class 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.
  • Constructor Details

  • Method Details

    • createTraceFinderCopy

      public NFAState createTraceFinderCopy(short copyID)
    • getCharSet

      public CodePointSet getCharSet()
    • getFinishedLookBehinds

      public Set<LookBehindAssertion> getFinishedLookBehinds()
    • getStateSet

      public StateSet<RegexAST,? extends RegexASTNode> getStateSet()
    • hasPrefixStates

      public boolean hasPrefixStates()
    • setHasPrefixStates

      public void setHasPrefixStates(boolean value)
    • isMustAdvance

      public boolean isMustAdvance()
    • setMustAdvance

      public void setMustAdvance(boolean value)
    • getMatchedConditionGroupsMap

      public org.graalvm.collections.EconomicMap<Integer,TBitSet> getMatchedConditionGroupsMap()
    • getMatchedConditionGroups

      public TBitSet getMatchedConditionGroups(RegexASTNode t)
    • getMatchedConditionGroupsDebug

      public TBitSet getMatchedConditionGroupsDebug()
    • hasTransitionToAnchoredFinalState

      public boolean hasTransitionToAnchoredFinalState(boolean forward)
    • getTransitionToAnchoredFinalStateId

      public short getTransitionToAnchoredFinalStateId(boolean forward)
    • getTransitionToAnchoredFinalState

      public NFAStateTransition getTransitionToAnchoredFinalState(boolean forward)
    • hasTransitionToUnAnchoredFinalState

      public boolean hasTransitionToUnAnchoredFinalState(boolean forward)
      Specified by:
      hasTransitionToUnAnchoredFinalState in class BasicState<NFAState,NFAStateTransition>
    • getTransitionToUnAnchoredFinalState

      public NFAStateTransition getTransitionToUnAnchoredFinalState(boolean forward)
    • getTransitionToUnAnchoredFinalStateId

      public short getTransitionToUnAnchoredFinalStateId(boolean forward)
    • hasTransitionToFinalState

      public boolean hasTransitionToFinalState(boolean forward)
    • getFirstTransitionToFinalStateIndex

      public int getFirstTransitionToFinalStateIndex(boolean forward)
    • getFirstTransitionToFinalState

      public NFAStateTransition getFirstTransitionToFinalState(boolean forward)
    • addLoopBackNext

      public void addLoopBackNext(NFAStateTransition transition)
    • removeLoopBackNext

      public void removeLoopBackNext()
    • setSuccessors

      public void setSuccessors(NFAStateTransition[] transitions, boolean createReverseTransitions)
    • removeSuccessor

      public void removeSuccessor(NFAState state)
    • linkPredecessors

      public void linkPredecessors()
    • getPossibleResults

      public TBitSet getPossibleResults()
      Set of possible pre-calculated result indices as generated by the NFATraceFinderGenerator. 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

      public String idToString()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • createTransitionsArray

      protected NFAStateTransition[] createTransitionsArray(int length)
      Specified by:
      createTransitionsArray in class BasicState<NFAState,NFAStateTransition>
    • toJson

      public JsonObject toJson()
      Specified by:
      toJson in interface JsonConvertible
    • toJson

      public JsonObject toJson(boolean forward)