|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.hu.cs.titokone.SymbolTable
This class represents the symbol table of a TTK-91 program. It contains symbols with defined values. It also contains DEF-definitions, which are like symbols except the value is String. Symbols and DEFs are in separated maps.
Field Summary | |
private java.util.HashMap |
definitions
This field contains the SymbolTable's definitions. |
private java.util.HashMap |
symbols
This field contains the SymbolTable's symbols. |
Constructor Summary | |
SymbolTable()
|
Method Summary | |
void |
addDefinition(java.lang.String key,
java.lang.String value)
This method adds a new definition. |
void |
addSymbol(java.lang.String symbolName,
int symbolValue)
This method adds a new symbol to the symbol table. |
java.lang.String[] |
getAllDefinitions()
This method returns a string array that contains all the currently made definitions. |
java.lang.String[] |
getAllSymbols()
This method returns a string array that contains all the currently defined symbols. |
java.lang.String |
getDefinition(java.lang.String key)
This function returns the string value that corresponds to a given definition. |
int |
getSymbol(java.lang.String symbolName)
This function returns the integer value that corresponds to a given symbol. |
java.util.HashMap |
toHashMap()
This method returns the symbol table as a hashmap. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.util.HashMap symbols
private java.util.HashMap definitions
Constructor Detail |
public SymbolTable()
Method Detail |
public int getSymbol(java.lang.String symbolName) throws InvalidSymbolException
symbolName
- Name of the symbol.
InvalidSymbolException
- If there is no such
symbol in the SymbolTable.public java.lang.String[] getAllSymbols()
public void addSymbol(java.lang.String symbolName, int symbolValue)
symbolName
- Name of the symbol.symbolValue
- Integer value of the symbol.public void addDefinition(java.lang.String key, java.lang.String value)
key
- The name of the definition.value
- The value to be attached to the name.public java.lang.String getDefinition(java.lang.String key) throws InvalidDefinitionException
key
- Name of the definition.
InvalidDefinitionException
- If there is no such
definition in the SymbolTable.public java.lang.String[] getAllDefinitions()
public java.util.HashMap toHashMap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |