org.antlr.runtime.tree.TreeNodeStream Interface Reference

Inheritance diagram for org.antlr.runtime.tree.TreeNodeStream:

Inheritance graph
[legend]
Collaboration diagram for org.antlr.runtime.tree.TreeNodeStream:

Collaboration graph
[legend]

List of all members.

Public Member Functions

Object get (int i)
Object LT (int k)
Object getTreeSource ()
TokenStream getTokenStream ()
TreeAdaptor getTreeAdaptor ()
void setUniqueNavigationNodes (boolean uniqueNavigationNodes)
String toString (Object start, Object stop)
void replaceChildren (Object parent, int startChildIndex, int stopChildIndex, Object t)


Detailed Description

A stream of tree nodes, accessing nodes from a tree of some kind

Definition at line 34 of file TreeNodeStream.java.


Member Function Documentation

Object org.antlr.runtime.tree.TreeNodeStream.get ( int  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.

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.

Object org.antlr.runtime.tree.TreeNodeStream.LT ( int  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. :)

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.

Object org.antlr.runtime.tree.TreeNodeStream.getTreeSource (  ) 

Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.

TokenStream org.antlr.runtime.tree.TreeNodeStream.getTokenStream (  ) 

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.

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.

TreeAdaptor org.antlr.runtime.tree.TreeNodeStream.getTreeAdaptor (  ) 

What adaptor can tell me how to interpret/navigate nodes and trees. E.g., get text of a node.

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.

void org.antlr.runtime.tree.TreeNodeStream.setUniqueNavigationNodes ( boolean  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;

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.

String org.antlr.runtime.tree.TreeNodeStream.toString ( Object  start,
Object  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.

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.

void org.antlr.runtime.tree.TreeNodeStream.replaceChildren ( Object  parent,
int  startChildIndex,
int  stopChildIndex,
Object  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.

Implemented in org.antlr.runtime.debug.DebugTreeNodeStream, org.antlr.runtime.tree.CommonTreeNodeStream, and org.antlr.runtime.tree.UnBufferedTreeNodeStream.


The documentation for this interface was generated from the following file:

Generated on Wed Oct 1 14:13:48 2008 for ANTLR API by  doxygen 1.5.5