接口 Tree
-
- 所有已知实现类:
BaseTree,CommonErrorNode,CommonTree,GrammarAST,ParseTree,RemoteDebugEventSocketListener.ProxyTree,TreeWizard.TreePattern,TreeWizard.WildcardTreePattern
public interface TreeWhat 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.
-
-
字段概要
字段 修饰符和类型 字段 说明 static TreeINVALID_NODE
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 voidaddChild(Tree t)Add t as a child to this node.java.lang.ObjectdeleteChild(int i)TreedupNode()voidfreshenParentAndChildIndexes()Set the parent and child index values for all childrenTreegetAncestor(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.intgetCharPositionInLine()TreegetChild(int i)intgetChildCount()intgetChildIndex()This node is what child index? 0..n-1intgetLine()In case we don't have a token payload, what is the line for errors?TreegetParent()java.lang.StringgetText()intgetTokenStartIndex()What is the smallest token index (indexing from 0) for this node and its children?intgetTokenStopIndex()What is the largest token index (indexing from 0) for this node and its children?intgetType()Return a token type; needed for tree parsingbooleanhasAncestor(int ttype)Is there is a node above with token type ttype?booleanisNil()Indicates the node is a nil node but may still have children, meaning the tree is a flat list.voidreplaceChildren(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).voidsetChild(int i, Tree t)Set ith child (0..n-1) to t; t must be non-null and non-nil nodevoidsetChildIndex(int index)voidsetParent(Tree t)voidsetTokenStartIndex(int index)voidsetTokenStopIndex(int index)java.lang.StringtoString()java.lang.StringtoStringTree()
-
-
-
字段详细资料
-
INVALID_NODE
static final Tree INVALID_NODE
-
-
方法详细资料
-
getChild
Tree getChild(int i)
-
getChildCount
int getChildCount()
-
getParent
Tree getParent()
-
setParent
void setParent(Tree t)
-
hasAncestor
boolean hasAncestor(int ttype)
Is there is a node above with token type ttype?
-
getAncestor
Tree getAncestor(int ttype)
Walk upwards and get first ancestor with this token type.
-
getAncestors
java.util.List<?> getAncestors()
Return a list of all ancestors of this node. The first node of list is the root and the last is the parent of this node.
-
getChildIndex
int getChildIndex()
This node is what child index? 0..n-1
-
setChildIndex
void setChildIndex(int index)
-
freshenParentAndChildIndexes
void freshenParentAndChildIndexes()
Set the parent and child index values for all children
-
addChild
void addChild(Tree t)
Add t as a child to this node. If t is null, do nothing. If t is nil, add all children of t to this' children.
-
setChild
void setChild(int i, Tree t)Set ith child (0..n-1) to t; t must be non-null and non-nil node
-
deleteChild
java.lang.Object deleteChild(int i)
-
replaceChildren
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). 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.
-
isNil
boolean isNil()
Indicates the node is a nil node but may still have children, meaning the tree is a flat list.
-
getTokenStartIndex
int getTokenStartIndex()
What is the smallest token index (indexing from 0) for this node and its children?
-
setTokenStartIndex
void setTokenStartIndex(int index)
-
getTokenStopIndex
int getTokenStopIndex()
What is the largest token index (indexing from 0) for this node and its children?
-
setTokenStopIndex
void setTokenStopIndex(int index)
-
dupNode
Tree dupNode()
-
getType
int getType()
Return a token type; needed for tree parsing
-
getText
java.lang.String getText()
-
getLine
int getLine()
In case we don't have a token payload, what is the line for errors?
-
getCharPositionInLine
int getCharPositionInLine()
-
toStringTree
java.lang.String toStringTree()
-
toString
java.lang.String toString()
- 覆盖:
toString在类中java.lang.Object
-
-