public class SymbolTable
extends java.lang.Object
Constructor and Description |
---|
SymbolTable()
Constructs an empty symbol table.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String symbol,
Token value)
Adds a string-value association to the table.
|
boolean |
contains(java.lang.String symbol)
Checks for an entry associated with a particular string.
|
Token |
get(java.lang.String symbol)
Gets a value associated with a string, from the symbol table.
|
static void |
main(java.lang.String[] args)
An example method that makes use of a symbol table.
|
Token |
remove(java.lang.String symbol)
Removes a value associated with the a string.
|
java.lang.String |
toString()
Returns a string representation of the symbol table.
|
public boolean contains(java.lang.String symbol)
symbol
- a string potentially associated with a value.public void add(java.lang.String symbol, Token value)
symbol
- a non-null stringvalue
- a Token associated with a string.public Token get(java.lang.String symbol)
symbol
- the string whose value is soughtpublic Token remove(java.lang.String symbol)
symbol
- a string possibly keyed to a value in the symbol table.public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)