类 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 IntArraycallsStack of indexes used for push/pop calls.static intDEFAULT_INITIAL_BUFFER_SIZEprotected booleanhasNilRootTree(nil A B C)trees like flatA B Cstreamsstatic intINITIAL_CALL_STACK_SIZEprotected TreeIteratoritTheTreeIteratorwe using.protected intlevelTracks tree depth.protected java.lang.ObjectpreviousLocationElementTracks the last node before the start ofFastQueue.datawhich contains position information to provide information for error reporting.protected java.lang.ObjectrootPull nodes from which tree?protected TokenStreamtokensIf 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.Objectget(int i)Get a tree node at an absolute indexi; 0..n-1.java.lang.ObjectgetKnownPositionElement(boolean allowApproximateLocation)Returns an element containing position information.java.lang.StringgetSourceName()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.TokenStreamgetTokenStream()If the tree associated with this stream was created from aTokenStream, you can specify it here.TreeAdaptorgetTreeAdaptor()What adaptor can tell me how to interpret/navigate nodes and trees.java.lang.ObjectgetTreeSource()Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.booleanhasPositionInformation(java.lang.Object node)Determines if the specifiedelementcontains concrete position information.booleanisEOF(java.lang.Object o)intLA(int i)Get int at current input pointer + i ahead where i=1 is next int.java.lang.ObjectnextElement()Pull elements from tree iterator.intpop()Seek back to previous index saved during lastpush(int)call.voidpush(int index)Make stream jump to a new location, saving old location.java.lang.Objectremove()Get and remove first element in queue; overrideFastQueue.remove(); it's the same, just checks for backtracking.voidreplaceChildren(java.lang.Object parent, int startChildIndex, int stopChildIndex, java.lang.Object t)Replace children ofparentfrom indexstartChildIndextostopChildIndexwitht, which might be a list.voidreset()Reset the tree node stream in such a way that it acts like a freshly constructed stream.voidsetTokenStream(TokenStream tokens)voidsetTreeAdaptor(TreeAdaptor adaptor)voidsetUniqueNavigationNodes(boolean uniqueNavigationNodes)As we flatten the tree, we useToken.UP,Token.DOWNnodes to represent the tree structure.java.lang.StringtoString(java.lang.Object start, java.lang.Object stop)Return the text of all nodes fromstarttostop, inclusive.java.lang.StringtoTokenTypeString()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
TheTreeIteratorwe 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 Cstreams
-
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.datawhich contains position information to provide information for error reporting. This is tracked in addition toLookaheadStream.prevElementwhich 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()
从接口复制的说明:TreeNodeStreamReset 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()
从类复制的说明:LookaheadStreamGet 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)
从接口复制的说明:TreeNodeStreamAs we flatten the tree, we useToken.UP,Token.DOWNnodes 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()
从接口复制的说明:TreeNodeStreamWhere 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()
从接口复制的说明:IntStreamWhere 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()
从接口复制的说明:TreeNodeStreamIf the tree associated with this stream was created from aTokenStream, you can specify it here. Used to do rule$textattribute in tree parser. Optional unless you use tree parser rule$textattribute oroutput=templateandrewrite=trueoptions.- 指定者:
getTokenStream在接口中TreeNodeStream
-
setTokenStream
public void setTokenStream(TokenStream tokens)
-
getTreeAdaptor
public TreeAdaptor getTreeAdaptor()
从接口复制的说明:TreeNodeStreamWhat 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)
从接口复制的说明:TreeNodeStreamGet 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)
从接口复制的说明:IntStreamGet 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. IfallowApproximateLocationisfalse, then this method will return theLT(1)element if it contains position information, and otherwise returnnull. IfallowApproximateLocationistrue, then this method will return the last known element containing position information.- 指定者:
getKnownPositionElement在接口中PositionTrackingStream<java.lang.Object>- 参数:
allowApproximateLocation- iffalse, this method returnsnullif an element containing exact information about the current position is not available- 另请参阅:
hasPositionInformation(java.lang.Object)
-
hasPositionInformation
public boolean hasPositionInformation(java.lang.Object node)
从接口复制的说明:PositionTrackingStreamDetermines if the specifiedelementcontains concrete position information.- 指定者:
hasPositionInformation在接口中PositionTrackingStream<java.lang.Object>- 参数:
node- the element to check- 返回:
trueifelementcontains concrete position information, otherwisefalse
-
replaceChildren
public void replaceChildren(java.lang.Object parent, int startChildIndex, int stopChildIndex, java.lang.Object t)从接口复制的说明:TreeNodeStreamReplace children ofparentfrom indexstartChildIndextostopChildIndexwitht, 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
parentisnull, 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)从接口复制的说明:TreeNodeStreamReturn the text of all nodes fromstarttostop, inclusive. If the stream does not buffer all the nodes then it can still walk recursively from start until stop. You can always returnnullor""too, but users should not access$ruleLabel.textin an action of course in that case.- 指定者:
toString在接口中TreeNodeStream
-
toTokenTypeString
public java.lang.String toTokenTypeString()
For debugging; destructive: moves tree iterator to end.
-
-