Class Rule

    • Constructor Detail

      • Rule

        public Rule​(NonterminalSymbol symbol,
                    Symbol... rhs)
        Construct a new rule mapping the nonterminal to a sequence of symbols.

        If the sequence of symbols is empty or null, then the nonterminal maps to "ε", that is to say, it's allowed to be absent.

        Parameters:
        symbol - The nonterminal.
        rhs - The sequence of symbols.
      • Rule

        public Rule​(NonterminalSymbol symbol,
                    java.util.List<Symbol> rhs)
        Construct a new rule mapping the nonterminal to a sequence of symbols.

        If the sequence of symbols is empty or null, then the nonterminal maps to "ε", that is to say, it's allowed to be absent.

        Parameters:
        symbol - The nonterminal.
        rhs - The list of symbols.
    • Method Detail

      • getSymbol

        public NonterminalSymbol getSymbol()
        The nonterminal symbol defined by this rule.
        Returns:
        The nonterminal symbol.
      • getRhs

        public RightHandSide getRhs()
        The sequence of symbols that comprise the definition of the rule's nonterminal.

        Note: although a rule may be defined with a null "right hand side", this method always returns an empty list in such cases.

        Returns:
        The sequence of symbols.
      • epsilonRule

        public boolean epsilonRule()
      • getSlots

        public java.util.List<State> getSlots()
      • equals

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

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

        public java.lang.String toString()
        Pretty print a node.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the node.