Package org.nineml.coffeegrinder.parser
Class RightHandSide
- java.lang.Object
-
- org.nineml.coffeegrinder.parser.RightHandSide
-
public class RightHandSide extends java.lang.ObjectA utility class for what appears on the "right hand side" of a production in a grammar.
-
-
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 booleanequals(java.lang.Object obj)Symbolget(int pos)Get the symobl at the specified position.SymbolgetFirst()The first symbol on the right hand side.inthashCode()booleanisEmpty()Is the right hand side empty?
-
-
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-