| java.lang.Object edu.hws.jcm.data.SymbolTable
SymbolTable | public class SymbolTable implements java.io.Serializable(Code) | | A symbol table contains MathObjects, associating them
with their names. To support scoping (for example), a symbol
table can have a parent symbol table. If a symbol is not found
in the table itself, the search procedes to its parent.
MathObjects in the parent are hidden by MathObjects of
the same name in a SymbolTable.
Note that a NullPointerException error will occur if an
attempt is made to add a MathObject with a null name to a
SymbolTable.
A MathObject should not be renamed while it is registered
in a SymbolTable.
Note that a Parser has an associated SymbolTable. I expect
SymbolTables to be used only through Parsers.
|
Method Summary | |
public synchronized void | add(MathObject sym) Adds sym to the SymbolTable, associating it with its name. | public synchronized void | add(String name, MathObject sym) Adds the given MathObject, sym, to the symbol table,
associating it with the given name (which is probably
the name of the symbol or that name transformed to lower
case, but it doesn't have to be).
If the same name is already in use in the HashTable
then the new object replaces the current object.
Note that if the name is defined in the parent
symbol table, then the old object is hidden, not
removed from the parent. | public synchronized MathObject | get(String name) Look up the object with the given name, if any.
If not found, return null. | SymbolTable | getParent() Returns the parent symbol table of this symbol table. | public synchronized void | remove(String name) Remove the object with the given name from the symbol table,
but NOT from the parent symbol table. |
SymbolTable | SymbolTable()(Code) | | Construct a symbol table with null parent.
|
SymbolTable | SymbolTable(SymbolTable parent)(Code) | | Construct a symbol table with specified parent.
|
add | public synchronized void add(MathObject sym)(Code) | | Adds sym to the SymbolTable, associating it with its name.
|
add | public synchronized void add(String name, MathObject sym)(Code) | | Adds the given MathObject, sym, to the symbol table,
associating it with the given name (which is probably
the name of the symbol or that name transformed to lower
case, but it doesn't have to be).
If the same name is already in use in the HashTable
then the new object replaces the current object.
Note that if the name is defined in the parent
symbol table, then the old object is hidden, not
removed from the parent. If sym is null or if
sym's name is null, than a NullPointerException is
thrown.
|
get | public synchronized MathObject get(String name)(Code) | | Look up the object with the given name, if any.
If not found, return null. (If the name is not found
in the HashTable, symbols, the search is delegated to
the parent.) If the name is null, then
null is returned.
|
getParent | SymbolTable getParent()(Code) | | Returns the parent symbol table of this symbol table.
|
remove | public synchronized void remove(String name)(Code) | | Remove the object with the given name from the symbol table,
but NOT from the parent symbol table. No error occurs
if the name is not in the table or if name is null.
If an object of the same name occurs in the parent,
this routine will un-hide it.
|
|
|