Java Doc for UnBufferedTreeNodeStream.java in  » Parser » antlr-3.0.1 » org » antlr » runtime » tree » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Parser » antlr 3.0.1 » org.antlr.runtime.tree 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.antlr.runtime.tree.UnBufferedTreeNodeStream

UnBufferedTreeNodeStream
public class UnBufferedTreeNodeStream implements TreeNodeStream(Code)
A stream of tree nodes, accessing nodes from a tree of ANY kind. No new nodes should be created in tree during the walk. A small buffer of tokens is kept to efficiently and easily handle LT(i) calls, though the lookahead mechanism is fairly complicated. For tree rewriting during tree parsing, this must also be able to replace a set of children without "losing its place". That part is not yet implemented. Will permit a rule to return a different tree and have it stitched into the output tree probably.
See Also:   CommonTreeNodeStream

Inner Class :protected class TreeWalkState

Field Summary
final public static  intINITIAL_LOOKAHEAD_BUFFER_SIZE
    
protected  intabsoluteNodeIndex
     What node index did we just consume? i=0..n-1 for n node trees. IntStream.next is hence 1 + this value.
 TreeAdaptoradaptor
    
protected  intcurrentChildIndex
     Which child are we currently visiting? If -1 we have not visited this node yet; next consume() request will set currentIndex to 0.
protected  ObjectcurrentNode
    
protected  Objectdown
    
protected  Objecteof
    
protected  inthead
     lookahead[head] is the first symbol of lookahead, LT(1).
protected  StackindexStack
     Track which child index you are visiting for each node we push.
protected  intlastMarker
     Track the last mark() call result value for use in rewind().
protected  Object[]lookahead
     Buffer tree node stream for use with LT(i).
protected  intmarkDepth
    
protected  Listmarkers
     Calls to mark() may be nested so we have to track a stack of them.
protected  StacknodeStack
     As we walk down the nodes, we must track parent nodes so we know where to go after walking the last child of a node.
protected  ObjectpreviousNode
     Which node did we visit last? Used for LT(-1) calls.
protected  Objectroot
    
protected  inttail
     Add new lookahead at lookahead[tail].
protected  TokenStreamtokens
     IF this tree (root) was created from a token stream, track it.
protected  booleanuniqueNavigationNodes
    
protected  Objectup
    

Constructor Summary
public  UnBufferedTreeNodeStream(Object tree)
    
public  UnBufferedTreeNodeStream(TreeAdaptor adaptor, Object tree)
    

Method Summary
public  intLA(int i)
    
public  ObjectLT(int k)
     Get tree node at current input pointer + i ahead where i=1 is next node. i<0 indicates nodes in the past.
protected  voidaddLookahead(Object node)
     Add a node to the lookahead buffer.
protected  voidaddNavigationNode(int ttype)
     As we flatten the tree, we use UP, DOWN nodes to represent the tree structure.
public  voidconsume()
    
protected  voidfill(int k)
    
public  Objectget(int i)
    
protected  intgetLookaheadSize()
    
public  TokenStreamgetTokenStream()
    
public  TreeAdaptorgetTreeAdaptor()
    
public  ObjectgetTreeSource()
     Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.
protected  ObjecthandleRootNode()
    
public  booleanhasUniqueNavigationNodes()
    
public  intindex()
    
public  intmark()
     Record the current state of the tree walk which includes the current node and stack state as well as the lookahead buffer.
public  Objectnext()
     Return the next node found during a depth-first walk of root. Also, add these nodes and DOWN/UP imaginary nodes into the lokoahead buffer as a side-effect.
public  voidrelease(int marker)
    
public  voidreset()
    
public  voidrewind(int marker)
     Rewind the current state of the tree walk to the state it was in when mark() was called and it returned marker.
public  voidrewind()
    
public  voidseek(int index)
     consume() ahead until we hit index.
public  voidsetTokenStream(TokenStream tokens)
    
public  voidsetUniqueNavigationNodes(boolean uniqueNavigationNodes)
    
public  intsize()
     Expensive to compute; recursively walk tree to find size; include navigation nodes and EOF.
public  StringtoString()
     Print out the entire tree including DOWN/UP nodes.
public  StringtoString(Object start, Object stop)
    
protected  voidtoStringWork(Object p, Object stop, StringBuffer buf)
    
protected  ObjectvisitChild(int child)
    
protected  voidwalkBackToMostRecentNodeWithUnvisitedChildren()
     Walk upwards looking for a node with more children to walk.

Field Detail
INITIAL_LOOKAHEAD_BUFFER_SIZE
final public static int INITIAL_LOOKAHEAD_BUFFER_SIZE(Code)



absoluteNodeIndex
protected int absoluteNodeIndex(Code)
What node index did we just consume? i=0..n-1 for n node trees. IntStream.next is hence 1 + this value. Size will be same.



adaptor
TreeAdaptor adaptor(Code)
What tree adaptor was used to build these trees



currentChildIndex
protected int currentChildIndex(Code)
Which child are we currently visiting? If -1 we have not visited this node yet; next consume() request will set currentIndex to 0.



currentNode
protected Object currentNode(Code)
Which node are we currently visiting?



down
protected Object down(Code)



eof
protected Object eof(Code)



head
protected int head(Code)
lookahead[head] is the first symbol of lookahead, LT(1).



indexStack
protected Stack indexStack(Code)
Track which child index you are visiting for each node we push. TODO: pretty inefficient...use int[] when you have time



lastMarker
protected int lastMarker(Code)
Track the last mark() call result value for use in rewind().



lookahead
protected Object[] lookahead(Code)
Buffer tree node stream for use with LT(i). This list grows to fit new lookahead depths, but consume() wraps like a circular buffer.



markDepth
protected int markDepth(Code)
tracks how deep mark() calls are nested



markers
protected List markers(Code)
Calls to mark() may be nested so we have to track a stack of them. The marker is an index into this stack. This is a List. Indexed from 1..markDepth. A null is kept @ index 0. Create upon first call to mark().



nodeStack
protected Stack nodeStack(Code)
As we walk down the nodes, we must track parent nodes so we know where to go after walking the last child of a node. When visiting a child, push current node and current index.



previousNode
protected Object previousNode(Code)
Which node did we visit last? Used for LT(-1) calls.



root
protected Object root(Code)
Pull nodes from which tree?



tail
protected int tail(Code)
Add new lookahead at lookahead[tail]. tail wraps around at the end of the lookahead buffer so tail could be less than head.



tokens
protected TokenStream tokens(Code)
IF this tree (root) was created from a token stream, track it.



uniqueNavigationNodes
protected boolean uniqueNavigationNodes(Code)
Reuse same DOWN, UP navigation nodes unless this is true



up
protected Object up(Code)




Constructor Detail
UnBufferedTreeNodeStream
public UnBufferedTreeNodeStream(Object tree)(Code)



UnBufferedTreeNodeStream
public UnBufferedTreeNodeStream(TreeAdaptor adaptor, Object tree)(Code)




Method Detail
LA
public int LA(int i)(Code)



LT
public Object LT(int k)(Code)
Get tree node at current input pointer + i ahead where i=1 is next node. i<0 indicates nodes in the past. So -1 is previous node and -2 is two nodes ago. 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. :)



addLookahead
protected void addLookahead(Object node)(Code)
Add a node to the lookahead buffer. Add at lookahead[tail]. If you tail+1 == head, then we must create a bigger buffer and copy all the nodes over plus reset head, tail. After this method, LT(1) will be lookahead[0].



addNavigationNode
protected void addNavigationNode(int ttype)(Code)
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
public void consume()(Code)



fill
protected void fill(int k)(Code)
Make sure we have at least k symbols in lookahead buffer



get
public Object get(int i)(Code)



getLookaheadSize
protected int getLookaheadSize()(Code)



getTokenStream
public TokenStream getTokenStream()(Code)



getTreeAdaptor
public TreeAdaptor getTreeAdaptor()(Code)



getTreeSource
public Object getTreeSource()(Code)
Where is this stream pulling nodes from? This is not the name, but the object that provides node objects.



handleRootNode
protected Object handleRootNode()(Code)



hasUniqueNavigationNodes
public boolean hasUniqueNavigationNodes()(Code)



index
public int index()(Code)



mark
public int mark()(Code)
Record the current state of the tree walk which includes the current node and stack state as well as the lookahead buffer.



next
public Object next()(Code)
Return the next node found during a depth-first walk of root. Also, add these nodes and DOWN/UP imaginary nodes into the lokoahead buffer as a side-effect. Normally side-effects are bad, but because we can emit many tokens for every next() call, it's pretty hard to use a single return value for that. We must add these tokens to the lookahead buffer. This does *not* return the DOWN/UP nodes; those are only returned by the LT() method. Ugh. This mechanism is much more complicated than a recursive solution, but it's the only way to provide nodes on-demand instead of walking once completely through and buffering up the nodes. :(



release
public void release(int marker)(Code)



reset
public void reset()(Code)



rewind
public void rewind(int marker)(Code)
Rewind the current state of the tree walk to the state it was in when mark() was called and it returned marker. Also, wipe out the lookahead which will force reloading a few nodes but it is better than making a copy of the lookahead buffer upon mark().



rewind
public void rewind()(Code)



seek
public void seek(int index)(Code)
consume() ahead until we hit index. Can't just jump ahead--must spit out the navigation nodes.



setTokenStream
public void setTokenStream(TokenStream tokens)(Code)



setUniqueNavigationNodes
public void setUniqueNavigationNodes(boolean uniqueNavigationNodes)(Code)



size
public int size()(Code)
Expensive to compute; recursively walk tree to find size; include navigation nodes and EOF. Reuse functionality in CommonTreeNodeStream as we only really use this for testing.



toString
public String toString()(Code)
Print out the entire tree including DOWN/UP nodes. Uses a recursive walk. Mostly useful for testing as it yields the token types not text.



toString
public String toString(Object start, Object stop)(Code)



toStringWork
protected void toStringWork(Object p, Object stop, StringBuffer buf)(Code)



visitChild
protected Object visitChild(int child)(Code)



walkBackToMostRecentNodeWithUnvisitedChildren
protected void walkBackToMostRecentNodeWithUnvisitedChildren()(Code)
Walk upwards looking for a node with more children to walk.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.