org.norecess.citkit.symboltable
Interface SymbolTable<A>

All Known Implementing Classes:
EmptySymbolTable, HashSymbolTable

public interface SymbolTable<A>


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.
 A get(ISymbol variable)
          Returns the value associated with the specified variable.
 A get(java.lang.String name)
          Returns the value associated with the specified variable.
 java.util.Set<Symbol> getSymbols()
          Returns all of symbols from the current scope.
 java.lang.String getVariablesAsString()
          Returns just the variables of the scope.
 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.
 

Method Detail

add

void add(Symbol variable,
         A value)
Adds a new variable to the current symbol table. This does not check the previous symbol table (for previous variable scopes) to see if this shadows an earlier declaration; an exception is thrown when the variable is already declared in the current symbol table.

Parameters:
variable - the new variable to add to the symbol table.
value - the new value to associate with the new variable.
Throws:
java.lang.IllegalStateException - when the variable is already declared in the current symbol table.

add

void add(java.lang.String name,
         A value)
Adds a name with an associated value to the current symbol table..

See Also:
add(Symbol, Object)

get

A get(ISymbol variable)
Returns the value associated with the specified variable. The search for the variable starts in the current symbol table; if it's found, that value is returned; otherwise, the search continued (recursively) through the previous symbol tables. The method returns null for an undefined variable.

Parameters:
variable - the variable to search for.
Returns:
the value associated with the variable; null if the variable isn't found.

get

A get(java.lang.String name)
Returns the value associated with the specified variable.

See Also:
get(ISymbol)

getSymbols

java.util.Set<Symbol> getSymbols()
Returns all of symbols from the current scope.


set

A set(Symbol variable,
      A value)
Changes the value associated with the specified variable. The variable is searched for in all of the previous symbol tables starting with the current one; the old value associated with the variable is returned.

Parameters:
variable - the variable to search for.
value - the new value for the variable.
Returns:
the old value associated with the variable.

set

A set(java.lang.String name,
      A value)
Sets a value associated with a name.

See Also:
set(Symbol, Object)

getVariablesAsString

java.lang.String getVariablesAsString()
Returns just the variables of the scope. Useful in debugging.