Class Item


  • public class Item
    extends java.lang.Object
    An Item is a parsing rule with a dot at the current symbol position. LR1 rules have an additional lookahead symbol.
    • Field Detail

      • rule

        public final Rule rule
      • dot

        public final int dot
      • follow

        public final java.util.Set<Symbol> follow
      • succ

        public java.util.List<Item> succ
    • Constructor Detail

      • Item

        public Item​(Rule rule,
                    int dot,
                    Symbol... follows)
    • Method Detail

      • addFollow

        public void addFollow​(Symbol sym)
      • addFollows

        public void addFollows​(java.util.Collection<Symbol> sym)
      • addToFollowSet

        public void addToFollowSet​(java.util.Map<Symbol,​Tuple<Symbol,​ItemSet>> map)
        Add the item set following this one to the follow set argument.
        Parameters:
        map - a map of follow sets, indexed by the lookahead symbol
      • immediateExtension

        public java.util.Collection<Item> immediateExtension​(Grammar grammar)
      • nullable

        public boolean nullable​(Grammar grammar)
        Returns true if this item is nullable.
      • nullableAfter

        public boolean nullableAfter​(int pos,
                                     Grammar grammar)
        Returns true if the symbols after the given position form a nullable sentence.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • canAdvance

        public boolean canAdvance()
      • afterDot

        public Symbol afterDot()
      • advance

        public Item advance()
      • baseItem

        public Item baseItem()
        Gives an item identical to this one but without follow symbol.
      • followSyms

        public java.util.Collection<Symbol> followSyms()
      • related

        public boolean related​(Symbol sym)
        Returns true if the this item is related to a conflict on symbol sym.