|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.antlr.runtime.tree.BaseTree
public abstract class BaseTree
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".
| Field Summary | |
|---|---|
protected List |
children
|
| Fields inherited from interface org.antlr.runtime.tree.Tree |
|---|
INVALID_NODE |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
void |
addChild(Tree t)
Add t as child of this node. |
void |
addChildren(List kids)
Add all elements of kids list as children of this node |
protected List |
createChildrenList()
Override in a subclass to change the impl of children list |
Object |
deleteChild(int i)
|
void |
freshenParentAndChildIndexes()
Set the parent and child index values for all child of t |
void |
freshenParentAndChildIndexes(int offset)
|
void |
freshenParentAndChildIndexesDeeply()
|
void |
freshenParentAndChildIndexesDeeply(int offset)
|
Tree |
getAncestor(int ttype)
Walk upwards and get first ancestor with this token type. |
List |
getAncestors()
Return a list of all ancestors of this node. |
int |
getCharPositionInLine()
|
Tree |
getChild(int i)
|
int |
getChildCount()
|
int |
getChildIndex()
BaseTree doesn't track child indexes. |
List |
getChildren()
Get the children internal List; note that if you directly mess with the list, do so at your own risk. |
Tree |
getFirstChildWithType(int type)
|
int |
getLine()
In case we don't have a token payload, what is the line for errors? |
Tree |
getParent()
BaseTree doesn't track parent pointers. |
boolean |
hasAncestor(int ttype)
Walk upwards looking for ancestor with this token type. |
void |
insertChild(int i,
Object t)
Insert child t at child position i (0..n-1) by shifting children i+1..n-1 to the right one position. |
boolean |
isNil()
Indicates the node is a nil node but may still have children, meaning the tree is a flat list. |
void |
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). |
void |
sanityCheckParentAndChildIndexes()
|
void |
sanityCheckParentAndChildIndexes(Tree parent,
int i)
|
void |
setChild(int i,
Tree t)
Set ith child (0..n-1) to t; t must be non-null and non-nil node |
void |
setChildIndex(int index)
|
void |
setParent(Tree t)
|
abstract String |
toString()
Override to say how a node (not a tree) should look as text |
String |
toStringTree()
Print out a whole tree not just a node |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.antlr.runtime.tree.Tree |
|---|
dupNode, getText, getTokenStartIndex, getTokenStopIndex, getType, setTokenStartIndex, setTokenStopIndex |
| Field Detail |
|---|
protected List children
| Constructor Detail |
|---|
public BaseTree()
public BaseTree(Tree node)
| Method Detail |
|---|
public Tree getChild(int i)
getChild in interface Treepublic List getChildren()
public Tree getFirstChildWithType(int type)
public int getChildCount()
getChildCount in interface Treepublic void addChild(Tree t)
addChild in interface Treepublic void addChildren(List kids)
public void setChild(int i,
Tree t)
Tree
setChild in interface Tree
public void insertChild(int i,
Object t)
public Object deleteChild(int i)
deleteChild in interface Tree
public void replaceChildren(int startChildIndex,
int stopChildIndex,
Object t)
replaceChildren in interface Treeprotected List createChildrenList()
public boolean isNil()
Tree
isNil in interface Treepublic void freshenParentAndChildIndexes()
freshenParentAndChildIndexes in interface Treepublic void freshenParentAndChildIndexes(int offset)
public void freshenParentAndChildIndexesDeeply()
public void freshenParentAndChildIndexesDeeply(int offset)
public void sanityCheckParentAndChildIndexes()
public void sanityCheckParentAndChildIndexes(Tree parent,
int i)
public int getChildIndex()
getChildIndex in interface Treepublic void setChildIndex(int index)
setChildIndex in interface Treepublic Tree getParent()
getParent in interface Treepublic void setParent(Tree t)
setParent in interface Treepublic boolean hasAncestor(int ttype)
hasAncestor in interface Treepublic Tree getAncestor(int ttype)
getAncestor in interface Treepublic List getAncestors()
getAncestors in interface Treepublic String toStringTree()
toStringTree in interface Treepublic int getLine()
Tree
getLine in interface Treepublic int getCharPositionInLine()
getCharPositionInLine in interface Treepublic abstract String toString()
toString in interface TreetoString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||