|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdspl.SymbolTable
public class SymbolTable
SymbolTable serves as a storage for all variables.
SymbolTable internally uses a HashMap to map identifiers
to their corresponding Variable
| Field Summary | |
|---|---|
private int |
nextFloatConstIDInt
|
private int |
nextStringIDInt
When strings are added to the symbol table, their identifier is set as "stringLabel#" where # is this number, must be unique, so we increment it on each call |
private java.util.HashMap |
symbolHashMap
HashMap used to map identifiers to Variable-typed objects for the Variable represented by the provided identifier |
| Fields inherited from interface dspl.frontend.ParserTokensTokenTypes |
|---|
ASSIGN, COMMA, COMMENT, DECLS, DIGITS, DIV, DOT, EOF, EQ, GE, GT, ID, LBRACE, LBRACK, LE, LITERAL_byte, LITERAL_byte_array, LITERAL_ccall, LITERAL_complex, LITERAL_complex_array, LITERAL_else, LITERAL_float, LITERAL_float_array, LITERAL_for, LITERAL_if, LITERAL_int, LITERAL_int_array, LITERAL_string, LITERAL_ubyte, LITERAL_ubyte_array, LITERAL_uint, LITERAL_uint_array, LITERAL_while, LPAREN, LT, MINUS, MUL, NE, NEGATE, NEWLINE, NULL_TREE_LOOKAHEAD, NUM, PLUS, PROGRAM, RBRACE, RBRACK, REAL, RPAREN, SEMI, STRING, TILDE, WS |
| Constructor Summary | |
|---|---|
SymbolTable()
Constructor for SymbolTable |
|
| Method Summary | |
|---|---|
Variable |
addStringVariable(java.lang.String identifier)
|
void |
addVariable(Variable v)
Adds the provided Variable to the Symbol table |
void |
constructTable(antlr.collections.AST tree)
Takes the AST that represents the program being compiled and adds all of the variables found to the Symbol table |
java.util.ArrayList |
getAllVariables()
|
java.lang.String |
getNextFloatConstID()
Provides unique label for each string added to the symbol table |
private java.lang.String |
getNextStringID()
Provides unique label for each string added to the symbol table |
Variable |
getVariable(java.lang.String identifier)
Returns the Variable corresponding to the identifier provided |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.HashMap symbolHashMap
private int nextStringIDInt
private int nextFloatConstIDInt
| Constructor Detail |
|---|
public SymbolTable()
| Method Detail |
|---|
private java.lang.String getNextStringID()
public java.lang.String getNextFloatConstID()
public void constructTable(antlr.collections.AST tree)
throws SymbolicException
tree -
SymbolicException
public void addVariable(Variable v)
throws SymbolicException
Note: The same symbol cannot be added to the symbol table multiple times
v -
SymbolicException
public Variable getVariable(java.lang.String identifier)
throws SymbolicException
the - identifier of the desired variable
SymbolicException
public Variable addStringVariable(java.lang.String identifier)
throws SymbolicException
SymbolicExceptionpublic java.util.ArrayList getAllVariables()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||