public class Rule
extends java.lang.Object
A grammar rule maps a single NonterminalSymbol to zero or more symbols (either Terminals
or further Nonterminals).
| Modifier and Type | Field and Description |
|---|---|
RightHandSide |
rhs |
NonterminalSymbol |
symbol |
| Constructor and Description |
|---|
Rule(NonterminalSymbol symbol,
java.util.List<Symbol> rhs)
Construct a new rule mapping the nonterminal to a sequence of symbols.
|
Rule(NonterminalSymbol symbol,
Symbol... rhs)
Construct a new rule mapping the nonterminal to a sequence of symbols.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
epsilonRule() |
boolean |
equals(java.lang.Object obj) |
RightHandSide |
getRhs()
The sequence of symbols that comprise the definition of the rule's nonterminal.
|
java.util.List<State> |
getSlots() |
NonterminalSymbol |
getSymbol()
The nonterminal symbol defined by this rule.
|
int |
hashCode() |
java.lang.String |
toString()
Pretty print a node.
|
public final NonterminalSymbol symbol
public final RightHandSide rhs
public Rule(NonterminalSymbol symbol, Symbol... rhs)
If the sequence of symbols is empty or null, then the nonterminal maps to "ε", that is to say, it's allowed to be absent.
symbol - The nonterminal.rhs - The sequence of symbols.public Rule(NonterminalSymbol symbol, java.util.List<Symbol> rhs)
If the sequence of symbols is empty or null, then the nonterminal maps to "ε", that is to say, it's allowed to be absent.
symbol - The nonterminal.rhs - The list of symbols.public NonterminalSymbol getSymbol()
public RightHandSide getRhs()
Note: although a rule may be defined with a null "right hand side", this method always returns an empty list in such cases.
public boolean epsilonRule()
public java.util.List<State> getSlots()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object