|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--torero.model.Grammar
This class represents a complete Grammar consisting of Symbols, Productions (Rules) and a Start Symbol. It has some Methods to build a full Grammar step-by-step. This methods a mainly called by the yacc file parser.
Field Summary | |
AdditionalGrammarInfo |
addinfo
|
Constructor Summary | |
Grammar()
This is an ordinary constructor to get a new instance of an empty Grammar. |
Method Summary | |
void |
addProduction(String LHSString,
String[] RHSStrings,
String PrecString)
This method allows to add a new Production to the grammar. |
void |
declareLiteral(String literal)
A new Literal (Token Symbol) is created and added to the SymbolMap. |
void |
declareLiteral(String literal,
int toknum)
A new Literal (Token Symbol) is created and added to the SymbolMap. |
void |
declareLiteral(String literal,
String assocType,
int precLevel)
A new Literal (Token Symbol) is created and added to the SymbolMap. |
void |
declareLiteral(String literal,
String assocType,
int precLevel,
int toknum)
A new Literal (Token Symbol) is created and added to the SymbolMap. |
void |
declareStartSymbol(String ssymbol)
Use this method to define the Start Symbol for the Grammar (it's created as NonTerm). |
void |
declareToken(String token)
A new Token Symbol is created and added to the SymbolMap. |
void |
declareToken(String token,
int toknum)
A new Token Symbol is created and added to the SymbolMap. |
void |
declareToken(String token,
String assocType,
int precLevel)
A new Token Symbol is created and added to the SymbolMap. |
void |
declareToken(String token,
String assocType,
int precLevel,
int toknum)
A new Token Symbol is created and added to the SymbolMap. |
ProductionMap |
getProductionMap()
Returns the ProductionMap that contains all Productions defined in this Grammar. |
Nonterm |
getStartSymbol()
Returns the Start Symbol of this Grammar. |
SymbolMap |
getSymbolMap()
Returns the SymbolMap that contains all Symbols defined in this Grammar. |
String |
toString()
Returns a String Representation of this grammar. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public AdditionalGrammarInfo addinfo
Constructor Detail |
public Grammar()
Method Detail |
public void declareToken(String token)
token
- takes the name of the token that will be createdpublic void declareLiteral(String literal)
literal
- takes the name of the Token that will be created - the name is also used as word expression of the Tokenpublic void declareToken(String token, String assocType, int precLevel)
token
- takes the name of the token that will be createdassocType
- takes the Association Type for the Symbol (Yacc Specific)precLevel
- takes the Precedence Level for the Symbol (Yacc Specific)public void declareLiteral(String literal, String assocType, int precLevel)
literal
- takes the name of the Token that will be created - the name is also used as word expression of the TokenassocType
- takes the Association Type for the Symbol (Yacc Specific)precLevel
- takes the Precedence Level for the Symbol (Yacc Specific)public void declareToken(String token, int toknum)
token
- takes the name of the token that will be createdtoknum
- takes the Token Number for the Symbol (Yacc Specific)public void declareLiteral(String literal, int toknum)
literal
- takes the name of the Token that will be created - the name is also used as word expression of the Tokentoknum
- takes the Token Number for the Symbol (Yacc Specific)public void declareToken(String token, String assocType, int precLevel, int toknum)
token
- takes the name of the token that will be createdassocType
- takes the Association Type for the Symbol (Yacc Specific)precLevel
- takes the Precedence Level for the Symbol (Yacc Specific)toknum
- takes the Token Number for the Symbol (Yacc Specific)public void declareLiteral(String literal, String assocType, int precLevel, int toknum)
literal
- takes the name of the Token that will be created - the name is also used as word expression of the TokenassocType
- takes the Association Type for the Symbol (Yacc Specific)precLevel
- takes the Precedence Level for the Symbol (Yacc Specific)toknum
- takes the Token Number for the Symbol (Yacc Specific)public void declareStartSymbol(String ssymbol)
public Nonterm getStartSymbol()
public ProductionMap getProductionMap()
public SymbolMap getSymbolMap()
public void addProduction(String LHSString, String[] RHSStrings, String PrecString)
LHSString
- takes the name of the LHS Symbol of the new Production (if not already done also a Nonterm Symbol is created)RHSStrings
- takes a String Array that contains the names of the RHS Symbols - an empty Array causes Epsilon as RHS (creating Nonterm Symbols for not previously defined Symbols is the default)PrecString
- takes null or the name of the precedence token (yacc specific extension)public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |