public class Production extends Object implements GrammarEntity, Cloneable
AlphabetSymbol
s that a NonTerminal
can derive. A production contains
a list of AlphabetSymbol
that the production produces. A production belongs to
at most one NonTerminal.Constructor and Description |
---|
Production(AlphabetSymbol... symbols) |
Production(LinkedList<AlphabetSymbol> us) |
Production(List<AlphabetSymbol> us) |
Production(Production p)
Clones the production p to the constructed object
|
Modifier and Type | Method and Description |
---|---|
void |
accept(GrammarEntityVisitor visitor)
Accepts the given grammar entity visitor in a visitor pattern
|
NonTerminal |
getNonTerminal()
Gets the non terminal that this production belongs to
|
NonTerminal |
getSingleProduction()
Returns A if this productions is of the type -> A, else returns null
|
LinkedList<AlphabetSymbol> |
getUs()
Gets the list of
AlphabetSymbol in this production of type U* in the Grammar |
boolean |
isEpsilonProduction()
Returns true iff the production only contains a single node that is an ε terminal, See
Terminal.isEpsilon() |
boolean |
isWhiteSpace()
Return true if this grammar entity contains only whitespace
|
void |
remove()
Removes this production from the NonTerminal that it belongs to.
|
void |
replace(NonTerminal symbol,
Production symbolP)
Replaces the given nonTerminal by the list of
AlphabetSymbol
that the given production produces. |
String |
toString() |
public Production(AlphabetSymbol... symbols)
public Production(LinkedList<AlphabetSymbol> us)
public Production(List<AlphabetSymbol> us)
public Production(Production p)
p
- public void accept(GrammarEntityVisitor visitor)
GrammarEntity
accept
in interface GrammarEntity
public NonTerminal getNonTerminal()
public NonTerminal getSingleProduction()
public LinkedList<AlphabetSymbol> getUs()
AlphabetSymbol
in this production of type U* in the Grammar
public boolean isEpsilonProduction()
Terminal.isEpsilon()
public boolean isWhiteSpace()
GrammarEntity
isWhiteSpace
in interface GrammarEntity
public void remove()
public void replace(NonTerminal symbol, Production symbolP)
AlphabetSymbol
that the given production produces.symbol
- symbolP
- Copyright © 2008-2013 Mathias Schwarz.