|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSymbolTable
public class SymbolTable
This class manages one or more symbol tables for a compiler. Tables are indexed from 0.
Field Summary | |
---|---|
private java.util.HashMap[] |
tables
|
Constructor Summary | |
---|---|
SymbolTable()
Construct a new SymbolTable manager with one table. |
|
SymbolTable(int n)
Construct a new SymbolTable manager with n tables. |
Method Summary | |
---|---|
Symbol |
getSymbol(int k,
java.lang.String key)
Get a symbol from table[k]. |
boolean |
isDeclared(int k,
java.lang.String key)
Check to see if a symbol is in table[k]. |
boolean |
isDeclared(java.lang.String key)
Check to see if a symbol is in any of the defined tables. |
Symbol |
putSymbol(int k,
java.lang.String key,
Symbol s)
Add a symbol to table[k]. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.HashMap[] tables
Constructor Detail |
---|
public SymbolTable()
public SymbolTable(int n)
n
- number of distinct tables to manage.Method Detail |
---|
public Symbol putSymbol(int k, java.lang.String key, Symbol s)
k
- the table number to use. Must be 0 to n-1, where n is
the number of defined tables.key
- the key (the symbol label) to use for this Symbols
- the Symbol to add.
public Symbol getSymbol(int k, java.lang.String key)
k
- the table number to use. Must be 0 to n-1, where n is
the number of defined tables.key
- the key (the symbol label) used for this Symbol
public boolean isDeclared(int k, java.lang.String key)
k
- the table number to use. Must be 0 to n-1, where n is
the number of defined tables.key
- the key (the symbol label) used for this Symbol
public boolean isDeclared(java.lang.String key)
key
- the key (the symbol label) used for this Symbol
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |