@brief A generic tree implementation with no payload.
You must subclass to actually have any user data. ANTLR v3 uses a
list of children approach instead of the child-sibling approach in v2. A
flat tree (a list) is an empty node whose children represent the list.
An empty, but non-null node is called "nil".
|
__init__(self,
node=None)
Create a new node from an existing node does nothing for BaseTree as
there are no fields other than the children list, which cannot be
copied as the children are not considered part of this node. |
|
|
|
|
|
getChildren(self)
@brief Get the children internal List |
|
|
|
getFirstChildWithType(self,
treeType) |
|
|
|
|
|
addChild(self,
childTree)
Add t as child of this node. |
|
|
|
addChildren(self,
children)
Add all elements of kids list as children of this node |
|
|
|
setChild(self,
i,
t)
Set ith child (0..n-1) to t; t must be non-null and non-nil node |
|
|
|
|
|
replaceChildren(self,
startChildIndex,
stopChildIndex,
newTree)
Delete children from start to stop and replace with t even if t is a
list (nil-root tree). |
|
|
|
isNil(self)
Indicates the node is a nil node but may still have children, meaning
the tree is a flat list. |
|
|
|
|
|
sanityCheckParentAndChildIndexes(self,
parent=None,
i=-1) |
|
|
|
|
|
|
|
getParent(self)
BaseTree doesn't track parent pointers. |
|
|
|
setParent(self,
t)
BaseTree doesn't track parent pointers. |
|
|
|
hasAncestor(self,
ttype)
Walk upwards looking for ancestor with this token type. |
|
|
|
getAncestor(self,
ttype)
Walk upwards and get first ancestor with this token type. |
|
|
|
getAncestors(self)
Return a list of all ancestors of this node. |
|
|
|
|
|
getLine(self)
In case we don't have a token payload, what is the line for errors? |
|
|
|
|
|
toString(self)
Override to say how a node (not a tree) should look as text |
|
|
Inherited from Tree :
dupNode ,
getText ,
getTokenStartIndex ,
getTokenStopIndex ,
getType ,
setTokenStartIndex ,
setTokenStopIndex
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|