Class RightHandSide


  • public class RightHandSide
    extends java.lang.Object
    A utility class for what appears on the "right hand side" of a production in a grammar.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int length
      The length of the right hand side.
      Symbol[] symbols
      The symbols on the right hand side.
    • Constructor Summary

      Constructors 
      Constructor Description
      RightHandSide​(java.util.List<Symbol> symbols)
      Create a right hand side from the list of symbols.
      RightHandSide​(Symbol[] symbols)
      Create a right hand side from the array of symbols.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      Symbol get​(int pos)
      Get the symobl at the specified position.
      Symbol getFirst()
      The first symbol on the right hand side.
      int hashCode()  
      boolean isEmpty()
      Is the right hand side empty?
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • symbols

        public final Symbol[] symbols
        The symbols on the right hand side.
      • length

        public final int length
        The length of the right hand side.
    • Constructor Detail

      • RightHandSide

        public RightHandSide​(Symbol[] symbols)
        Create a right hand side from the array of symbols.
        Parameters:
        symbols - the symbols.
      • RightHandSide

        public RightHandSide​(java.util.List<Symbol> symbols)
        Create a right hand side from the list of symbols.
        Parameters:
        symbols - the symbols.
    • Method Detail

      • get

        public Symbol get​(int pos)
        Get the symobl at the specified position.
        Parameters:
        pos - the position
        Returns:
        the symbol
        Throws:
        java.lang.IndexOutOfBoundsException - if the position is out of bounds.
      • getFirst

        public Symbol getFirst()
        The first symbol on the right hand side.
        Returns:
        The symbol or null if there are no symbols.
      • isEmpty

        public boolean isEmpty()
        Is the right hand side empty?
        Returns:
        true if it is.
      • 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