Class State

java.lang.Object
org.nineml.coffeegrinder.parser.State

public class State extends Object
States (or Earley items) in the chart. FIXME: this API is in flux.
  • Field Details

  • Method Details

    • nextSymbol

      public Symbol nextSymbol()
      Get the next symbol

      If the state has more symbols, return the symbol that occurs after the current position.

      Returns:
      the next symbol, or null if position is last
    • prevSymbol

      public Symbol prevSymbol()
    • getDescriptor

      public Descriptor getDescriptor(int k, int i)
    • getSymbol

      public NonterminalSymbol getSymbol()
      Get the nonterminal associated with this state
      Returns:
      the symbol
    • getRule

      public Rule getRule()
      Get the rule that originated this state.
      Returns:
      the rule
    • getRhs

      public RightHandSide getRhs()
      Get the list of symbols that define this state's nonterminal symbol.
      Returns:
      the list of symbols on the "right hand side"
    • getPosition

      public int getPosition()
      Get the current position in this state
      Returns:
      the position
    • advance

      public State advance()
      Get a new state with the position advanced by one
      Returns:
      a new state with the position advanced
      Throws:
      ParseException - if an attempt is made to advance a completed state
    • completed

      public boolean completed()
      Are we finished with this symbol?
      Returns:
      true if the position indicates that we've seen all of the symbols on the "right hand side"
    • getFirst

      public Set<Symbol> getFirst(ParserGrammar grammar)
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object