Package org.nineml.coffeegrinder.parser
Class Rule
- java.lang.Object
-
- org.nineml.coffeegrinder.parser.Rule
-
public class Rule extends java.lang.ObjectA grammar rule.A grammar rule maps a single
NonterminalSymbolto zero or moresymbols(eitherTerminalsor furtherNonterminals).
-
-
Field Summary
Fields Modifier and Type Field Description RightHandSiderhsNonterminalSymbolsymbol
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanepsilonRule()booleanequals(java.lang.Object obj)RightHandSidegetRhs()The sequence of symbols that comprise the definition of the rule's nonterminal.java.util.List<State>getSlots()NonterminalSymbolgetSymbol()The nonterminal symbol defined by this rule.inthashCode()java.lang.StringtoString()Pretty print a node.
-
-
-
Field Detail
-
symbol
public final NonterminalSymbol symbol
-
rhs
public final RightHandSide rhs
-
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Pretty print a node.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the node.
-
-