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 setUnknownTokenBoundaries
 For every node in this subtree, make sure it's start/stop token's are set.
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 1279 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 1281 of file tree.py.

def antlr3.tree.CommonTree.getToken (   self  ) 

Definition at line 1312 of file tree.py.

def antlr3.tree.CommonTree.dupNode (   self  ) 

Reimplemented from antlr3.tree.Tree.

Definition at line 1316 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 1320 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 1324 of file tree.py.

def antlr3.tree.CommonTree.getText (   self  ) 

Reimplemented from antlr3.tree.Tree.

Reimplemented in antlr3.tree.CommonErrorNode.

Definition at line 1333 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 1342 of file tree.py.

def antlr3.tree.CommonTree.getCharPositionInLine (   self  ) 

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1354 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 1367 of file tree.py.

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

Reimplemented from antlr3.tree.Tree.

Definition at line 1373 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 1379 of file tree.py.

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

Reimplemented from antlr3.tree.Tree.

Definition at line 1385 of file tree.py.

def antlr3.tree.CommonTree.setUnknownTokenBoundaries (   self  ) 

For every node in this subtree, make sure it's start/stop token's are set.

Walk depth first, visit bottom up. Only updates nodes with at least one token index < 0.

Definition at line 1396 of file tree.py.

def antlr3.tree.CommonTree.getChildIndex (   self  ) 

BaseTree doesn't track child indexes.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1418 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 1423 of file tree.py.

def antlr3.tree.CommonTree.getParent (   self  ) 

BaseTree doesn't track parent pointers.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1428 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 1433 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 1438 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 1451 of file tree.py.


Member Data Documentation

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

Definition at line 1330 of file tree.py.

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

Definition at line 1339 of file tree.py.

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

Definition at line 1351 of file tree.py.

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

Definition at line 1364 of file tree.py.

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

Definition at line 1376 of file tree.py.

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

Definition at line 1388 of file tree.py.

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

Definition at line 1447 of file tree.py.

Definition at line 1286 of file tree.py.

Definition at line 1287 of file tree.py.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1290 of file tree.py.

Reimplemented from antlr3.tree.BaseTree.

Definition at line 1293 of file tree.py.

Definition at line 1297 of file tree.py.


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