类 CommonTree
- java.lang.Object
-
- org.antlr.runtime.tree.BaseTree
-
- org.antlr.runtime.tree.CommonTree
-
- 所有已实现的接口:
Tree
- 直接已知子类:
CommonErrorNode
,GrammarAST
,TreeWizard.TreePattern
public class CommonTree extends BaseTree
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.
-
-
字段概要
字段 修饰符和类型 字段 说明 int
childIndex
What index is this node in the child list? Range: 0..n-1CommonTree
parent
Who is the parent node of this node; if null, implies node is rootprotected 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-
从接口继承的字段 org.antlr.runtime.tree.Tree
INVALID_NODE
-
-
构造器概要
构造器 构造器 说明 CommonTree()
CommonTree(Token t)
CommonTree(CommonTree node)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.java.lang.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 parsingboolean
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.java.lang.String
toString()
Override to say how a node (not a tree) should look as text-
从类继承的方法 org.antlr.runtime.tree.BaseTree
addChild, addChildren, createChildrenList, deleteChild, freshenParentAndChildIndexes, freshenParentAndChildIndexes, freshenParentAndChildIndexesDeeply, freshenParentAndChildIndexesDeeply, getAncestor, getAncestors, getChild, getChildCount, getChildren, getFirstChildWithType, hasAncestor, insertChild, replaceChildren, sanityCheckParentAndChildIndexes, sanityCheckParentAndChildIndexes, setChild, toStringTree
-
-
-
-
字段详细资料
-
token
public Token token
A single token is the payload
-
startIndex
protected int startIndex
What token indexes bracket all tokens associated with this node and below?
-
stopIndex
protected int stopIndex
What token indexes bracket all tokens associated with this node and below?
-
parent
public CommonTree parent
Who is the parent node of this node; if null, implies node is root
-
childIndex
public int childIndex
What index is this node in the child list? Range: 0..n-1
-
-
构造器详细资料
-
CommonTree
public CommonTree()
-
CommonTree
public CommonTree(CommonTree node)
-
CommonTree
public CommonTree(Token t)
-
-
方法详细资料
-
getToken
public Token getToken()
-
dupNode
public Tree dupNode()
-
isNil
public boolean isNil()
从接口复制的说明:Tree
Indicates the node is a nil node but may still have children, meaning the tree is a flat list.
-
getType
public int getType()
从接口复制的说明:Tree
Return a token type; needed for tree parsing
-
getText
public java.lang.String getText()
-
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
- 覆盖:
getCharPositionInLine
在类中BaseTree
-
getTokenStartIndex
public int getTokenStartIndex()
从接口复制的说明:Tree
What is the smallest token index (indexing from 0) for this node and its children?
-
setTokenStartIndex
public void setTokenStartIndex(int index)
-
getTokenStopIndex
public int getTokenStopIndex()
从接口复制的说明:Tree
What is the largest token index (indexing from 0) for this node and its children?
-
setTokenStopIndex
public void setTokenStopIndex(int index)
-
setUnknownTokenBoundaries
public void setUnknownTokenBoundaries()
For every node in this subtree, make sure it's start/stop token's are set. Walk depth first, visit bottom up. Only updates nodes with at least one token index < 0.
-
getChildIndex
public int getChildIndex()
从类复制的说明:BaseTree
BaseTree doesn't track child indexes.- 指定者:
getChildIndex
在接口中Tree
- 覆盖:
getChildIndex
在类中BaseTree
-
setChildIndex
public void setChildIndex(int index)
- 指定者:
setChildIndex
在接口中Tree
- 覆盖:
setChildIndex
在类中BaseTree
-
-