Class PositionAssertion

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

public class PositionAssertion extends Term
An assertion that succeeds when encountered at the beginning or at the end of the string we are searching in.

Corresponds to the ^ and $ right-hand sides of the Assertion goal symbol in the ECMAScript RegExp syntax.

PositionAssertion nodes are also used for state sets of NFA initial states, which is why they can have a next-pointer (getNext()), see RegexAST.getNFAAnchoredInitialState(int).

  • Field Details

  • Method Details

    • copy

      public PositionAssertion 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 Term 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 isCaret(), then this returns the next expression. If this isDollar(), then this returns the previous expression.
    • setNext

      public void setNext(RegexASTNode next)
    • isCaret

      public boolean isCaret()
      Overrides:
      isCaret in class RegexASTNode
    • isDollar

      public boolean isDollar()
      Overrides:
      isDollar in class RegexASTNode
    • 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()