public class CommonTreeNodeStream extends LookaheadStream<java.lang.Object> implements TreeNodeStream
| Modifier and Type | Field and Description |
|---|---|
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 flat A B C streams
|
static int |
INITIAL_CALL_STACK_SIZE |
protected TreeIterator |
it
The tree iterator we using
|
protected int |
level
Tracks tree depth.
|
protected java.lang.Object |
root
Pull nodes from which tree?
|
protected TokenStream |
tokens
If this tree (root) was created from a token stream, track it.
|
currentElementIndex, eof, lastMarker, markDepth, prevElement, UNINITIALIZED_EOF_ELEMENT_INDEX| Constructor and Description |
|---|
CommonTreeNodeStream(java.lang.Object tree) |
CommonTreeNodeStream(TreeAdaptor adaptor,
java.lang.Object tree) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
get(int i)
Get a tree node at an absolute index i; 0..n-1.
|
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 a TokenStream,
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 |
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 last push() call.
|
void |
push(int index)
Make stream jump to a new location, saving old location.
|
void |
replaceChildren(java.lang.Object parent,
int startChildIndex,
int stopChildIndex,
java.lang.Object t)
Replace from start to stop child index of parent 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 |
setTokenStream(TokenStream tokens) |
void |
setTreeAdaptor(TreeAdaptor adaptor) |
void |
setUniqueNavigationNodes(boolean uniqueNavigationNodes)
As we flatten the tree, we use UP, 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 from start to stop, inclusive.
|
java.lang.String |
toTokenTypeString()
For debugging; destructive: moves tree iterator to end.
|
consume, fill, index, LB, LT, mark, release, remove, rewind, rewind, seek, size, syncAheadadd, clear, elementAt, head, range, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitLTpublic static final int DEFAULT_INITIAL_BUFFER_SIZE
public static final int INITIAL_CALL_STACK_SIZE
protected java.lang.Object root
protected TokenStream tokens
protected TreeIterator it
protected IntArray calls
protected boolean hasNilRoot
protected int level
public CommonTreeNodeStream(java.lang.Object tree)
public CommonTreeNodeStream(TreeAdaptor adaptor, java.lang.Object tree)
public void reset()
TreeNodeStreamreset in interface TreeNodeStreamreset in class LookaheadStream<java.lang.Object>public java.lang.Object nextElement()
nextElement in class LookaheadStream<java.lang.Object>public boolean isEOF(java.lang.Object o)
isEOF in class LookaheadStream<java.lang.Object>public void setUniqueNavigationNodes(boolean uniqueNavigationNodes)
TreeNodeStreamsetUniqueNavigationNodes in interface TreeNodeStreampublic java.lang.Object getTreeSource()
TreeNodeStreamgetTreeSource in interface TreeNodeStreampublic java.lang.String getSourceName()
IntStreamgetSourceName in interface IntStreampublic TokenStream getTokenStream()
TreeNodeStreamgetTokenStream in interface TreeNodeStreampublic void setTokenStream(TokenStream tokens)
public TreeAdaptor getTreeAdaptor()
TreeNodeStreamgetTreeAdaptor in interface TreeNodeStreampublic void setTreeAdaptor(TreeAdaptor adaptor)
public java.lang.Object get(int i)
TreeNodeStreamget in interface TreeNodeStreampublic int LA(int i)
IntStreampublic void push(int index)
public int pop()
public void replaceChildren(java.lang.Object parent,
int startChildIndex,
int stopChildIndex,
java.lang.Object t)
TreeNodeStreamreplaceChildren in interface TreeNodeStreampublic java.lang.String toString(java.lang.Object start,
java.lang.Object stop)
TreeNodeStreamtoString in interface TreeNodeStreampublic java.lang.String toTokenTypeString()