public abstract class AbstractNode<Tag extends java.lang.Enum<Tag>> extends AbstractSymbolTable<Tag>
AbstractNode
implements the basic abstract syntax tree (AST) node.Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractNode.NodeKind
AbstractNode.NodeKind classifies nodes according to their abilities to have names and scopes. |
Modifier | Constructor and 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.
|
Modifier and Type | Method and 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() |
addAll, findAroundRecursively, findAroundRecursively, findRecursively, findRecursively, getUpperTable, items, items, setUpperTable
protected AbstractNode(Tag tag, java.util.EnumSet<Tag> childrenTags, AbstractNode.NodeKind kind, AbstractNode<Tag> parent)
tag
- the tag.childrenTags
- the admissible tags of the node's children.kind
- the kind.parent
- the parent node.protected AbstractNode(Tag tag, java.util.EnumSet<Tag> childrenTags, AbstractNode.NodeKind kind)
tag
- the tag.childrenTags
- the admissible tags of the node's children.kind
- the kind.protected AbstractNode(AbstractNode<Tag> other)
other
- the node to be copied.protected AbstractNode(AbstractNode<Tag> other, AbstractNode<Tag> parent)
other
- the node to be copied.parent
- the parent node to be set.public final java.lang.String getName()
public final java.lang.String getFullName()
public final void setName(java.lang.String name)
name
- the name to be set.public final Tag getTag()
public final void setTag(Tag tag)
tag
- the tag to be set.public final boolean hasName()
true
iff the node has a name.public final boolean hasScope()
true
iff the node has a scope.public final boolean isTransparent()
true
iff the node is transparent.public final AbstractNode<Tag> getParent()
null
if the node is a top-level one.public final void setParent(AbstractNode<Tag> parent)
parent
- the parent node to be set.public java.lang.String toString()
toString
in class java.lang.Object
public abstract AbstractNode<Tag> clone()
AbstractSymbolTable
clone
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
public final java.util.Collection<AbstractNode<Tag>> items()
AbstractSymbolTable
items
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
public final java.util.Collection<AbstractNode<Tag>> items(Tag tag)
AbstractSymbolTable
items
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
tag
- the tag.public final java.util.Collection<AbstractNode<Tag>> items(java.util.EnumSet<Tag> tags)
AbstractSymbolTable
items
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
tags
- the set of tags.public final AbstractNode<Tag> find(java.lang.String name)
AbstractSymbolTable
find
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
name
- the name.null
.public final void add(AbstractNode<Tag> node)
AbstractSymbolTable
add
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
node
- the item to be added.public final void remove(AbstractNode<Tag> node)
AbstractSymbolTable
remove
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
node
- the item to be removed.public void replace(AbstractNode<Tag> oldNode, java.util.Collection<AbstractNode<Tag>> newNodes)
AbstractSymbolTable
All items should have the same tag.
replace
in class AbstractSymbolTable<Tag extends java.lang.Enum<Tag>>
oldNode
- the existing item to be replaced.newNodes
- the items to to replace the existing one.protected final void setRedefinitionHandler(ErrorHandler<Tag> redefinitionHandler)
redefinitionHandler
- the handler to be set.