|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Tree
What does a tree look like? ANTLR has a number of support classes such as CommonTreeNodeStream that work on these kinds of trees. You don't have to make your trees implement this interface, but if you do, you'll be able to use more support code. NOTE: When constructing trees, ANTLR can build any kind of tree; it can even use Token objects as trees if you add a child list to your tokens. This is a tree node without any payload; just navigation and factory stuff.
Field Summary | |
---|---|
static Tree |
INVALID_NODE
|
Method Summary | |
---|---|
void |
addChild(Tree t)
Add t as a child to this node. |
java.lang.Object |
deleteChild(int i)
|
Tree |
dupNode()
|
void |
freshenParentAndChildIndexes()
Set the parent and child index values for all children |
Tree |
getAncestor(int ttype)
Walk upwards and get first ancestor with this token type. |
java.util.List |
getAncestors()
Return a list of all ancestors of this node. |
int |
getCharPositionInLine()
|
Tree |
getChild(int i)
|
int |
getChildCount()
|
int |
getChildIndex()
This node is what child index? 0..n-1 |
int |
getLine()
In case we don't have a token payload, what is the line for errors? |
Tree |
getParent()
|
java.lang.String |
getText()
|
int |
getTokenStartIndex()
What is the smallest token index (indexing from 0) for this node and its children? |
int |
getTokenStopIndex()
What is the largest token index (indexing from 0) for this node and its children? |
int |
getType()
Return a token type; needed for tree parsing |
boolean |
hasAncestor(int ttype)
Is there is a node above with token type ttype? |
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,
java.lang.Object t)
Delete children from start to stop and replace with t even if t is a list (nil-root tree). |
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)
|
void |
setTokenStartIndex(int index)
|
void |
setTokenStopIndex(int index)
|
java.lang.String |
toString()
|
java.lang.String |
toStringTree()
|
Field Detail |
---|
static final Tree INVALID_NODE
Method Detail |
---|
Tree getChild(int i)
int getChildCount()
Tree getParent()
void setParent(Tree t)
boolean hasAncestor(int ttype)
Tree getAncestor(int ttype)
java.util.List getAncestors()
int getChildIndex()
void setChildIndex(int index)
void freshenParentAndChildIndexes()
void addChild(Tree t)
void setChild(int i, Tree t)
java.lang.Object deleteChild(int i)
void replaceChildren(int startChildIndex, int stopChildIndex, java.lang.Object t)
boolean isNil()
int getTokenStartIndex()
void setTokenStartIndex(int index)
int getTokenStopIndex()
void setTokenStopIndex(int index)
Tree dupNode()
int getType()
java.lang.String getText()
int getLine()
int getCharPositionInLine()
java.lang.String toStringTree()
java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |