org.antlr.runtime.tree.BaseTree Class Reference

Inheritance diagram for org.antlr.runtime.tree.BaseTree:

Inheritance graph
[legend]
Collaboration diagram for org.antlr.runtime.tree.BaseTree:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 BaseTree ()
 BaseTree (Tree node)
Tree getChild (int i)
List getChildren ()
Tree getFirstChildWithType (int type)
int getChildCount ()
void addChild (Tree t)
void addChildren (List kids)
void setChild (int i, Tree t)
Object deleteChild (int i)
void replaceChildren (int startChildIndex, int stopChildIndex, Object t)
boolean isNil ()
void freshenParentAndChildIndexes ()
void freshenParentAndChildIndexes (int offset)
void sanityCheckParentAndChildIndexes ()
void sanityCheckParentAndChildIndexes (Tree parent, int i)
int getChildIndex ()
void setChildIndex (int index)
Tree getParent ()
void setParent (Tree t)
String toStringTree ()
int getLine ()
int getCharPositionInLine ()
abstract String toString ()

Protected Member Functions

List createChildrenList ()

Protected Attributes

List children


Detailed Description

A generic tree implementation with no payload. You must subclass to actually have any user data. ANTLR v3 uses a list of children approach instead of the child-sibling approach in v2. A flat tree (a list) is an empty node whose children represent the list. An empty, but non-null node is called "nil".

Definition at line 39 of file BaseTree.java.


Constructor & Destructor Documentation

org.antlr.runtime.tree.BaseTree.BaseTree (  ) 

Definition at line 42 of file BaseTree.java.

org.antlr.runtime.tree.BaseTree.BaseTree ( Tree  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.

Definition at line 49 of file BaseTree.java.


Member Function Documentation

Tree org.antlr.runtime.tree.BaseTree.getChild ( int  i  ) 

Implements org.antlr.runtime.tree.Tree.

Definition at line 52 of file BaseTree.java.

List org.antlr.runtime.tree.BaseTree.getChildren (  ) 

Get the children internal List; note that if you directly mess with the list, do so at your own risk.

Definition at line 62 of file BaseTree.java.

Tree org.antlr.runtime.tree.BaseTree.getFirstChildWithType ( int  type  ) 

Definition at line 66 of file BaseTree.java.

int org.antlr.runtime.tree.BaseTree.getChildCount (  ) 

Implements org.antlr.runtime.tree.Tree.

Definition at line 76 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.addChild ( Tree  t  ) 

Add t as child of this node.

Warning: if t has no children, but child does and child isNil then this routine moves children to t via t.children = child.children; i.e., without copying the array.

Implements org.antlr.runtime.tree.Tree.

Definition at line 89 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.addChildren ( List  kids  ) 

Add all elements of kids list as children of this node

Definition at line 132 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.setChild ( int  i,
Tree  t 
)

Set ith child (0..n-1) to t; t must be non-null and non-nil node

Implements org.antlr.runtime.tree.Tree.

Definition at line 139 of file BaseTree.java.

Object org.antlr.runtime.tree.BaseTree.deleteChild ( int  i  ) 

Implements org.antlr.runtime.tree.Tree.

Definition at line 154 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.replaceChildren ( int  startChildIndex,
int  stopChildIndex,
Object  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.

Implements org.antlr.runtime.tree.Tree.

Definition at line 169 of file BaseTree.java.

List org.antlr.runtime.tree.BaseTree.createChildrenList (  )  [protected]

Override in a subclass to change the impl of children list

Definition at line 231 of file BaseTree.java.

boolean org.antlr.runtime.tree.BaseTree.isNil (  ) 

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

Implements org.antlr.runtime.tree.Tree.

Reimplemented in org.antlr.runtime.tree.CommonErrorNode, and org.antlr.runtime.tree.CommonTree.

Definition at line 235 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.freshenParentAndChildIndexes (  ) 

Set the parent and child index values for all child of t

Implements org.antlr.runtime.tree.Tree.

Definition at line 240 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.freshenParentAndChildIndexes ( int  offset  ) 

Definition at line 244 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.sanityCheckParentAndChildIndexes (  ) 

Definition at line 253 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.sanityCheckParentAndChildIndexes ( Tree  parent,
int  i 
)

Definition at line 257 of file BaseTree.java.

int org.antlr.runtime.tree.BaseTree.getChildIndex (  ) 

BaseTree doesn't track child indexes.

Implements org.antlr.runtime.tree.Tree.

Reimplemented in org.antlr.runtime.tree.CommonTree.

Definition at line 272 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.setChildIndex ( int  index  ) 

Implements org.antlr.runtime.tree.Tree.

Reimplemented in org.antlr.runtime.tree.CommonTree.

Definition at line 275 of file BaseTree.java.

Tree org.antlr.runtime.tree.BaseTree.getParent (  ) 

BaseTree doesn't track parent pointers.

Implements org.antlr.runtime.tree.Tree.

Reimplemented in org.antlr.runtime.tree.CommonTree.

Definition at line 279 of file BaseTree.java.

void org.antlr.runtime.tree.BaseTree.setParent ( Tree  t  ) 

Implements org.antlr.runtime.tree.Tree.

Reimplemented in org.antlr.runtime.tree.CommonTree.

Definition at line 282 of file BaseTree.java.

String org.antlr.runtime.tree.BaseTree.toStringTree (  ) 

Print out a whole tree not just a node

Implements org.antlr.runtime.tree.Tree.

Definition at line 286 of file BaseTree.java.

int org.antlr.runtime.tree.BaseTree.getLine (  ) 

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

Implements org.antlr.runtime.tree.Tree.

Reimplemented in org.antlr.runtime.tree.CommonTree.

Definition at line 309 of file BaseTree.java.

int org.antlr.runtime.tree.BaseTree.getCharPositionInLine (  ) 

Implements org.antlr.runtime.tree.Tree.

Reimplemented in org.antlr.runtime.tree.CommonTree.

Definition at line 313 of file BaseTree.java.

abstract String org.antlr.runtime.tree.BaseTree.toString (  )  [pure virtual]


Member Data Documentation

Definition at line 40 of file BaseTree.java.


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

Generated on Wed Oct 1 14:13:46 2008 for ANTLR API by  doxygen 1.5.5