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

Class CommonTree

object --+        
         |        
      Tree --+    
             |    
      BaseTree --+
                 |
                CommonTree
Known Subclasses:

@brief 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.

Instance Methods [hide private]
 
__init__(self, payload)
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.
 
getToken(self)
 
dupNode(self)
 
isNil(self)
Indicates the node is a nil node but may still have children, meaning the tree is a flat list.
 
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)
 
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)
 
setUnknownTokenBoundaries(self)
For every node in this subtree, make sure it's start/stop token's are set.
 
getChildIndex(self)
BaseTree doesn't track child indexes.
 
setChildIndex(self, idx)
BaseTree doesn't track child indexes.
 
getParent(self)
BaseTree doesn't track parent pointers.
 
setParent(self, t)
BaseTree doesn't track parent pointers.
 
toString(self)
Override to say how a node (not a tree) should look as text
 
__str__(self)
Override to say how a node (not a tree) should look as text
 
toStringTree(self)
Print out a whole tree not just a node

Inherited from BaseTree: addChild, addChildren, deleteChild, freshenParentAndChildIndexes, getAncestor, getAncestors, getChild, getChildCount, getChildren, getFirstChildWithType, hasAncestor, replaceChildren, sanityCheckParentAndChildIndexes, setChild

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

Properties [hide private]
  type
  text
  line
  charPositionInLine
  tokenStartIndex
  tokenStopIndex

Inherited from object: __class__

Method Details [hide private]

__init__(self, payload)
(Constructor)

 

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.

Overrides: object.__init__
(inherited documentation)

dupNode(self)

 
Overrides: Tree.dupNode

isNil(self)

 

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

Overrides: Tree.isNil
(inherited documentation)

getType(self)

 

Return a token type; needed for tree parsing.

Overrides: Tree.getType
(inherited documentation)

getText(self)

 
Overrides: Tree.getText

getLine(self)

 

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

Overrides: Tree.getLine
(inherited documentation)

getCharPositionInLine(self)

 
Overrides: Tree.getCharPositionInLine

getTokenStartIndex(self)

 

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

Overrides: Tree.getTokenStartIndex
(inherited documentation)

setTokenStartIndex(self, index)

 
Overrides: Tree.setTokenStartIndex

getTokenStopIndex(self)

 

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

Overrides: Tree.getTokenStopIndex
(inherited documentation)

setTokenStopIndex(self, index)

 
Overrides: Tree.setTokenStopIndex

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.

getChildIndex(self)

 

BaseTree doesn't track child indexes.

Overrides: Tree.getChildIndex
(inherited documentation)

setChildIndex(self, idx)

 

BaseTree doesn't track child indexes.

Overrides: Tree.setChildIndex
(inherited documentation)

getParent(self)

 

BaseTree doesn't track parent pointers.

Overrides: Tree.getParent
(inherited documentation)

setParent(self, t)

 

BaseTree doesn't track parent pointers.

Overrides: Tree.setParent
(inherited documentation)

toString(self)

 

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

Overrides: Tree.toString

__str__(self)
(Informal representation operator)

 

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

Overrides: object.__str__
(inherited documentation)

toStringTree(self)

 

Print out a whole tree not just a node

Overrides: Tree.toStringTree

Property Details [hide private]

type

Get Method:
getType(self) - Return a token type; needed for tree parsing.

text

Get Method:
getText(self)

line

Get Method:
getLine(self) - In case we don't have a token payload, what is the line for errors?

charPositionInLine

Get Method:
getCharPositionInLine(self)

tokenStartIndex

Get Method:
getTokenStartIndex(self) - What is the smallest token index (indexing from 0) for this node...
Set Method:
setTokenStartIndex(self, index)

tokenStopIndex

Get Method:
getTokenStopIndex(self) - What is the largest token index (indexing from 0) for this node and its children?
Set Method:
setTokenStopIndex(self, index)