antlr3.tree.Tree Class Reference

Abstract baseclass for tree nodes. More...

Inheritance diagram for antlr3.tree.Tree:

Inheritance graph
[legend]

List of all members.

Public Member Functions

def getChild
def getChildCount
def getParent
 Tree tracks parent and child index now > 3.0.
def setParent
 Tree tracks parent and child index now > 3.0.
def hasAncestor
 Walk upwards looking for ancestor with this token type.
def getAncestor
 Walk upwards and get first ancestor with this token type.
def getAncestors
 Return a list of all ancestors of this node.
def getChildIndex
 This node is what child index? 0.
def setChildIndex
 This node is what child index? 0.
def freshenParentAndChildIndexes
 Set the parent and child index values for all children.
def addChild
 Add t as a child to this node.
def setChild
 Set ith child (0.
def deleteChild
def replaceChildren
 Delete children from start to stop and replace with t even if t is a list (nil-root tree).
def isNil
 Indicates the node is a nil node but may still have children, meaning the tree is a flat list.
def getTokenStartIndex
 What is the smallest token index (indexing from 0) for this node and its children?
def setTokenStartIndex
def getTokenStopIndex
 What is the largest token index (indexing from 0) for this node and its children?
def setTokenStopIndex
def dupNode
def getType
 Return a token type; needed for tree parsing.
def getText
def getLine
 In case we don't have a token payload, what is the line for errors?
def getCharPositionInLine
def toStringTree
def toString


Detailed Description

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.

Definition at line 116 of file tree.py.


Member Function Documentation

def antlr3.tree.Tree.getChild (   self,
  i 
)

Reimplemented in antlr3.tree.BaseTree.

Definition at line 119 of file tree.py.

def antlr3.tree.Tree.getChildCount (   self  ) 

Reimplemented in antlr3.tree.BaseTree.

Definition at line 123 of file tree.py.

def antlr3.tree.Tree.getParent (   self  ) 

Tree tracks parent and child index now > 3.0.

Reimplemented in antlr3.tree.BaseTree, and antlr3.tree.CommonTree.

Definition at line 129 of file tree.py.

def antlr3.tree.Tree.setParent (   self,
  t 
)

Tree tracks parent and child index now > 3.0.

Reimplemented in antlr3.tree.BaseTree, and antlr3.tree.CommonTree.

Definition at line 135 of file tree.py.

def antlr3.tree.Tree.hasAncestor (   self,
  ttype 
)

Walk upwards looking for ancestor with this token type.

Reimplemented in antlr3.tree.BaseTree.

Definition at line 142 of file tree.py.

def antlr3.tree.Tree.getAncestor (   self,
  ttype 
)

Walk upwards and get first ancestor with this token type.

Reimplemented in antlr3.tree.BaseTree.

Definition at line 148 of file tree.py.

def antlr3.tree.Tree.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.

Reimplemented in antlr3.tree.BaseTree.

Definition at line 158 of file tree.py.

def antlr3.tree.Tree.getChildIndex (   self  ) 

This node is what child index? 0.

.n-1

Reimplemented in antlr3.tree.BaseTree, and antlr3.tree.CommonTree.

Definition at line 165 of file tree.py.

def antlr3.tree.Tree.setChildIndex (   self,
  index 
)

This node is what child index? 0.

.n-1

Reimplemented in antlr3.tree.BaseTree, and antlr3.tree.CommonTree.

Definition at line 171 of file tree.py.

def antlr3.tree.Tree.freshenParentAndChildIndexes (   self  ) 

Set the parent and child index values for all children.

Definition at line 178 of file tree.py.

def antlr3.tree.Tree.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.

Reimplemented in antlr3.tree.BaseTree.

Definition at line 188 of file tree.py.

def antlr3.tree.Tree.setChild (   self,
  i,
  t 
)

Set ith child (0.

.n-1) to t; t must be non-null and non-nil node

Reimplemented in antlr3.tree.BaseTree.

Definition at line 195 of file tree.py.

def antlr3.tree.Tree.deleteChild (   self,
  i 
)

Reimplemented in antlr3.tree.BaseTree.

Definition at line 200 of file tree.py.

def antlr3.tree.Tree.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.

Reimplemented in antlr3.tree.BaseTree.

Definition at line 211 of file tree.py.

def antlr3.tree.Tree.isNil (   self  ) 

Indicates the node is a nil node but may still have children, meaning the tree is a flat list.

Reimplemented in antlr3.tree.BaseTree, antlr3.tree.CommonTree, and antlr3.tree.CommonErrorNode.

Definition at line 221 of file tree.py.

def antlr3.tree.Tree.getTokenStartIndex (   self  ) 

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

Reimplemented in antlr3.tree.CommonTree.

Definition at line 231 of file tree.py.

def antlr3.tree.Tree.setTokenStartIndex (   self,
  index 
)

Reimplemented in antlr3.tree.CommonTree.

Definition at line 236 of file tree.py.

def antlr3.tree.Tree.getTokenStopIndex (   self  ) 

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

Reimplemented in antlr3.tree.CommonTree.

Definition at line 245 of file tree.py.

def antlr3.tree.Tree.setTokenStopIndex (   self,
  index 
)

Reimplemented in antlr3.tree.CommonTree.

Definition at line 250 of file tree.py.

def antlr3.tree.Tree.dupNode (   self  ) 

Reimplemented in antlr3.tree.CommonTree.

Definition at line 254 of file tree.py.

def antlr3.tree.Tree.getType (   self  ) 

Return a token type; needed for tree parsing.

Reimplemented in antlr3.tree.CommonTree, and antlr3.tree.CommonErrorNode.

Definition at line 260 of file tree.py.

def antlr3.tree.Tree.getText (   self  ) 

Reimplemented in antlr3.tree.CommonTree, and antlr3.tree.CommonErrorNode.

Definition at line 265 of file tree.py.

def antlr3.tree.Tree.getLine (   self  ) 

In case we don't have a token payload, what is the line for errors?

Reimplemented in antlr3.tree.BaseTree, and antlr3.tree.CommonTree.

Definition at line 273 of file tree.py.

def antlr3.tree.Tree.getCharPositionInLine (   self  ) 

Reimplemented in antlr3.tree.BaseTree, and antlr3.tree.CommonTree.

Definition at line 278 of file tree.py.

def antlr3.tree.Tree.toStringTree (   self  ) 

Reimplemented in antlr3.tree.BaseTree, and antlr3.tree.CommonTree.

Definition at line 282 of file tree.py.

def antlr3.tree.Tree.toString (   self  ) 


The documentation for this class was generated from the following file:

Generated on Mon Nov 29 17:24:29 2010 for ANTLR Python API by  doxygen 1.5.5