Class NonterminalSymbol


  • public class NonterminalSymbol
    extends Symbol
    A nonterminal symbol in the grammar.

    Every nonterminal must be defined by a Rule in the Grammar.

    • Field Detail

      • symbolName

        public final java.lang.String symbolName
    • Method Detail

      • getName

        public java.lang.String getName()
        The name of this symbol.
        Returns:
        the name of the symbol.
      • matches

        public final boolean matches​(Symbol input)
        Are these the same symbol?
        Specified by:
        matches in class Symbol
        Parameters:
        input - The symbol.
        Returns:
        true if they're the same nonterminal symbol.
      • matches

        public final boolean matches​(Token input)
        Does this symbol match the input token?

        No, it does not. No nonterminal ever matches an input token.

        Specified by:
        matches in class Symbol
        Parameters:
        input - The token.
        Returns:
        false
      • equals

        public boolean equals​(java.lang.Object obj)
        Test nonterminals for equality.

        Two nonterminals are equal if they have the same name.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - An object.
        Returns:
        true if obj is equal to this nonterminal.
      • hashCode

        public int hashCode()
        Assure that equal nonterminals return the same hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code.
      • toString

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