public final class SymbolTable<Tag extends java.lang.Enum<Tag>>
extends java.lang.Object
SymbolTable
implements a simple symbol table based on Java hash tables.Constructor and Description |
---|
SymbolTable() |
Modifier and Type | Method and Description |
---|---|
void |
add(SyntaxNode<Tag> item)
Adds an item into the symbol table.
|
void |
addAll(java.util.Collection<SyntaxNode<Tag>> items)
Adds items into the symbol table.
|
SyntaxNode<Tag> |
find(java.lang.String name)
Returns an item of the symbol table with the given name.
|
SyntaxNode<Tag> |
findRecursively(java.lang.String name)
Returns an item of the symbol table (or the parent tables) with the given name
|
protected SymbolTable<Tag> |
getParent()
Returns the parent symbol table.
|
java.util.Collection<SyntaxNode<Tag>> |
items()
Returns the collection of items.
|
java.util.Collection<SyntaxNode<Tag>> |
items(java.util.EnumSet<Tag> tags)
Returns the collection of items whose tags belong to the given set.
|
java.util.Collection<SyntaxNode<Tag>> |
items(Tag tag)
Returns the collection of items with the given tag.
|
protected void |
setParent(SymbolTable<Tag> parent)
Sets the parent symbol table.
|
void |
setRedefinitionHandler(ErrorHandler<Tag> handler)
Sets the redefinition handler.
|
protected SymbolTable<Tag> getParent()
null
if the table is a top-level one.protected void setParent(SymbolTable<Tag> parent)
parent
- the symbol table to be set.public java.util.Collection<SyntaxNode<Tag>> items()
public java.util.Collection<SyntaxNode<Tag>> items(Tag tag)
tag
- the tag.public java.util.Collection<SyntaxNode<Tag>> items(java.util.EnumSet<Tag> tags)
tags
- the set of tags.public SyntaxNode<Tag> find(java.lang.String name)
name
- the item name.null
if the symbol table does not contain such
an item.public final SyntaxNode<Tag> findRecursively(java.lang.String name)
name
- the item name.null
if the symbol table and the parent tables
do not contain such an item.public void add(SyntaxNode<Tag> item)
item
- the item to be added.public final void addAll(java.util.Collection<SyntaxNode<Tag>> items)
items
- the items to be added.public void setRedefinitionHandler(ErrorHandler<Tag> handler)
handler
- the handler to be set.