Public Member Functions | |
def | __init__ |
def | fillBuffer |
Walk tree with depth-first-search and fill nodes buffer. | |
def | getNodeIndex |
What is the stream index for node? 0. | |
def | addNavigationNode |
As we flatten the tree, we use UP, DOWN nodes to represent the tree structure. | |
def | get |
Get a tree node at an absolute index i; 0. | |
def | LT |
Get tree node at current input pointer + i ahead where i=1 is next node. | |
def | getCurrentSymbol |
def | LB |
Look backwards k nodes. | |
def | getTreeSource |
Where is this stream pulling nodes from? This is not the name, but the object that provides node objects. | |
def | getSourceName |
def | getTokenStream |
If the tree associated with this stream was created from a TokenStream, you can specify it here. | |
def | setTokenStream |
def | getTreeAdaptor |
What adaptor can tell me how to interpret/navigate nodes and trees. | |
def | hasUniqueNavigationNodes |
def | setUniqueNavigationNodes |
As we flatten the tree, we use UP, DOWN nodes to represent the tree structure. | |
def | consume |
def | LA |
def | mark |
def | release |
def | index |
def | rewind |
def | seek |
def | push |
Make stream jump to a new location, saving old location. | |
def | pop |
Seek back to previous index saved during last push() call. | |
def | reset |
def | size |
def | replaceChildren |
Replace from start to stop child index of parent with t, which might be a list. | |
def | __str__ |
Used for testing, just return the token type stream. | |
def | toString |
Return the text of all nodes from start to stop, inclusive. | |
def | __iter__ |
iterator interface | |
Public Attributes | |
down | |
up | |
eof | |
nodes | |
root | |
adaptor | |
uniqueNavigationNodes | |
p | |
lastMarker | |
calls | |
Private Member Functions | |
def | _fillBuffer |
Nodes can be from a tree of ANY kind.
This node stream sucks all nodes out of the tree specified in the constructor during construction and makes pointers into the tree using an array of Object pointers. The stream necessarily includes pointers to DOWN and UP and EOF nodes.
This stream knows how to mark/release for backtracking.
This stream is most suitable for tree interpreters that need to jump around a lot or for tree parsers requiring speed (at cost of memory). There is some duplicated functionality here with UnBufferedTreeNodeStream but just in bookkeeping, not tree walking etc...
Definition at line 1849 of file tree.py.
def antlr3.tree.CommonTreeNodeStream.__init__ | ( | self, | ||
args | ||||
) |
def antlr3.tree.CommonTreeNodeStream.fillBuffer | ( | self | ) |
def antlr3.tree.CommonTreeNodeStream._fillBuffer | ( | self, | ||
t | ||||
) | [private] |
def antlr3.tree.CommonTreeNodeStream.getNodeIndex | ( | self, | ||
node | ||||
) |
def antlr3.tree.CommonTreeNodeStream.addNavigationNode | ( | self, | ||
ttype | ||||
) |
def antlr3.tree.CommonTreeNodeStream.get | ( | self, | ||
i | ||||
) |
Get a tree node at an absolute index i; 0.
.n-1. If you don't want to buffer up nodes, then this method makes no sense for you.
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.LT | ( | self, | ||
k | ||||
) |
Get tree node at current input pointer + i ahead where i=1 is next node.
i<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 i>=n, return null. Return null for LT(0) and any index that results in an absolute address that is negative.
This is analogus to the LT() method of the TokenStream, but this returns a tree node instead of a token. Makes code gen identical for both parser and tree grammars. :)
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.getCurrentSymbol | ( | self | ) |
def antlr3.tree.CommonTreeNodeStream.LB | ( | self, | ||
k | ||||
) |
def antlr3.tree.CommonTreeNodeStream.getTreeSource | ( | self | ) |
Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.getSourceName | ( | self | ) |
def antlr3.tree.CommonTreeNodeStream.getTokenStream | ( | self | ) |
If the tree associated with this stream was created from a TokenStream, 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.
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.setTokenStream | ( | self, | ||
tokens | ||||
) |
def antlr3.tree.CommonTreeNodeStream.getTreeAdaptor | ( | self | ) |
What adaptor can tell me how to interpret/navigate nodes and trees.
E.g., get text of a node.
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.hasUniqueNavigationNodes | ( | self | ) |
def antlr3.tree.CommonTreeNodeStream.setUniqueNavigationNodes | ( | self, | ||
uniqueNavigationNodes | ||||
) |
As we flatten the tree, we use UP, 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 be false;
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.release | ( | self, | ||
marker = None | ||||
) |
def antlr3.tree.CommonTreeNodeStream.rewind | ( | self, | ||
marker = None | ||||
) |
def antlr3.tree.CommonTreeNodeStream.push | ( | self, | ||
index | ||||
) |
def antlr3.tree.CommonTreeNodeStream.pop | ( | self | ) |
def antlr3.tree.CommonTreeNodeStream.replaceChildren | ( | self, | ||
parent, | ||||
startChildIndex, | ||||
stopChildIndex, | ||||
t | ||||
) |
Replace from start to stop child index of parent 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.
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.__str__ | ( | self | ) |
def antlr3.tree.CommonTreeNodeStream.toString | ( | self, | ||
start, | ||||
stop | ||||
) |
Return the text of all nodes from start 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.
Reimplemented from antlr3.tree.TreeNodeStream.
def antlr3.tree.CommonTreeNodeStream.__iter__ | ( | self | ) |