|
CS 536 Fall 2007, Project 5 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectSymbolTable
public class SymbolTable
A block-structured symbol table. Logically, a SymbolTable is a stack of blocks. Each block contains a mapping from Strings to Symbol objects.
Symbol
Constructor Summary | |
---|---|
SymbolTable()
Constructs an empty SymbolTable. |
Method Summary | |
---|---|
void |
define(Symbol sym)
Adds symbol "sym" to the current block of the symbol table. |
Symbol |
globalLookup(String name)
Returns the Symbol with the given name in the block that is highest (nearest the top) of the stack that has such a Symbol. |
Symbol |
localLookup(String name)
Returns the Symbol with the given name in the top block of the table. |
void |
pop()
Pops the top block off the stack, destroying it. |
void |
print(PrintStream out)
Prints the contents of this symbol table. |
void |
push()
Pushes a new empty block onto the stack of blocks. |
String |
toString()
Returns a string representation of this SymbolTable, for debugging. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SymbolTable()
Method Detail |
---|
public void push()
public void pop() throws EmptySymbolTableException
EmptySymbolTableException
- if the stack is empty.public void define(Symbol sym) throws DuplicateSymbolException, EmptySymbolTableException
sym
- the Symbol to add.
DuplicateSymbolException
- if there is already a Symbol with the
same name defined in the current block.
EmptySymbolTableException
- if there is no current block.public Symbol localLookup(String name)
null
if the table is empty or the top block does
not contain a symbol with the given name.
name
- the name to look up.
public Symbol globalLookup(String name)
null
if no block on the stack contains a matching
Symbol.
name
- the name to look up.
public void print(PrintStream out)
out
- the destination of the listing.public String toString()
toString
in class Object
|
CS 536 Fall 2007, Project 5 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |