Record Class Item

java.lang.Object
java.lang.Record
org.libxmq.imp.ixml.earley.Item
Record Components:
production - the production being matched
dot - how many symbols of the production have been matched
origin - the input position where the production started

public record Item(Grammar.Production production, int dot, int origin) extends Record
An Earley item: a production with a dot showing how much of it has been matched, and the origin, the input position where the match started. The item (S → S · '+' M, 0) in set 1 means: starting at position 0, the input up to position 1 matches S, and now a '+' is expected.
  • Constructor Details

    • Item

      public Item(Grammar.Production production, int dot, int origin)
      Creates an instance of a Item record class.
      Parameters:
      production - the value for the production record component
      dot - the value for the dot record component
      origin - the value for the origin record component
  • Method Details

    • isComplete

      public boolean isComplete()
      Returns true if all symbols have been matched.
      Returns:
      true if the dot is at the end
    • next

      public Grammar.Symbol next()
      The symbol after the dot, the one expected next.
      Returns:
      the symbol, or null if the item is complete
    • advance

      public Item advance()
      The same item with the dot moved over the next symbol.
      Returns:
      the advanced item
    • toString

      public 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 the compare method from their corresponding wrapper classes.
      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.
    • production

      public Grammar.Production production()
      Returns the value of the production record component.
      Returns:
      the value of the production record component
    • dot

      public int dot()
      Returns the value of the dot record component.
      Returns:
      the value of the dot record component
    • origin

      public int origin()
      Returns the value of the origin record component.
      Returns:
      the value of the origin record component