public class NonTerminal extends Object implements AlphabetSymbol
Grammar
. Nonterminals are
mutable but the set of productions can be iterated safely while adding and removing using the methods in this class. The list
being iterated remains the same while the productions are updated. The set of productions is a set in the sense that
the same production can only be in this set once. The productions are however note required immutable or to have a fixed
hash code
or equals
result.Constructor and Description |
---|
NonTerminal()
Constructs a fresh non terminal
|
NonTerminal(NonTerminal n)
Constructs a new nonterminal that will play the same role as n in the grammar, thus inheriting
code locations and other meta information
|
Modifier and Type | Method and Description |
---|---|
void |
accept(GrammarEntityVisitor visitor)
Accepts the given grammar entity visitor in a visitor pattern
|
void |
addAll(Collection<Production> productions)
Adds all productions in the list to the set of productions in
|
void |
addProduction(Production production)
Adds a production to the set of productions.
|
void |
ensureSet()
Ensure that there are no duplicate productions in the set of productions.
|
Collection<Production> |
getProductions()
Returns a list of all productions from this nonterminal.
|
boolean |
isTaint() |
boolean |
isWhiteSpace()
Return true if this grammar entity contains only whitespace
|
void |
removeProduction(Production production)
Removes a production from the set of productions
|
void |
setProductions(Collection<Production> productions)
Sets the set of productions the the contents of the given collection
|
void |
setTaint(boolean taint) |
public NonTerminal()
public NonTerminal(NonTerminal n)
n
- public void accept(GrammarEntityVisitor visitor)
GrammarEntity
accept
in interface GrammarEntity
public void addAll(Collection<Production> productions)
productions
- public void addProduction(Production production)
production
- public void ensureSet()
public Collection<Production> getProductions()
unmodifiable
.
Use the methods on NonTerminal to change the set of productions.public boolean isTaint()
public boolean isWhiteSpace()
GrammarEntity
isWhiteSpace
in interface GrammarEntity
public void removeProduction(Production production)
production
- public void setProductions(Collection<Production> productions)
productions
- public void setTaint(boolean taint)
Copyright © 2008-2013 Mathias Schwarz.