|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.chaperon.model.grammar.Grammar
public class Grammar
This class represents a model for a grammar. The content of the grammar includes the productions, start symbol, associativities and priorities.
Constructor Summary | |
---|---|
Grammar()
Creates an empty grammar. |
Method Summary | |
---|---|
int |
addProduction(Production production)
Add a production to this grammar. |
void |
addProduction(Production[] list)
Add a list of productions to this grammar. |
java.lang.Object |
clone()
Creates a clone of this grammar. |
boolean |
contains(Production production)
If the grammar contains a production. |
boolean |
contains(Symbol ntsymbol)
If the grammar contains a production with this nonterminal symbol. |
Associativity |
getAssociativity(Production production)
Return the associativity of a production in this grammar. |
Associativity |
getAssociativity(Terminal terminal)
Return the associativity of a terminal symbol. |
java.lang.String |
getLocation()
Returns the location from the input source. |
int |
getPriority(Production production)
Return the priority of a production in this grammar. |
int |
getPriority(Terminal terminal)
Returns the priority of a terminal symbol. |
Production[] |
getProduction()
Returns the production, which this grammar contains, as an array. |
Production |
getProduction(int index)
Return a production giving by an index. |
int |
getProductionCount()
Returns the count of productions in this grammar. |
IntegerList |
getProductionList(Symbol ntsymbol)
Returns all production for given nonterminal symbol as a list of indices. |
Production[] |
getProductions(Symbol ntsymbol)
|
Nonterminal |
getStartSymbol()
Return the start symbol. |
SymbolSet |
getSymbols()
Return all used symbol in this grammar. |
int |
indexOf(Production production)
Return the index of a production. |
int |
indexOf(Symbol ntsymbol)
Return the index of the next production, which found by a nonterminal symbol. |
void |
removeAllProduction()
Removes all productions from this grammar. |
void |
removeProduction(int index)
Removes a production by an index from this grammar. |
void |
setAssociativity(Terminal terminal,
Associativity assoc)
Set the associativity of a terminal symbol. |
void |
setLocation(java.lang.String location)
Set the location from the input source. |
void |
setPriority(Terminal terminal,
int priority)
Set a priority of a terminal symbol. |
void |
setProduction(int index,
Production production)
Replace a production by an index in this grammar. |
void |
setProduction(Production[] productionArray)
Replace the productions of this grammar by an array of productions. |
void |
setStartSymbol(Nonterminal startsymbol)
Set the start symbol for this grammar. |
java.lang.String |
toString()
Return a string representation of the grammar. |
Violations |
validate()
Validated the grammar. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Grammar()
Method Detail |
---|
public int addProduction(Production production)
production
- Production, which should be added.
public void addProduction(Production[] list)
list
- Array of productions.public void removeProduction(int index)
index
- Index of the production, which should be removed.public void setProduction(int index, Production production)
index
- The index, at which the productionshould be replaced.production
- The production.public Production getProduction(int index)
index
- Index of the Production.
public IntegerList getProductionList(Symbol ntsymbol)
ntsymbol
- Nonterminal symbol
public Production[] getProductions(Symbol ntsymbol)
public int getProductionCount()
public int indexOf(Production production)
production
- The production.
public int indexOf(Symbol ntsymbol)
ntsymbol
- Nonterminal symbol
public boolean contains(Production production)
production
- The production, which the grammar should contain.
public boolean contains(Symbol ntsymbol)
ntsymbol
- Nonterminal symbol.
public void removeAllProduction()
public Production[] getProduction()
public void setProduction(Production[] productionArray)
productionArray
- Array of productions.public void setPriority(Terminal terminal, int priority)
terminal
- Terminal symbol.priority
- Priority of the symbol.public int getPriority(Terminal terminal)
terminal
- Terminal symbol.
public int getPriority(Production production)
production
- Production.
public void setAssociativity(Terminal terminal, Associativity assoc)
terminal
- Terminal symbol.assoc
- Associativity of the symbol.public Associativity getAssociativity(Terminal terminal)
terminal
- Terminal symbol.
public Associativity getAssociativity(Production production)
production
- Production.
public SymbolSet getSymbols()
public void setStartSymbol(Nonterminal startsymbol)
startsymbol
- Start symbol.public Nonterminal getStartSymbol()
public void setLocation(java.lang.String location)
location
- Location in the input source.public java.lang.String getLocation()
public Violations validate()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- If an exception occurs during the cloning.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |