类 CommonTreeNodeStream
- java.lang.Object
-
- org.antlr.runtime.misc.FastQueue<T>
-
- org.antlr.runtime.misc.LookaheadStream<java.lang.Object>
-
- org.antlr.runtime.tree.CommonTreeNodeStream
-
- 所有已实现的接口:
IntStream
,PositionTrackingStream<java.lang.Object>
,TreeNodeStream
public class CommonTreeNodeStream extends LookaheadStream<java.lang.Object> implements TreeNodeStream, PositionTrackingStream<java.lang.Object>
-
-
字段概要
字段 修饰符和类型 字段 说明 protected IntArray
calls
Stack of indexes used for push/pop calls.static int
DEFAULT_INITIAL_BUFFER_SIZE
protected boolean
hasNilRoot
Tree(nil A B C)
trees like flatA B C
streamsstatic int
INITIAL_CALL_STACK_SIZE
protected TreeIterator
it
TheTreeIterator
we using.protected int
level
Tracks tree depth.protected java.lang.Object
previousLocationElement
Tracks the last node before the start ofFastQueue.data
which contains position information to provide information for error reporting.protected java.lang.Object
root
Pull nodes from which tree?protected TokenStream
tokens
If this tree (root) was created from aTokenStream
, track it.-
从类继承的字段 org.antlr.runtime.misc.LookaheadStream
currentElementIndex, eof, lastMarker, markDepth, prevElement, UNINITIALIZED_EOF_ELEMENT_INDEX
-
-
构造器概要
构造器 构造器 说明 CommonTreeNodeStream(java.lang.Object tree)
CommonTreeNodeStream(TreeAdaptor adaptor, java.lang.Object tree)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 java.lang.Object
get(int i)
Get a tree node at an absolute indexi
; 0..n-1.java.lang.Object
getKnownPositionElement(boolean allowApproximateLocation)
Returns an element containing position information.java.lang.String
getSourceName()
Where are you getting symbols from? Normally, implementations will pass the buck all the way to the lexer who can ask its input stream for the file name or whatever.TokenStream
getTokenStream()
If the tree associated with this stream was created from aTokenStream
, you can specify it here.TreeAdaptor
getTreeAdaptor()
What adaptor can tell me how to interpret/navigate nodes and trees.java.lang.Object
getTreeSource()
Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.boolean
hasPositionInformation(java.lang.Object node)
Determines if the specifiedelement
contains concrete position information.boolean
isEOF(java.lang.Object o)
int
LA(int i)
Get int at current input pointer + i ahead where i=1 is next int.java.lang.Object
nextElement()
Pull elements from tree iterator.int
pop()
Seek back to previous index saved during lastpush(int)
call.void
push(int index)
Make stream jump to a new location, saving old location.java.lang.Object
remove()
Get and remove first element in queue; overrideFastQueue.remove()
; it's the same, just checks for backtracking.void
replaceChildren(java.lang.Object parent, int startChildIndex, int stopChildIndex, java.lang.Object t)
Replace children ofparent
from indexstartChildIndex
tostopChildIndex
witht
, which might be a list.void
reset()
Reset the tree node stream in such a way that it acts like a freshly constructed stream.void
setTokenStream(TokenStream tokens)
void
setTreeAdaptor(TreeAdaptor adaptor)
void
setUniqueNavigationNodes(boolean uniqueNavigationNodes)
As we flatten the tree, we useToken.UP
,Token.DOWN
nodes to represent the tree structure.java.lang.String
toString(java.lang.Object start, java.lang.Object stop)
Return the text of all nodes fromstart
tostop
, inclusive.java.lang.String
toTokenTypeString()
For debugging; destructive: moves tree iterator to end.-
从类继承的方法 org.antlr.runtime.misc.LookaheadStream
consume, fill, index, LB, LT, mark, release, rewind, rewind, seek, size, syncAhead
-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
从接口继承的方法 org.antlr.runtime.tree.TreeNodeStream
LT
-
-
-
-
字段详细资料
-
DEFAULT_INITIAL_BUFFER_SIZE
public static final int DEFAULT_INITIAL_BUFFER_SIZE
- 另请参阅:
- 常量字段值
-
INITIAL_CALL_STACK_SIZE
public static final int INITIAL_CALL_STACK_SIZE
- 另请参阅:
- 常量字段值
-
root
protected java.lang.Object root
Pull nodes from which tree?
-
tokens
protected TokenStream tokens
If this tree (root) was created from aTokenStream
, track it.
-
it
protected TreeIterator it
TheTreeIterator
we using.
-
calls
protected IntArray calls
Stack of indexes used for push/pop calls.
-
hasNilRoot
protected boolean hasNilRoot
Tree(nil A B C)
trees like flatA B C
streams
-
level
protected int level
Tracks tree depth. Level=0 means we're at root node level.
-
previousLocationElement
protected java.lang.Object previousLocationElement
Tracks the last node before the start ofFastQueue.data
which contains position information to provide information for error reporting. This is tracked in addition toLookaheadStream.prevElement
which may or may not contain position information.
-
-
构造器详细资料
-
CommonTreeNodeStream
public CommonTreeNodeStream(java.lang.Object tree)
-
CommonTreeNodeStream
public CommonTreeNodeStream(TreeAdaptor adaptor, java.lang.Object tree)
-
-
方法详细资料
-
reset
public void reset()
从接口复制的说明:TreeNodeStream
Reset the tree node stream in such a way that it acts like a freshly constructed stream.- 指定者:
reset
在接口中TreeNodeStream
- 覆盖:
reset
在类中LookaheadStream<java.lang.Object>
-
nextElement
public java.lang.Object nextElement()
Pull elements from tree iterator. Track tree level 0..max_level. If nil rooted tree, don't give initial nil and DOWN nor final UP.- 指定者:
nextElement
在类中LookaheadStream<java.lang.Object>
- 另请参阅:
LookaheadStream.isEOF(T)
-
remove
public java.lang.Object remove()
从类复制的说明:LookaheadStream
Get and remove first element in queue; overrideFastQueue.remove()
; it's the same, just checks for backtracking.- 覆盖:
remove
在类中LookaheadStream<java.lang.Object>
-
isEOF
public boolean isEOF(java.lang.Object o)
- 指定者:
isEOF
在类中LookaheadStream<java.lang.Object>
-
setUniqueNavigationNodes
public void setUniqueNavigationNodes(boolean uniqueNavigationNodes)
从接口复制的说明:TreeNodeStream
As we flatten the tree, we useToken.UP
,Token.DOWN
nodes to represent the tree structure. When debugging we need unique nodes so we have to instantiate new ones. When doing normal tree parsing, it's slow and a waste of memory to create unique navigation nodes. Default should befalse
.- 指定者:
setUniqueNavigationNodes
在接口中TreeNodeStream
-
getTreeSource
public java.lang.Object getTreeSource()
从接口复制的说明:TreeNodeStream
Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.- 指定者:
getTreeSource
在接口中TreeNodeStream
-
getSourceName
public java.lang.String getSourceName()
从接口复制的说明:IntStream
Where are you getting symbols from? Normally, implementations will pass the buck all the way to the lexer who can ask its input stream for the file name or whatever.- 指定者:
getSourceName
在接口中IntStream
-
getTokenStream
public TokenStream getTokenStream()
从接口复制的说明:TreeNodeStream
If the tree associated with this stream was created from aTokenStream
, you can specify it here. Used to do rule$text
attribute in tree parser. Optional unless you use tree parser rule$text
attribute oroutput=template
andrewrite=true
options.- 指定者:
getTokenStream
在接口中TreeNodeStream
-
setTokenStream
public void setTokenStream(TokenStream tokens)
-
getTreeAdaptor
public TreeAdaptor getTreeAdaptor()
从接口复制的说明:TreeNodeStream
What adaptor can tell me how to interpret/navigate nodes and trees. E.g., get text of a node.- 指定者:
getTreeAdaptor
在接口中TreeNodeStream
-
setTreeAdaptor
public void setTreeAdaptor(TreeAdaptor adaptor)
-
get
public java.lang.Object get(int i)
从接口复制的说明:TreeNodeStream
Get a tree node at an absolute indexi
; 0..n-1. If you don't want to buffer up nodes, then this method makes no sense for you.- 指定者:
get
在接口中TreeNodeStream
-
LA
public int LA(int i)
从接口复制的说明:IntStream
Get int at current input pointer + i ahead where i=1 is next int. Negative indexes are allowed. LA(-1) is previous token (token just matched). LA(-i) where i is before first token should yield -1, invalid char / EOF.
-
push
public void push(int index)
Make stream jump to a new location, saving old location. Switch back with pop().
-
pop
public int pop()
Seek back to previous index saved during lastpush(int)
call. Return top of stack (return index).
-
getKnownPositionElement
public java.lang.Object getKnownPositionElement(boolean allowApproximateLocation)
Returns an element containing position information. IfallowApproximateLocation
isfalse
, then this method will return theLT(1)
element if it contains position information, and otherwise returnnull
. IfallowApproximateLocation
istrue
, then this method will return the last known element containing position information.- 指定者:
getKnownPositionElement
在接口中PositionTrackingStream<java.lang.Object>
- 参数:
allowApproximateLocation
- iffalse
, this method returnsnull
if an element containing exact information about the current position is not available- 另请参阅:
hasPositionInformation(java.lang.Object)
-
hasPositionInformation
public boolean hasPositionInformation(java.lang.Object node)
从接口复制的说明:PositionTrackingStream
Determines if the specifiedelement
contains concrete position information.- 指定者:
hasPositionInformation
在接口中PositionTrackingStream<java.lang.Object>
- 参数:
node
- the element to check- 返回:
true
ifelement
contains concrete position information, otherwisefalse
-
replaceChildren
public void replaceChildren(java.lang.Object parent, int startChildIndex, int stopChildIndex, java.lang.Object t)
从接口复制的说明:TreeNodeStream
Replace children ofparent
from indexstartChildIndex
tostopChildIndex
witht
, which might be a list. Number of children may be different after this call. The stream is notified because it is walking the tree and might need to know you are monkeying with the underlying tree. Also, it might be able to modify the node stream to avoid restreaming for future phases.If
parent
isnull
, don't do anything; must be at root of overall tree. Can't replace whatever points to the parent externally. Do nothing.- 指定者:
replaceChildren
在接口中TreeNodeStream
-
toString
public java.lang.String toString(java.lang.Object start, java.lang.Object stop)
从接口复制的说明:TreeNodeStream
Return the text of all nodes fromstart
tostop
, inclusive. If the stream does not buffer all the nodes then it can still walk recursively from start until stop. You can always returnnull
or""
too, but users should not access$ruleLabel.text
in an action of course in that case.- 指定者:
toString
在接口中TreeNodeStream
-
toTokenTypeString
public java.lang.String toTokenTypeString()
For debugging; destructive: moves tree iterator to end.
-
-