|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.antlr.runtime.tree.BaseTree
org.antlr.runtime.tree.CommonTree
public class CommonTree
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.
| Field Summary | |
|---|---|
int |
childIndex
What index is this node in the child list? Range: 0..n-1 |
CommonTree |
parent
Who is the parent node of this node; if null, implies node is root |
protected int |
startIndex
What token indexes bracket all tokens associated with this node and below? |
protected int |
stopIndex
What token indexes bracket all tokens associated with this node and below? |
Token |
token
A single token is the payload |
| Fields inherited from class org.antlr.runtime.tree.BaseTree |
|---|
children |
| Fields inherited from interface org.antlr.runtime.tree.Tree |
|---|
INVALID_NODE |
| Constructor Summary | |
|---|---|
CommonTree()
|
|
CommonTree(CommonTree node)
|
|
CommonTree(Token t)
|
|
| Method Summary | |
|---|---|
Tree |
dupNode()
|
int |
getCharPositionInLine()
|
int |
getChildIndex()
BaseTree doesn't track child indexes. |
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. |
String |
getText()
|
Token |
getToken()
|
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 |
isNil()
Indicates the node is a nil node but may still have children, meaning the tree is a flat list. |
void |
setChildIndex(int index)
|
void |
setParent(Tree t)
|
void |
setTokenStartIndex(int index)
|
void |
setTokenStopIndex(int index)
|
void |
setUnknownTokenBoundaries()
For every node in this subtree, make sure it's start/stop token's are set. |
String |
toString()
Override to say how a node (not a tree) should look as text |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public Token token
protected int startIndex
protected int stopIndex
public CommonTree parent
public int childIndex
| Constructor Detail |
|---|
public CommonTree()
public CommonTree(CommonTree node)
public CommonTree(Token t)
| Method Detail |
|---|
public Token getToken()
public Tree dupNode()
public boolean isNil()
Tree
isNil in interface TreeisNil in class BaseTreepublic int getType()
Tree
public String getText()
public int getLine()
Tree
getLine in interface TreegetLine in class BaseTreepublic int getCharPositionInLine()
getCharPositionInLine in interface TreegetCharPositionInLine in class BaseTreepublic int getTokenStartIndex()
Tree
public void setTokenStartIndex(int index)
public int getTokenStopIndex()
Tree
public void setTokenStopIndex(int index)
public void setUnknownTokenBoundaries()
public int getChildIndex()
BaseTree
getChildIndex in interface TreegetChildIndex in class BaseTreepublic Tree getParent()
BaseTree
getParent in interface TreegetParent in class BaseTreepublic void setParent(Tree t)
setParent in interface TreesetParent in class BaseTreepublic void setChildIndex(int index)
setChildIndex in interface TreesetChildIndex in class BaseTreepublic String toString()
BaseTree
toString in interface TreetoString in class BaseTree
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||