antlr3.tree.CommonTree Class Reference

A tree node that is wrapper for a Token object. More...

Inheritance diagram for antlr3.tree.CommonTree:

Inheritance graph
[legend]
Collaboration diagram for antlr3.tree.CommonTree:

Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
 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.
def getToken
def dupNode
def isNil
 Indicates the node is a nil node but may still have children, meaning the tree is a flat list.
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 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 getChildIndex
 BaseTree doesn't track child indexes.
def setChildIndex
 BaseTree doesn't track child indexes.
def getParent
 BaseTree doesn't track parent pointers.
def setParent
 BaseTree doesn't track parent pointers.
def toString
 Override to say how a node (not a tree) should look as text.
def toStringTree
 Print out a whole tree not just a node.

Public Attributes

 startIndex
 stopIndex
 parent
 childIndex
 token

Static Public Attributes

tuple type = property(getType)
tuple text = property(getText)
tuple line = property(getLine)
tuple charPositionInLine = property(getCharPositionInLine)
tuple tokenStartIndex = property(getTokenStartIndex, setTokenStartIndex)
tuple tokenStopIndex = property(getTokenStopIndex, setTokenStopIndex)

Static Private Attributes

 __str__ = toString


Detailed Description

A tree node that is wrapper for a Token object.

After 3.0 release while building tree rewrite stuff, it became clear that computing parent and child index is very difficult and cumbersome. Better to spend the space in every tree node. If you don't want these extra fields, it's easy to cut them out in your own BaseTree subclass.

Definition at line 1210 of file tree.py.


Member Function Documentation

def antlr3.tree.CommonTree.__init__ (   self,
  node 
)

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.

Reimplemented from antlr3.tree.BaseTree.

Reimplemented in antlr3.treewizard.TreePattern.

Definition at line 1212 of file tree.py.

def antlr3.tree.CommonTree.getToken (   self  ) 

Definition at line 1243 of file tree.py.

def antlr3.tree.CommonTree.dupNode (   self  ) 

Reimplemented from antlr3.tree.Tree.

Definition at line 1247 of file tree.py.

def antlr3.tree.CommonTree.isNil (   self  ) 

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

Reimplemented from antlr3.tree.BaseTree.

Reimplemented in antlr3.tree.CommonErrorNode.

Definition at line 1251 of file tree.py.

def antlr3.tree.CommonTree.getType (   self  ) 

Return a token type; needed for tree parsing.

Reimplemented from antlr3.tree.Tree.

Reimplemented in antlr3.tree.CommonErrorNode.

Definition at line 1255 of file tree.py.

def antlr3.tree.CommonTree.getText (   self  ) 

Reimplemented from antlr3.tree.Tree.

Reimplemented in antlr3.tree.CommonErrorNode.

Definition at line 1264 of file tree.py.

def antlr3.tree.CommonTree.getLine (   self  ) 

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

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1273 of file tree.py.

def antlr3.tree.CommonTree.getCharPositionInLine (   self  ) 

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1285 of file tree.py.

def antlr3.tree.CommonTree.getTokenStartIndex (   self  ) 

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

Reimplemented from antlr3.tree.Tree.

Definition at line 1298 of file tree.py.

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

Reimplemented from antlr3.tree.Tree.

Definition at line 1304 of file tree.py.

def antlr3.tree.CommonTree.getTokenStopIndex (   self  ) 

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

Reimplemented from antlr3.tree.Tree.

Definition at line 1310 of file tree.py.

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

Reimplemented from antlr3.tree.Tree.

Definition at line 1316 of file tree.py.

def antlr3.tree.CommonTree.getChildIndex (   self  ) 

BaseTree doesn't track child indexes.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1322 of file tree.py.

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

BaseTree doesn't track child indexes.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1327 of file tree.py.

def antlr3.tree.CommonTree.getParent (   self  ) 

BaseTree doesn't track parent pointers.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1332 of file tree.py.

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

BaseTree doesn't track parent pointers.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1337 of file tree.py.

def antlr3.tree.CommonTree.toString (   self  ) 

Override to say how a node (not a tree) should look as text.

Reimplemented from antlr3.tree.BaseTree.

Reimplemented in antlr3.tree.CommonErrorNode, and antlr3.treewizard.TreePattern.

Definition at line 1342 of file tree.py.

def antlr3.tree.CommonTree.toStringTree (   self  ) 

Print out a whole tree not just a node.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1355 of file tree.py.


Member Data Documentation

tuple antlr3.tree.CommonTree.type = property(getType) [static]

Definition at line 1261 of file tree.py.

tuple antlr3.tree.CommonTree.text = property(getText) [static]

Definition at line 1270 of file tree.py.

tuple antlr3.tree.CommonTree.line = property(getLine) [static]

Definition at line 1282 of file tree.py.

tuple antlr3.tree.CommonTree.charPositionInLine = property(getCharPositionInLine) [static]

Definition at line 1295 of file tree.py.

tuple antlr3.tree.CommonTree.tokenStartIndex = property(getTokenStartIndex, setTokenStartIndex) [static]

Definition at line 1307 of file tree.py.

tuple antlr3.tree.CommonTree.tokenStopIndex = property(getTokenStopIndex, setTokenStopIndex) [static]

Definition at line 1319 of file tree.py.

antlr3.tree.CommonTree.__str__ = toString [static, private]

Definition at line 1351 of file tree.py.

Definition at line 1217 of file tree.py.

Definition at line 1218 of file tree.py.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1221 of file tree.py.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1224 of file tree.py.

Definition at line 1228 of file tree.py.


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

Generated on Tue May 20 18:34:07 2008 for ANTLR Python API by  doxygen 1.5.5