Package schrodinger :: Package application :: Package desmond :: Package antlr3 :: Module tree :: Class Tree
[hide private]
[frames] | no frames]

Class Tree

object --+
         |
        Tree
Known Subclasses:

@brief Abstract baseclass for tree nodes.

What does a tree look like? ANTLR has a number of support classes such as CommonTreeNodeStream that work on these kinds of trees. You don't have to make your trees implement this interface, but if you do, you'll be able to use more support code.

NOTE: When constructing trees, ANTLR can build any kind of tree; it can even use Token objects as trees if you add a child list to your tokens.

This is a tree node without any payload; just navigation and factory stuff.

Instance Methods [hide private]
 
getChild(self, i)
 
getChildCount(self)
 
getParent(self)
Tree tracks parent and child index now > 3.0
 
setParent(self, t)
Tree tracks parent and child index now > 3.0
 
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.
 
getChildIndex(self)
This node is what child index? 0..n-1
 
setChildIndex(self, index)
This node is what child index? 0..n-1
 
freshenParentAndChildIndexes(self)
Set the parent and child index values for all children
 
addChild(self, t)
Add t as a child to this node.
 
setChild(self, i, t)
Set ith child (0..n-1) to t; t must be non-null and non-nil node
 
deleteChild(self, i)
 
replaceChildren(self, startChildIndex, stopChildIndex, t)
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.
 
getTokenStartIndex(self)
What is the smallest token index (indexing from 0) for this node...
 
setTokenStartIndex(self, index)
 
getTokenStopIndex(self)
What is the largest token index (indexing from 0) for this node and its children?
 
setTokenStopIndex(self, index)
 
dupNode(self)
 
getType(self)
Return a token type; needed for tree parsing.
 
getText(self)
 
getLine(self)
In case we don't have a token payload, what is the line for errors?
 
getCharPositionInLine(self)
 
toStringTree(self)
 
toString(self)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

getAncestors(self)

 

Return a list of all ancestors of this node.

The first node of list is the root and the last is the parent of this node.

addChild(self, t)

 

Add t as a child to this node. If t is null, do nothing. If t is nil, add all children of t to this' children.

replaceChildren(self, startChildIndex, stopChildIndex, t)

 

Delete children from start to stop and replace with t even if t is a list (nil-root tree). num of children can increase or decrease. For huge child lists, inserting children can force walking rest of children to set their childindex; could be slow.

getTokenStartIndex(self)

 

What is the smallest token index (indexing from 0) for this node
   and its children?