Record Class Quantifier

java.lang.Object
java.lang.Record
com.orbit.parse.Quantifier
All Implemented Interfaces:
Expr

public record Quantifier(Expr child, int min, OptionalInt max, boolean possessive, boolean lazy) extends Record implements Expr
Represents a quantified sub-expression with optional laziness or possessive semantics.

The lazy and possessive fields are mutually exclusive: if possessive is true, lazy must be false. A greedy quantifier has both fields false.

Instances are immutable and safe for use by multiple concurrent threads.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Quantifier(Expr child, int min, OptionalInt max, boolean possessive)
    Creates a greedy quantifier (neither lazy nor possessive).
    Quantifier(Expr child, int min, OptionalInt max, boolean possessive, boolean lazy)
    Creates a Quantifier, validating all invariants.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the child record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the lazy record component.
    max()
    Returns the value of the max record component.
    int
    min()
    Returns the value of the min record component.
    boolean
    Returns the value of the possessive record component.
    Returns the source location information for this expression.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Quantifier

      public Quantifier(Expr child, int min, OptionalInt max, boolean possessive, boolean lazy)
      Creates a Quantifier, validating all invariants.
    • Quantifier

      public Quantifier(Expr child, int min, OptionalInt max, boolean possessive)
      Creates a greedy quantifier (neither lazy nor possessive).
      Parameters:
      child - the quantified sub-expression; must not be null
      min - the minimum repetition count; must be >= 0
      max - the maximum repetition count; empty means unbounded
      possessive - true for possessive (atomic) semantics
  • Method Details

    • span

      public SourceSpan span()
      Description copied from interface: Expr
      Returns the source location information for this expression.
      Specified by:
      span in interface Expr
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • child

      public Expr child()
      Returns the value of the child record component.
      Returns:
      the value of the child record component
    • min

      public int min()
      Returns the value of the min record component.
      Returns:
      the value of the min record component
    • max

      public OptionalInt max()
      Returns the value of the max record component.
      Returns:
      the value of the max record component
    • possessive

      public boolean possessive()
      Returns the value of the possessive record component.
      Returns:
      the value of the possessive record component
    • lazy

      public boolean lazy()
      Returns the value of the lazy record component.
      Returns:
      the value of the lazy record component