public class DebugTreeNodeStream extends Object implements TreeNodeStream
| Modifier and Type | Field and Description |
|---|---|
protected TreeAdaptor |
adaptor |
protected DebugEventListener |
dbg |
protected boolean |
initialStreamState |
protected TreeNodeStream |
input |
protected int |
lastMarker
Track the last mark() call result value for use in rewind().
|
| Constructor and Description |
|---|
DebugTreeNodeStream(TreeNodeStream input,
DebugEventListener dbg) |
| Modifier and Type | Method and Description |
|---|---|
void |
consume() |
Object |
get(int i)
Get a tree node at an absolute index
i; 0..n-1. |
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 a
TokenStream, you can specify it here. |
TreeAdaptor |
getTreeAdaptor()
What adaptor can tell me how to interpret/navigate nodes and
trees.
|
Object |
getTreeSource()
Where is this stream pulling nodes from? This is not the name, but
the object that provides node objects.
|
int |
index()
Return the current input symbol index 0..n where n indicates the
last symbol has been read.
|
int |
LA(int i)
Get int at current input pointer + i ahead where i=1 is next int.
|
Object |
LT(int i)
Get tree node at current input pointer +
k ahead where
k==1 is next node. |
int |
mark()
Tell the stream to start buffering if it hasn't already.
|
void |
release(int marker)
You may want to commit to a backtrack but don't want to force the
stream to keep bookkeeping objects around for a marker that is
no longer necessary.
|
void |
replaceChildren(Object parent,
int startChildIndex,
int stopChildIndex,
Object t)
Replace children of
parent from index startChildIndex to
stopChildIndex with t, 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 |
rewind()
Rewind to the input position of the last marker.
|
void |
rewind(int marker)
Reset the stream so that next call to index would return marker.
|
void |
seek(int index)
Set the input cursor to the position indicated by index.
|
void |
setDebugListener(DebugEventListener dbg) |
void |
setUniqueNavigationNodes(boolean uniqueNavigationNodes)
It is normally this object that instructs the node stream to
create unique nav nodes, but to satisfy interface, we have to
define it.
|
int |
size()
Only makes sense for streams that buffer everything up probably, but
might be useful to display the entire stream or for testing.
|
String |
toString(Object start,
Object stop)
Return the text of all nodes from
start to stop,
inclusive. |
protected DebugEventListener dbg
protected TreeAdaptor adaptor
protected TreeNodeStream input
protected boolean initialStreamState
protected int lastMarker
public DebugTreeNodeStream(TreeNodeStream input, DebugEventListener dbg)
public void setDebugListener(DebugEventListener dbg)
public TreeAdaptor getTreeAdaptor()
TreeNodeStreamgetTreeAdaptor in interface TreeNodeStreampublic Object get(int i)
TreeNodeStreami; 0..n-1.
If you don't want to buffer up nodes, then this method makes no
sense for you.get in interface TreeNodeStreampublic Object LT(int i)
TreeNodeStreamk ahead where
k==1 is next node. k<0 indicates nodes in the past. So
LT(-1) is previous node, but implementations are not required to
provide results for k < -1. LT(0) is undefined. For
k<=n, return null. Return null for LT(0)
and any index that results in an absolute address that is negative.
This is analogous to TokenStream.LT(int), but this returns a tree node
instead of a Token. Makes code generation identical for both
parser and tree grammars.LT in interface TreeNodeStreampublic int LA(int i)
IntStreampublic int mark()
IntStreampublic int index()
IntStreampublic void rewind(int marker)
IntStreampublic void rewind()
IntStreampublic void release(int marker)
IntStreampublic void seek(int index)
IntStreampublic int size()
IntStreampublic void reset()
TreeNodeStreamreset in interface TreeNodeStreampublic Object getTreeSource()
TreeNodeStreamgetTreeSource in interface TreeNodeStreampublic String getSourceName()
IntStreamgetSourceName in interface IntStreampublic TokenStream getTokenStream()
TreeNodeStreamTokenStream, you can specify it here. Used to do rule
$text attribute in tree parser. Optional unless you use tree
parser rule $text attribute or output=template and
rewrite=true options.getTokenStream in interface TreeNodeStreampublic void setUniqueNavigationNodes(boolean uniqueNavigationNodes)
setUniqueNavigationNodes in interface TreeNodeStreampublic void replaceChildren(Object parent, int startChildIndex, int stopChildIndex, Object t)
TreeNodeStreamparent from index startChildIndex to
stopChildIndex with t, 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 is null, don't do anything; must be at root of
overall tree. Can't replace whatever points to the parent externally. Do
nothing.replaceChildren in interface TreeNodeStreampublic String toString(Object start, Object stop)
TreeNodeStreamstart to stop,
inclusive. If the stream does not buffer all the nodes then it can still
walk recursively from start until stop. You can always return
null or "" too, but users should not access
$ruleLabel.text in an action of course in that case.toString in interface TreeNodeStreamCopyright © 1992-2013 ANTLR. All Rights Reserved.