org.antlr.runtime.tree.CommonTreeNodeStream Class Reference

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

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 CommonTreeNodeStream (Object tree)
 CommonTreeNodeStream (TreeAdaptor adaptor, Object tree)
void reset ()
Object nextElement ()
boolean isEOF (Object o)
void setUniqueNavigationNodes (boolean uniqueNavigationNodes)
Object getTreeSource ()
String getSourceName ()
TokenStream getTokenStream ()
void setTokenStream (TokenStream tokens)
TreeAdaptor getTreeAdaptor ()
void setTreeAdaptor (TreeAdaptor adaptor)
Object get (int i)
int LA (int i)
void push (int index)
int pop ()
void replaceChildren (Object parent, int startChildIndex, int stopChildIndex, Object t)
String toString (Object start, Object stop)
String toTokenTypeString ()

Static Public Attributes

static final int DEFAULT_INITIAL_BUFFER_SIZE = 100
static final int INITIAL_CALL_STACK_SIZE = 10

Protected Attributes

Object root
TokenStream tokens
TreeIterator it
IntArray calls
boolean hasNilRoot = false
int level = 0

Package Attributes

TreeAdaptor adaptor


Detailed Description

Definition at line 37 of file CommonTreeNodeStream.java.


Constructor & Destructor Documentation

org.antlr.runtime.tree.CommonTreeNodeStream.CommonTreeNodeStream ( Object  tree  ) 

Definition at line 62 of file CommonTreeNodeStream.java.

org.antlr.runtime.tree.CommonTreeNodeStream.CommonTreeNodeStream ( TreeAdaptor  adaptor,
Object  tree 
)

Definition at line 66 of file CommonTreeNodeStream.java.


Member Function Documentation

void org.antlr.runtime.tree.CommonTreeNodeStream.reset (  ) 

Reset the tree node stream in such a way that it acts like a freshly constructed stream.

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 72 of file CommonTreeNodeStream.java.

Object org.antlr.runtime.tree.CommonTreeNodeStream.nextElement (  ) 

Pull elements from tree iterator. Track tree level 0..max_level. If nil rooted tree, don't give initial nil and DOWN nor final UP.

Definition at line 83 of file CommonTreeNodeStream.java.

boolean org.antlr.runtime.tree.CommonTreeNodeStream.isEOF ( Object  o  ) 

Definition at line 100 of file CommonTreeNodeStream.java.

void org.antlr.runtime.tree.CommonTreeNodeStream.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;

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 102 of file CommonTreeNodeStream.java.

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

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

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 104 of file CommonTreeNodeStream.java.

String org.antlr.runtime.tree.CommonTreeNodeStream.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.

Implements org.antlr.runtime.IntStream.

Definition at line 106 of file CommonTreeNodeStream.java.

TokenStream org.antlr.runtime.tree.CommonTreeNodeStream.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.

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 108 of file CommonTreeNodeStream.java.

void org.antlr.runtime.tree.CommonTreeNodeStream.setTokenStream ( TokenStream  tokens  ) 

Definition at line 110 of file CommonTreeNodeStream.java.

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

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

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 112 of file CommonTreeNodeStream.java.

void org.antlr.runtime.tree.CommonTreeNodeStream.setTreeAdaptor ( TreeAdaptor  adaptor  ) 

Definition at line 114 of file CommonTreeNodeStream.java.

Object org.antlr.runtime.tree.CommonTreeNodeStream.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.

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 116 of file CommonTreeNodeStream.java.

int org.antlr.runtime.tree.CommonTreeNodeStream.LA ( int  i  ) 

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.

Implements org.antlr.runtime.IntStream.

Definition at line 120 of file CommonTreeNodeStream.java.

void org.antlr.runtime.tree.CommonTreeNodeStream.push ( int  index  ) 

Make stream jump to a new location, saving old location. Switch back with pop().

Definition at line 125 of file CommonTreeNodeStream.java.

int org.antlr.runtime.tree.CommonTreeNodeStream.pop (  ) 

Seek back to previous index saved during last push() call. Return top of stack (return index).

Definition at line 136 of file CommonTreeNodeStream.java.

void org.antlr.runtime.tree.CommonTreeNodeStream.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.

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 144 of file CommonTreeNodeStream.java.

String org.antlr.runtime.tree.CommonTreeNodeStream.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.

Implements org.antlr.runtime.tree.TreeNodeStream.

Definition at line 150 of file CommonTreeNodeStream.java.

String org.antlr.runtime.tree.CommonTreeNodeStream.toTokenTypeString (  ) 

For debugging; destructive: moves tree iterator to end.

Definition at line 157 of file CommonTreeNodeStream.java.


Member Data Documentation

Definition at line 38 of file CommonTreeNodeStream.java.

Definition at line 39 of file CommonTreeNodeStream.java.

Pull nodes from which tree?

Definition at line 42 of file CommonTreeNodeStream.java.

If this tree (root) was created from a token stream, track it.

Definition at line 45 of file CommonTreeNodeStream.java.

What tree adaptor was used to build these trees

Definition at line 48 of file CommonTreeNodeStream.java.

The tree iterator we using

Definition at line 51 of file CommonTreeNodeStream.java.

Stack of indexes used for push/pop calls

Definition at line 54 of file CommonTreeNodeStream.java.

Tree (nil A B C) trees like flat A B C streams

Definition at line 57 of file CommonTreeNodeStream.java.

Tracks tree depth. Level=0 means we're at root node level.

Definition at line 60 of file CommonTreeNodeStream.java.


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

Generated on Tue Jul 19 11:42:10 2011 for ANTLR API by  doxygen 1.5.5