类 BaseTree
- java.lang.Object
-
- org.antlr.runtime.tree.BaseTree
-
- 所有已实现的接口:
Tree
public abstract class BaseTree extends java.lang.Object implements Tree
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".
-
-
字段概要
字段 修饰符和类型 字段 说明 protected java.util.List<java.lang.Object>
children
-
从接口继承的字段 org.antlr.runtime.tree.Tree
INVALID_NODE
-
-
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 void
addChild(Tree t)
Add t as child of this node.void
addChildren(java.util.List<? extends Tree> kids)
Add all elements of kids list as children of this nodeprotected java.util.List<java.lang.Object>
createChildrenList()
Override in a subclass to change the impl of children listjava.lang.Object
deleteChild(int i)
void
freshenParentAndChildIndexes()
Set the parent and child index values for all child of tvoid
freshenParentAndChildIndexes(int offset)
void
freshenParentAndChildIndexesDeeply()
void
freshenParentAndChildIndexesDeeply(int offset)
Tree
getAncestor(int ttype)
Walk upwards and get first ancestor with this token type.java.util.List<? extends Tree>
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.java.util.List<? extends java.lang.Object>
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, java.lang.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, java.lang.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 nodevoid
setChildIndex(int index)
void
setParent(Tree t)
abstract java.lang.String
toString()
Override to say how a node (not a tree) should look as textjava.lang.String
toStringTree()
Print out a whole tree not just a node-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
从接口继承的方法 org.antlr.runtime.tree.Tree
dupNode, getText, getTokenStartIndex, getTokenStopIndex, getType, setTokenStartIndex, setTokenStopIndex
-
-
-
-
构造器详细资料
-
BaseTree
public BaseTree()
-
BaseTree
public 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.
-
-
方法详细资料
-
getChildren
public java.util.List<? extends java.lang.Object> getChildren()
Get the children internal List; note that if you directly mess with the list, do so at your own risk.
-
getFirstChildWithType
public Tree getFirstChildWithType(int type)
-
getChildCount
public int getChildCount()
- 指定者:
getChildCount
在接口中Tree
-
addChild
public void 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.
-
addChildren
public void addChildren(java.util.List<? extends Tree> kids)
Add all elements of kids list as children of this node
-
setChild
public void setChild(int i, Tree t)
从接口复制的说明:Tree
Set ith child (0..n-1) to t; t must be non-null and non-nil node
-
insertChild
public void insertChild(int i, java.lang.Object t)
Insert child t at child position i (0..n-1) by shifting children i+1..n-1 to the right one position. Set parent / indexes properly but does NOT collapse nil-rooted t's that come in here like addChild.
-
deleteChild
public java.lang.Object deleteChild(int i)
- 指定者:
deleteChild
在接口中Tree
-
replaceChildren
public 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.- 指定者:
replaceChildren
在接口中Tree
-
createChildrenList
protected java.util.List<java.lang.Object> createChildrenList()
Override in a subclass to change the impl of children list
-
isNil
public boolean isNil()
从接口复制的说明:Tree
Indicates the node is a nil node but may still have children, meaning the tree is a flat list.
-
freshenParentAndChildIndexes
public void freshenParentAndChildIndexes()
Set the parent and child index values for all child of t- 指定者:
freshenParentAndChildIndexes
在接口中Tree
-
freshenParentAndChildIndexes
public void freshenParentAndChildIndexes(int offset)
-
freshenParentAndChildIndexesDeeply
public void freshenParentAndChildIndexesDeeply()
-
freshenParentAndChildIndexesDeeply
public void freshenParentAndChildIndexesDeeply(int offset)
-
sanityCheckParentAndChildIndexes
public void sanityCheckParentAndChildIndexes()
-
sanityCheckParentAndChildIndexes
public void sanityCheckParentAndChildIndexes(Tree parent, int i)
-
getChildIndex
public int getChildIndex()
BaseTree doesn't track child indexes.- 指定者:
getChildIndex
在接口中Tree
-
setChildIndex
public void setChildIndex(int index)
- 指定者:
setChildIndex
在接口中Tree
-
hasAncestor
public boolean hasAncestor(int ttype)
Walk upwards looking for ancestor with this token type.- 指定者:
hasAncestor
在接口中Tree
-
getAncestor
public Tree getAncestor(int ttype)
Walk upwards and get first ancestor with this token type.- 指定者:
getAncestor
在接口中Tree
-
getAncestors
public java.util.List<? extends Tree> 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.- 指定者:
getAncestors
在接口中Tree
-
toStringTree
public java.lang.String toStringTree()
Print out a whole tree not just a node- 指定者:
toStringTree
在接口中Tree
-
getLine
public int getLine()
从接口复制的说明:Tree
In case we don't have a token payload, what is the line for errors?
-
getCharPositionInLine
public int getCharPositionInLine()
- 指定者:
getCharPositionInLine
在接口中Tree
-
-