Package ru.ispras.verilog.parser.core
Class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- java.lang.Object
-
- ru.ispras.verilog.parser.core.AbstractSymbolTable<Tag>
-
- Direct Known Subclasses:
AbstractNode
public abstract class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>> extends java.lang.Object
AbstractSymbolTable
represents an abstract symbol table.
-
-
Constructor Summary
Constructors Constructor Description AbstractSymbolTable()
Creates a symbol table.AbstractSymbolTable(AbstractSymbolTable<Tag> upper)
Creates a symbol table with an upper scope.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Constructor Detail
-
AbstractSymbolTable
public AbstractSymbolTable()
Creates a symbol table.
-
AbstractSymbolTable
public AbstractSymbolTable(AbstractSymbolTable<Tag> upper)
Creates a symbol table with an upper scope.- Parameters:
upper
- the symbol table of the upper scope.
-
-
Method Detail
-
getUpperTable
protected final AbstractSymbolTable<Tag> getUpperTable()
Returns the symbol table of the upper scope.- Returns:
- the upper symbol table or
null
.
-
setUpperTable
protected final void setUpperTable(AbstractSymbolTable<Tag> upper)
Sets the symbol table of the upper scope.- Parameters:
upper
- the symbol table to be set.
-
items
public abstract java.util.Collection<AbstractNode<Tag>> items()
Returns the symbol table's items.- Returns:
- the collection of items.
-
items
public abstract java.util.Collection<AbstractNode<Tag>> items(java.util.EnumSet<Tag> tags)
Returns the items whose tags belong to the given set.- Parameters:
tags
- the set of tags.- Returns:
- the collection of items.
-
items
public abstract java.util.Collection<AbstractNode<Tag>> items(Tag tag)
Returns the items with the given tag.- Parameters:
tag
- the tag.- Returns:
- the collection of items.
-
items
public final java.util.Collection<AbstractNode<Tag>> items(Tag tag1, Tag tag2)
Returns the items with the given tags.- Parameters:
tag1
- the tag 1.tag2
- the tag 2.- Returns:
- the collection of items.
-
items
public final java.util.Collection<AbstractNode<Tag>> items(Tag tag1, Tag tag2, Tag tag3)
Returns the items with the given tags.- Parameters:
tag1
- the tag 1.tag2
- the tag 2.tag3
- the tag 3.- Returns:
- the collection of items.
-
find
public abstract AbstractNode<Tag> find(java.lang.String name)
Returns an item of the symbol table with the given name.- Parameters:
name
- the name.- Returns:
- an item or
null
.
-
findRecursively
public final AbstractNode<Tag> findRecursively(java.lang.String name, Tag tag)
Returns an item of the symbol table with the given name and the given tag.If the tag is null, then it is ignored.
- Parameters:
name
- the name.tag
- the tag.- Returns:
- an item or
null
.
-
findRecursively
public final AbstractNode<Tag> findRecursively(java.lang.String name)
Returns an item of the symbol table with the given name.- Parameters:
name
- the name.- Returns:
- an item or
null
.
-
findAroundRecursively
public final AbstractNode<Tag> findAroundRecursively(java.lang.String name, Tag tag)
Returns an item of the symbol table with the given name and the given 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).- Parameters:
name
- the name.tag
- the tag.- Returns:
- an item or
null
.
-
findAroundRecursively
public final AbstractNode<Tag> findAroundRecursively(java.lang.String name)
Returns an item of the symbol table with the given name.- Parameters:
name
- the name.- Returns:
- an item or
null
.
-
add
public abstract void add(AbstractNode<Tag> item)
Adds the item into the symbol table.- Parameters:
item
- the item to be added.
-
addAll
public final void addAll(java.util.Collection<? extends AbstractNode<Tag>> items)
Adds the items into the symbol table.- Parameters:
items
- the collection of items to be added.
-
remove
public abstract void remove(AbstractNode<Tag> item)
Removes the item from the symbol table.- Parameters:
item
- the item to be removed.
-
replace
public abstract void replace(AbstractNode<Tag> oldItem, java.util.Collection<AbstractNode<Tag>> newItems)
Replaces the item of the symbol table with the given items.All items should have the same tag.
- Parameters:
oldItem
- the existing item to be replaced.newItems
- the items to to replace the existing one.
-
clone
public abstract AbstractSymbolTable<Tag> clone()
Clones the symbol table.- Overrides:
clone
in classjava.lang.Object
- Returns:
- a copy of the symbol table.
-
-