Package ru.ispras.verilog.parser.core
Class AbstractNode<Tag extends java.lang.Enum<Tag>>
- java.lang.Object
-
- ru.ispras.verilog.parser.core.AbstractSymbolTable<Tag>
-
- ru.ispras.verilog.parser.core.AbstractNode<Tag>
-
- Direct Known Subclasses:
VerilogNode
public abstract class AbstractNode<Tag extends java.lang.Enum<Tag>> extends AbstractSymbolTable<Tag>
AbstractNode
implements the basic abstract syntax tree (AST) node.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractNode.NodeKind
AbstractNode.NodeKind
classifies nodes according to their abilities to have names and scopes.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNode(AbstractNode<Tag> other)
Creates a copy of the node.protected
AbstractNode(AbstractNode<Tag> other, AbstractNode<Tag> parent)
Creates a copy of the node.protected
AbstractNode(Tag tag, java.util.EnumSet<Tag> childrenTags, AbstractNode.NodeKind kind)
Creates a node.protected
AbstractNode(Tag tag, java.util.EnumSet<Tag> childrenTags, AbstractNode.NodeKind kind, AbstractNode<Tag> parent)
Creates a node.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(AbstractNode<Tag> node)
Adds the item into the symbol table.abstract AbstractNode<Tag>
clone()
Clones the symbol table.AbstractNode<Tag>
find(java.lang.String name)
Returns an item of the symbol table with the given name.java.lang.String
getFullName()
Returns the fully qualified name of the node.java.lang.String
getName()
Returns the name of the node.AbstractNode<Tag>
getParent()
Returns the parent of the node.Tag
getTag()
Returns the tag of the node.boolean
hasName()
Checks whether the node has a name.boolean
hasScope()
Checks whether the node has a scope.boolean
isTransparent()
Checks whether the node is transparent (i.e.java.util.Collection<AbstractNode<Tag>>
items()
Returns the symbol table's items.java.util.Collection<AbstractNode<Tag>>
items(java.util.EnumSet<Tag> tags)
Returns the items whose tags belong to the given set.java.util.Collection<AbstractNode<Tag>>
items(Tag tag)
Returns the items with the given tag.void
remove(AbstractNode<Tag> node)
Removes the item from the symbol table.void
replace(AbstractNode<Tag> oldNode, java.util.Collection<AbstractNode<Tag>> newNodes)
Replaces the item of the symbol table with the given items.void
setName(java.lang.String name)
Sets the name of the node.void
setParent(AbstractNode<Tag> parent)
Sets the parent of the node.protected void
setRedefinitionHandler(ErrorHandler<Tag> redefinitionHandler)
Sets the redefinition handler.void
setTag(Tag tag)
Sets the tag of the node.java.lang.String
toString()
-
Methods inherited from class ru.ispras.verilog.parser.core.AbstractSymbolTable
addAll, findAroundRecursively, findAroundRecursively, findRecursively, findRecursively, getUpperTable, items, items, setUpperTable
-
-
-
-
Constructor Detail
-
AbstractNode
protected AbstractNode(Tag tag, java.util.EnumSet<Tag> childrenTags, AbstractNode.NodeKind kind, AbstractNode<Tag> parent)
Creates a node.- Parameters:
tag
- the tag.childrenTags
- the admissible tags of the node's children.kind
- the kind.parent
- the parent node.
-
AbstractNode
protected AbstractNode(Tag tag, java.util.EnumSet<Tag> childrenTags, AbstractNode.NodeKind kind)
Creates a node.- Parameters:
tag
- the tag.childrenTags
- the admissible tags of the node's children.kind
- the kind.
-
AbstractNode
protected AbstractNode(AbstractNode<Tag> other)
Creates a copy of the node.- Parameters:
other
- the node to be copied.
-
AbstractNode
protected AbstractNode(AbstractNode<Tag> other, AbstractNode<Tag> parent)
Creates a copy of the node.- Parameters:
other
- the node to be copied.parent
- the parent node to be set.
-
-
Method Detail
-
getName
public final java.lang.String getName()
Returns the name of the node.- Returns:
- the name of the node.
-
getFullName
public final java.lang.String getFullName()
Returns the fully qualified name of the node.- Returns:
- the full name of the node.
-
setName
public final void setName(java.lang.String name)
Sets the name of the node.- Parameters:
name
- the name to be set.
-
getTag
public final Tag getTag()
Returns the tag of the node.- Returns:
- the tag of the node.
-
setTag
public final void setTag(Tag tag)
Sets the tag of the node.- Parameters:
tag
- the tag to be set.
-
hasName
public final boolean hasName()
Checks whether the node has a name.- Returns:
true
iff the node has a name.
-
hasScope
public final boolean hasScope()
Checks whether the node has a scope.- Returns:
true
iff the node has a scope.
-
isTransparent
public final boolean isTransparent()
Checks whether the node is transparent (i.e. has no a real scope).- Returns:
true
iff the node is transparent.
-
getParent
public final AbstractNode<Tag> getParent()
Returns the parent of the node.- Returns:
- the parent node or
null
if the node is a top-level one.
-
setParent
public final void setParent(AbstractNode<Tag> parent)
Sets the parent of the node.- Parameters:
parent
- the parent node to be set.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
clone
public abstract AbstractNode<Tag> clone()
Description copied from class:AbstractSymbolTable
Clones the symbol table.- Specified by:
clone
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Returns:
- a copy of the symbol table.
-
items
public final java.util.Collection<AbstractNode<Tag>> items()
Description copied from class:AbstractSymbolTable
Returns the symbol table's items.- Specified by:
items
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Returns:
- the collection of items.
-
items
public final java.util.Collection<AbstractNode<Tag>> items(Tag tag)
Description copied from class:AbstractSymbolTable
Returns the items with the given tag.- Specified by:
items
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Parameters:
tag
- the tag.- Returns:
- the collection of items.
-
items
public final java.util.Collection<AbstractNode<Tag>> items(java.util.EnumSet<Tag> tags)
Description copied from class:AbstractSymbolTable
Returns the items whose tags belong to the given set.- Specified by:
items
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Parameters:
tags
- the set of tags.- Returns:
- the collection of items.
-
find
public final AbstractNode<Tag> find(java.lang.String name)
Description copied from class:AbstractSymbolTable
Returns an item of the symbol table with the given name.- Specified by:
find
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Parameters:
name
- the name.- Returns:
- an item or
null
.
-
add
public final void add(AbstractNode<Tag> node)
Description copied from class:AbstractSymbolTable
Adds the item into the symbol table.- Specified by:
add
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Parameters:
node
- the item to be added.
-
remove
public final void remove(AbstractNode<Tag> node)
Description copied from class:AbstractSymbolTable
Removes the item from the symbol table.- Specified by:
remove
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Parameters:
node
- the item to be removed.
-
replace
public void replace(AbstractNode<Tag> oldNode, java.util.Collection<AbstractNode<Tag>> newNodes)
Description copied from class:AbstractSymbolTable
Replaces the item of the symbol table with the given items.All items should have the same tag.
- Specified by:
replace
in classAbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
- Parameters:
oldNode
- the existing item to be replaced.newNodes
- the items to to replace the existing one.
-
setRedefinitionHandler
protected final void setRedefinitionHandler(ErrorHandler<Tag> redefinitionHandler)
Sets the redefinition handler.- Parameters:
redefinitionHandler
- the handler to be set.
-
-