|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.norecess.citkit.symboltable.HashSymbolTable<A>
public class HashSymbolTable<A>
Implements a symbol table for a compiler of Hobbes and perhaps other languages
To create a new, initial symbol table, use HashSymbolTable()
. To
create a chained symbol table (for nested scopes), use
HashSymbolTable(SymbolTable)
.
Constructor Summary | |
---|---|
HashSymbolTable()
Builds a new, initial symbol table. |
|
HashSymbolTable(SymbolTable<A> previous)
Builds a new symbol table using the specified symbol table as the previous symbol table for the previous scope. |
Method Summary | |
---|---|
void |
add(java.lang.String name,
A value)
Adds a name with an associated value to the current symbol table.. |
void |
add(Symbol variable,
A value)
Adds a new variable to the current symbol table. |
boolean |
equals(java.lang.Object other)
|
A |
get(ISymbol variable)
Returns the value associated with the specified variable. |
A |
get(java.lang.String name)
Invokes get(ISymbol) . |
java.util.Set<Symbol> |
getSymbols()
Returns the symbols in the current scope. |
java.lang.String |
getVariablesAsString()
Returns the variables of the scope. |
int |
hashCode()
|
A |
set(java.lang.String name,
A value)
Sets a value associated with a name.. |
A |
set(Symbol variable,
A value)
Changes the value associated with the specified variable. |
A |
setInCurrentScope(Symbol variable,
A value)
Changes the value associated with the specified variable only in the current scope. |
java.lang.String |
toString()
The symbol table as a string. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HashSymbolTable()
public HashSymbolTable(SymbolTable<A> previous)
previous
- the previous symbol table.Method Detail |
---|
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void add(Symbol variable, A value)
SymbolTable
add
in interface SymbolTable<A>
variable
- the new variable to add to the symbol table.value
- the new value to associate with the new variable.public void add(java.lang.String name, A value)
SymbolTable
add
in interface SymbolTable<A>
SymbolTable.add(Symbol, Object)
public A get(ISymbol variable)
get
in interface SymbolTable<A>
variable
- the variable to search for.
null
if the
variable isn't found.public A get(java.lang.String name)
get(ISymbol)
.
get
in interface SymbolTable<A>
SymbolTable.get(ISymbol)
public java.util.Set<Symbol> getSymbols()
getSymbols
in interface SymbolTable<A>
public A set(Symbol variable, A value)
set
in interface SymbolTable<A>
variable
- the variable to search for.value
- the new value for the variable.
public A set(java.lang.String name, A value)
set
in interface SymbolTable<A>
SymbolTable.set(Symbol, Object)
public A setInCurrentScope(Symbol variable, A value)
variable
- the variable to search for.value
- the new value for the variable.
InvalidVariableException
- when the variable is undeclared (in this or any previous
scope).public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getVariablesAsString()
getVariablesAsString
in interface SymbolTable<A>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |