Class Token.Quantifier

java.lang.Object
com.oracle.truffle.regex.tregex.parser.Token
com.oracle.truffle.regex.tregex.parser.Token.Quantifier
All Implemented Interfaces:
JsonConvertible
Enclosing class:
Token

public static final class Token.Quantifier extends Token
  • Field Details

  • Constructor Details

    • Quantifier

      public Quantifier(int min, int max, boolean greedy, boolean possessive, boolean singleChar)
  • Method Details

    • isInfiniteLoop

      public boolean isInfiniteLoop()
    • getMin

      public int getMin()
      The minimum number of times the quantified element must appear. Can be -1 to represent a virtually infinite number of occurrences are necessary (e.g. as in a{1111111111111111111,}). Any number which is larger than the maximum size of the platform's String data type is considered "virtually infinite".
    • getMax

      public int getMax()
    • isGreedy

      public boolean isGreedy()
    • isPossessive

      public boolean isPossessive()
    • isSingleChar

      public boolean isSingleChar()
      Returns true iff the quantifier was created from a shorthand character, i.e. one of '?', '*' or '+'.
    • hasIndex

      public boolean hasIndex()
    • getIndex

      public int getIndex()
    • setIndex

      public void setIndex(int index)
    • hasZeroWidthIndex

      public boolean hasZeroWidthIndex()
    • getZeroWidthIndex

      public int getZeroWidthIndex()
    • setZeroWidthIndex

      public void setZeroWidthIndex(int zeroWidthIndex)
    • isWithinThreshold

      public boolean isWithinThreshold(int threshold)
      Returns true iff both getMin() and getMax() are less or equal to the given threshold, or infinite isInfiniteLoop().
    • isUnrollTrivial

      public boolean isUnrollTrivial()
      Returns true iff "unrolling" this quantifier is trivial, i.e. nothing has to be duplicated. This is the case for quantifiers ? and *.
    • isDead

      public boolean isDead()
      Returns true if the quantified term can never match. This is the case when:
      • The minimum is virtually infinite (i.e. greater than the maximum string length).
      • The minimum is larger than the maximum. This is usually a syntax error.
    • hashCode

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

      public boolean equalsSemantic(Token.Quantifier o)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

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

      public String toStringNoSuffix()
    • toJson

      public JsonObject toJson()
      Specified by:
      toJson in interface JsonConvertible
      Overrides:
      toJson in class Token