public abstract class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
extends java.lang.Object
AbstractSymbolTable
represents an abstract symbol table.Constructor and Description |
---|
AbstractSymbolTable()
Creates a symbol table.
|
AbstractSymbolTable(AbstractSymbolTable<Tag> upper)
Creates a symbol table with an upper scope.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
add(AbstractNode<Tag> item)
Adds the item into the symbol table.
|
void |
addAll(java.util.Collection<? extends AbstractNode<Tag>> items)
Adds the items into the symbol table.
|
abstract AbstractSymbolTable<Tag> |
clone()
Clones the symbol table.
|
abstract AbstractNode<Tag> |
find(java.lang.String name)
Returns an item of the symbol table with the given name.
|
AbstractNode<Tag> |
findAroundRecursively(java.lang.String name)
Returns an item of the symbol table with the given name.
|
AbstractNode<Tag> |
findAroundRecursively(java.lang.String name,
Tag tag)
Returns an item of the symbol table with the given name and the given tag.
|
AbstractNode<Tag> |
findRecursively(java.lang.String name)
Returns an item of the symbol table with the given name.
|
AbstractNode<Tag> |
findRecursively(java.lang.String name,
Tag tag)
Returns an item of the symbol table with the given name and the given tag.
|
protected AbstractSymbolTable<Tag> |
getUpperTable()
Returns the symbol table of the upper scope.
|
abstract java.util.Collection<AbstractNode<Tag>> |
items()
Returns the symbol table's items.
|
abstract java.util.Collection<AbstractNode<Tag>> |
items(java.util.EnumSet<Tag> tags)
Returns the items whose tags belong to the given set.
|
abstract java.util.Collection<AbstractNode<Tag>> |
items(Tag tag)
Returns the items with the given tag.
|
java.util.Collection<AbstractNode<Tag>> |
items(Tag tag1,
Tag tag2)
Returns the items with the given tags.
|
java.util.Collection<AbstractNode<Tag>> |
items(Tag tag1,
Tag tag2,
Tag tag3)
Returns the items with the given tags.
|
abstract void |
remove(AbstractNode<Tag> item)
Removes the item from the symbol table.
|
abstract void |
replace(AbstractNode<Tag> oldItem,
java.util.Collection<AbstractNode<Tag>> newItems)
Replaces the item of the symbol table with the given items.
|
protected void |
setUpperTable(AbstractSymbolTable<Tag> upper)
Sets the symbol table of the upper scope.
|
public AbstractSymbolTable()
public AbstractSymbolTable(AbstractSymbolTable<Tag> upper)
upper
- the symbol table of the upper scope.protected final AbstractSymbolTable<Tag> getUpperTable()
null
.protected final void setUpperTable(AbstractSymbolTable<Tag> upper)
upper
- the symbol table to be set.public abstract java.util.Collection<AbstractNode<Tag>> items()
public abstract java.util.Collection<AbstractNode<Tag>> items(java.util.EnumSet<Tag> tags)
tags
- the set of tags.public abstract java.util.Collection<AbstractNode<Tag>> items(Tag tag)
tag
- the tag.public final java.util.Collection<AbstractNode<Tag>> items(Tag tag1, Tag tag2)
tag1
- the tag 1.tag2
- the tag 2.public final java.util.Collection<AbstractNode<Tag>> items(Tag tag1, Tag tag2, Tag tag3)
tag1
- the tag 1.tag2
- the tag 2.tag3
- the tag 3.public abstract AbstractNode<Tag> find(java.lang.String name)
name
- the name.null
.public final AbstractNode<Tag> findRecursively(java.lang.String name, Tag tag)
If the tag is null, then it is ignored.
name
- the name.tag
- the tag.null
.public final AbstractNode<Tag> findRecursively(java.lang.String name)
name
- the name.null
.public final AbstractNode<Tag> findAroundRecursively(java.lang.String name, Tag tag)
If the tag is null, then it is ignored.
The purpose of this method is to handle the following situation, where scope
declares
some element, which is visible from outside.
scope { declare(element); } use(element).
Such situation is possible, when scope
is transparent (i.e. it is not a real scope and
will be removed by a preprocessor).
name
- the name.tag
- the tag.null
.public final AbstractNode<Tag> findAroundRecursively(java.lang.String name)
name
- the name.null
.public abstract void add(AbstractNode<Tag> item)
item
- the item to be added.public final void addAll(java.util.Collection<? extends AbstractNode<Tag>> items)
items
- the collection of items to be added.public abstract void remove(AbstractNode<Tag> item)
item
- the item to be removed.public abstract void replace(AbstractNode<Tag> oldItem, java.util.Collection<AbstractNode<Tag>> newItems)
All items should have the same tag.
oldItem
- the existing item to be replaced.newItems
- the items to to replace the existing one.public abstract AbstractSymbolTable<Tag> clone()
clone
in class java.lang.Object