Class MatchFound

All Implemented Interfaces:
AbstractState<Term,ASTTransition>, JsonConvertible

public class MatchFound extends Term
MatchFound nodes are RegexASTNodes that represent the initial/final states of the non-deterministic finite state automaton generated from the regular expression.

Regular expressions are translated into non-deterministic finite state automata, with each RegexASTNode in the RegexAST contributing some of the states or transitions. The MatchFound nodes are those that contribute the final (accepting) states. The root group of every regular expression is linked (using the 'next' pointer) to a single MatchFound node. Other MatchFound nodes appear in look-behind and look-ahead assertions, where they contribute the final states of their subautomata (look-around assertions generate subautomata which are then joined with the root automaton using a product construction).

MatchFound nodes are also used as initial states (the initial states of the forward search automaton are the final states of the reverse search automaton). Therefore, there is a set of MatchFound nodes used as final states in forward search (reachable by 'next' pointers) and as initial states in reverse search and a set of MatchFound nodes used as final states in reverse search (reachable by 'prev' pointers) and as initial states in forward search. MatchFound being used as NFA initial states is also why they can have a next-pointer ( getNext()) themselves (see RegexAST.getNFAUnAnchoredInitialState(int)).

  • Constructor Details

    • MatchFound

      public MatchFound()
  • Method Details

    • copy

      public MatchFound copy(RegexAST ast)
      Description copied from class: RegexASTNode
      Copy this node only, without any child nodes. The ID and minPath of the copied nodes is left unset.
      Specified by:
      copy in class Term
      Parameters:
      ast - RegexAST the node should belong to.
      Returns:
      A shallow copy of this node.
    • copyRecursive

      public MatchFound copyRecursive(RegexAST ast, CompilationBuffer compilationBuffer)
      Description copied from class: RegexASTNode
      Recursively copy this subtree. This method should be used instead of CopyVisitor if the copying process is required to be thread-safe. The ID and minPath of the copied nodes is left unset.
      Specified by:
      copyRecursive in class Term
      Parameters:
      ast - RegexAST the new nodes should belong to.
      Returns:
      A deep copy of this node.
    • getNext

      public RegexASTNode getNext()
      Points to the body of a regular expression when this node is treated as an initial state of an NFA. If this node represents an initial state, then this points to the first expression. If this node represents a final state, then this points to the last expression.
    • setNext

      public void setNext(RegexASTNode next)
    • equalsSemantic

      public boolean equalsSemantic(RegexASTNode obj)
      Specified by:
      equalsSemantic in class RegexASTNode
    • toString

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

      public JsonValue toJson()