Class BackReference

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

public class BackReference extends QuantifiableTerm
A reference to the contents of a previously matched capturing group.

Corresponds to the goal symbol DecimalEscape in the ECMAScript RegExp syntax.

Currently not implemented in TRegex and so any use of this node type causes TRegex to bail out.

  • Method Details

    • copy

      public BackReference 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 QuantifiableTerm
      Parameters:
      ast - RegexAST the node should belong to.
      Returns:
      A shallow copy of this node.
    • copyRecursive

      public BackReference 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.
    • getGroupNumbers

      public int[] getGroupNumbers()
      Returns the capture group numbers this back-reference is referring to, e.g. the referenced groups of \1 is [1] and the references groups of \k<x> in (?:(?<x>a|?<x>b))\k<x> is [1, 2].
    • isNestedBackReference

      public boolean isNestedBackReference()
      Returns true iff this back-reference refers to its own parent group. In order for this to be true, all of the target group numbers must be nested references.
    • setNestedBackReference

      public void setNestedBackReference()
    • isForwardReference

      public boolean isForwardReference()
      Returns true iff this "back-reference" is actually a reference to a later group in the expression. In order for this to be true, all of the target group numbers must be forward references.
    • setForwardReference

      public void setForwardReference()
    • isNestedOrForwardReference

      public boolean isNestedOrForwardReference()
      Returns true iff this "back-reference" is actually a reference to its own parent group or a later group in the expression. In order for this to be true, all of the target group numbers must either be referenced or nested references. In JavaScript, such nested/forward references will always match the empty string.
    • setNestedOrForwardReference

      public void setNestedOrForwardReference()
    • isIgnoreCaseReference

      public boolean isIgnoreCaseReference()
    • setIgnoreCaseReference

      public void setIgnoreCaseReference()
    • isIgnoreCaseReferenceAltMode

      public boolean isIgnoreCaseReferenceAltMode()
    • setIgnoreCaseReferenceAltMode

      public void setIgnoreCaseReferenceAltMode()
    • isUnrollingCandidate

      public boolean isUnrollingCandidate()
      Description copied from class: QuantifiableTerm
      Returns true iff the parser should try to unroll this term's quantifier.
      Specified by:
      isUnrollingCandidate in class QuantifiableTerm
    • equalsSemantic

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

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

      public JsonValue toJson()