CommonTreeNodeStream
| Modifier and Type | Class and Description |
|---|---|
| protected class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv TreeAdaptor | adaptor
What tree adaptor was used to build these trees |
| protected IntArray | calls
Stack of indexes used for push/pop calls |
| public static final int | |
| protected Object | |
| protected Object | |
| public static final int | |
| protected int | lastMarker
Track the last mark() call result value for use in rewind(). |
| protected List | nodes
The complete mapping from stream index to tree node. |
| protected int | p
The index into the nodes list of the current node (next node to consume). |
| protected Object | root
Pull nodes from which tree? |
| protected TokenStream | tokens
IF this tree (root) was created from a token stream, track it. |
| protected boolean | uniqueNavigationNodes
Reuse same DOWN, UP navigation nodes unless this is true |
| protected Object |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addNavigationNode(final int ttype)
As we flatten the tree, we use UP, DOWN nodes to represent the tree structure. |
| public void | |
| protected void | |
| public void | |
| public Object | get(int i)
Implements org. i; 0..n-1.
|
| public Object | |
| protected int | |
| public String | getSourceName()
Implements org. |
| public TokenStream | getTokenStream()
Implements org. TokenStream, you can specify it here.
|
| public TreeAdaptor | getTreeAdaptor()
Implements org. |
| public Object | getTreeSource()
Implements org. |
| public boolean | |
| public int | index()
Implements org. |
| public Iterator | |
| public int | LA(int i)
Implements org. |
| protected Object | |
| public Object | LT(int k)
Implements org. k ahead where
k==1 is next node.
|
| public int | mark()
Implements org. |
| public int | |
| public void | |
| public void | release(int marker)
Implements org. |
| public void | replaceChildren(Object parent, int startChildIndex, int stopChildIndex, Object t)
Implements org. parent from index startChildIndex to
stopChildIndex with t, which might be a list.
|
| public void | reset()
Implements org. |
| public void | rewind(int marker)
Implements org. |
| public void | rewind()
Implements org. |
| public void | seek(int index)
Implements org. |
| public void | |
| public void | |
| public void | setUniqueNavigationNodes(boolean uniqueNavigationNodes)
Implements org. Token#UP, Token#DOWN nodes
to represent the tree structure.
|
| public int | size()
Implements org. |
| public String | toString(Object start, Object stop)
Implements org. start to stop,
inclusive.
|
| public String | |
| public String |
| adaptor | back to summary |
|---|---|
| pack-priv TreeAdaptor adaptor What tree adaptor was used to build these trees | |
| calls | back to summary |
|---|---|
| protected IntArray calls Stack of indexes used for push/pop calls | |
| DEFAULT_INITIAL_BUFFER_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_INITIAL_BUFFER_SIZE | |
| down | back to summary |
|---|---|
| protected Object down | |
| eof | back to summary |
|---|---|
| protected Object eof | |
| INITIAL_CALL_STACK_SIZE | back to summary |
|---|---|
| public static final int INITIAL_CALL_STACK_SIZE | |
| lastMarker | back to summary |
|---|---|
| protected int lastMarker Track the last mark() call result value for use in rewind(). | |
| nodes | back to summary |
|---|---|
| protected List<Object> nodes The complete mapping from stream index to tree node. This buffer includes pointers to DOWN, UP, and EOF nodes. It is built upon ctor invocation. The elements are type Object as we don't what the trees look like. Load upon first need of the buffer so we can set token types of interest for reverseIndexing. Slows us down a wee bit to do all of the if p==-1 testing everywhere though. | |
| p | back to summary |
|---|---|
| protected int p The index into the nodes list of the current node (next node to consume). If -1, nodes array not filled yet. | |
| root | back to summary |
|---|---|
| protected Object root Pull nodes from which tree? | |
| tokens | back to summary |
|---|---|
| protected TokenStream tokens IF this tree (root) was created from a token stream, track it. | |
| uniqueNavigationNodes | back to summary |
|---|---|
| protected boolean uniqueNavigationNodes Reuse same DOWN, UP navigation nodes unless this is true | |
| up | back to summary |
|---|---|
| protected Object up | |
| BufferedTreeNodeStream | back to summary |
|---|---|
| public BufferedTreeNodeStream(Object tree) | |
| BufferedTreeNodeStream | back to summary |
|---|---|
| public BufferedTreeNodeStream(TreeAdaptor adaptor, Object tree) | |
| BufferedTreeNodeStream | back to summary |
|---|---|
| public BufferedTreeNodeStream(TreeAdaptor adaptor, Object tree, int initialBufferSize) | |
| addNavigationNode | back to summary |
|---|---|
| protected void addNavigationNode(final int ttype) As we flatten the tree, we use UP, DOWN nodes to represent the tree structure. When debugging we need unique nodes so instantiate new ones when uniqueNavigationNodes is true. | |
| consume | back to summary |
|---|---|
| public void consume() Implements org.
| |
| fillBuffer | back to summary |
|---|---|
| protected void fillBuffer() Walk tree with depth-first-search and fill nodes buffer. Don't do DOWN, UP nodes if its a list (t is isNil). | |
| fillBuffer | back to summary |
|---|---|
| public void fillBuffer(Object t) | |
| get | back to summary |
|---|---|
| public Object get(int i) Implements org. Doc from org. Get a tree node at an absolute index
| |
| getCurrentSymbol | back to summary |
|---|---|
| public Object getCurrentSymbol() | |
| getNodeIndex | back to summary |
|---|---|
| protected int getNodeIndex(Object node) What is the stream index for node? 0..n-1 Return -1 if node not found. | |
| getSourceName | back to summary |
|---|---|
| public String getSourceName() Implements org. Doc from org. 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.
| |
| getTokenStream | back to summary |
|---|---|
| public TokenStream getTokenStream() Implements org. Doc from org. If the tree associated with this stream was created from a
| |
| getTreeAdaptor | back to summary |
|---|---|
| public TreeAdaptor getTreeAdaptor() Implements org. Doc from org. What adaptor can tell me how to interpret/navigate nodes and trees. E.g., get text of a node.
| |
| getTreeSource | back to summary |
|---|---|
| public Object getTreeSource() Implements org. Doc from org. Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.
| |
| hasUniqueNavigationNodes | back to summary |
|---|---|
| public boolean hasUniqueNavigationNodes() | |
| index | back to summary |
|---|---|
| public int index() Implements org. Doc from org. Return the current input symbol index 0..n where n indicates the last symbol has been read. The index is the symbol about to be read not the most recently read symbol.
| |
| iterator | back to summary |
|---|---|
| public Iterator | |
| LA | back to summary |
|---|---|
| public int LA(int i) Implements org. Doc from org. 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.
| |
| LB | back to summary |
|---|---|
| protected Object LB(int k) Look backwards k nodes | |
| LT | back to summary |
|---|---|
| public Object LT(int k) Implements org. Doc from org. Get tree node at current input pointer +
This is analogous to
| |
| mark | back to summary |
|---|---|
| public int mark() Implements org. Doc from org. Tell the stream to start buffering if it hasn't already. Return current input position, index(), or some other marker so that when passed to rewind() you get back to the same spot. rewind(mark()) should not affect the input cursor. The Lexer track line/col info as well as input index so its markers are not pure input indexes. Same for tree node streams.
| |
| pop | back to summary |
|---|---|
| public int pop() Seek back to previous index saved during last push() call. Return top of stack (return index). | |
| push | back to summary |
|---|---|
| public void push(int index) Make stream jump to a new location, saving old location. Switch back with pop(). | |
| release | back to summary |
|---|---|
| public void release(int marker) Implements org. Doc from org. 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. This will have the same behavior as rewind() except it releases resources without the backward seek. This must throw away resources for all markers back to the marker argument. So if you're nested 5 levels of mark(), and then release(2) you have to release resources for depths 2..5.
| |
| replaceChildren | back to summary |
|---|---|
| public void replaceChildren(Object parent, int startChildIndex, int stopChildIndex, Object t) Implements org. Doc from org. Replace children of
If
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Reset the tree node stream in such a way that it acts like a freshly constructed stream.
| |
| rewind | back to summary |
|---|---|
| public void rewind(int marker) Implements org. Doc from org. Reset the stream so that next call to index would return marker. The marker will usually be index() but it doesn't have to be. It's just a marker to indicate what state the stream was in. This is essentially calling release() and seek(). If there are markers created after this marker argument, this routine must unroll them like a stack. Assume the state the stream was in when this marker was created.
| |
| rewind | back to summary |
|---|---|
| public void rewind() Implements org. Doc from org. Rewind to the input position of the last marker. Used currently only after a cyclic DFA and just before starting a sem/syn predicate to get the input position back to the start of the decision. Do not "pop" the marker off the state. mark(i) and rewind(i) should balance still. It is like invoking rewind(last marker) but it should not "pop" the marker off. It's like seek(last marker's input position).
| |
| seek | back to summary |
|---|---|
| public void seek(int index) Implements org. Doc from org. Set the input cursor to the position indicated by index. This is normally used to seek ahead in the input stream. No buffering is required to do this unless you know your stream will use seek to move backwards such as when backtracking. This is different from rewind in its multi-directional requirement and in that its argument is strictly an input cursor (index). For char streams, seeking forward must update the stream state such as line number. For seeking backwards, you will be presumably backtracking using the mark/rewind mechanism that restores state and so this method does not need to update state when seeking backwards. Currently, this method is only used for efficient backtracking using memoization, but in the future it may be used for incremental parsing. The index is 0..n-1. A seek to position i means that LA(1) will return the ith symbol. So, seeking to 0 means LA(1) will return the first element in the stream.
| |
| setTokenStream | back to summary |
|---|---|
| public void setTokenStream(TokenStream tokens) | |
| setTreeAdaptor | back to summary |
|---|---|
| public void setTreeAdaptor(TreeAdaptor adaptor) | |
| setUniqueNavigationNodes | back to summary |
|---|---|
| public void setUniqueNavigationNodes(boolean uniqueNavigationNodes) Implements org. Doc from org. As we flatten the tree, we use
| |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from org. Only makes sense for streams that buffer everything up probably, but might be useful to display the entire stream or for testing. This value includes a single EOF.
| |
| toString | back to summary |
|---|---|
| public String toString(Object start, Object stop) Implements org. Doc from org. Return the text of all nodes from
| |
| toTokenString | back to summary |
|---|---|
| public String toTokenString(int start, int stop) Debugging | |
| toTokenTypeString | back to summary |
|---|---|
| public String toTokenTypeString() Used for testing, just return the token type stream | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Object | |
| public void | remove()
Overrides default java. |
| i | back to summary |
|---|---|
| pack-priv int i | |
| StreamIterator | back to summary |
|---|---|
| protected StreamIterator() | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public Object next() Implements java. Doc from java. Returns the next element in the iteration. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |