Java Doc for CommonTreeNodeStream.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.CommonTreeNodeStream

CommonTreeNodeStream
public class CommonTreeNodeStream implements TreeNodeStream(Code)
A buffered stream of tree nodes. 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...
See Also:   UnBufferedTreeNodeStream

Inner Class :protected class StreamIterator implements Iterator

Field Summary
final public static  intDEFAULT_INITIAL_BUFFER_SIZE
    
final public static  SetINDEX_ALL
     If tokenTypesToReverseIndex set to INDEX_ALL then indexing occurs for all token types.
final public static  intINITIAL_CALL_STACK_SIZE
    
protected  int_sp
     Stack pointer for stack of indexes; -1 indicates empty.
 TreeAdaptoradaptor
    
protected  int[]calls
    
protected  Objectdown
    
protected  Objecteof
    
protected  intlastMarker
     Track the last mark() call result value for use in rewind().
protected  Listnodes
     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.
protected  intp
     The index into the nodes list of the current node (next node to consume).
protected  Objectroot
    
protected  MaptokenTypeToStreamIndexesMap
     During fillBuffer(), we can make a reverse index from a set of token types of interest to the list of indexes into the node stream.
protected  SettokenTypesToReverseIndex
     A set of token types user would like to index for faster lookup. If this is INDEX_ALL, then all token types are tracked.
protected  TokenStreamtokens
     IF this tree (root) was created from a token stream, track it.
protected  booleanuniqueNavigationNodes
    
protected  Objectup
    

Constructor Summary
public  CommonTreeNodeStream(Object tree)
    
public  CommonTreeNodeStream(TreeAdaptor adaptor, Object tree)
    
public  CommonTreeNodeStream(TreeAdaptor adaptor, Object tree, int initialBufferSize)
    

Method Summary
public  intLA(int i)
    
protected  ObjectLB(int k)
    
public  ObjectLT(int k)
    
protected  voidaddNavigationNode(int ttype)
     As we flatten the tree, we use UP, DOWN nodes to represent the tree structure.
public  voidconsume()
    
protected  voidfillBuffer()
     Walk tree with depth-first-search and fill nodes buffer.
protected  voidfillBuffer(Object t)
    
protected  voidfillReverseIndex(Object node, int streamIndex)
     Given a node, add this to the reverse index tokenTypeToStreamIndexesMap. You can override this method to alter how indexing occurs.
public  Objectget(int i)
    
public  intgetNodeIndex(Object node)
     Given a node pointer, return its index into the node stream. This is not its Token stream index.
protected  intgetNodeIndexLinearly(Object node)
    
public  TokenStreamgetTokenStream()
    
public  TreeAdaptorgetTreeAdaptor()
    
public  ObjectgetTreeSource()
    
public  booleanhasUniqueNavigationNodes()
    
public  intindex()
    
public  Iteratoriterator()
    
public  intmark()
    
public  intpop()
     Seek back to previous index saved during last push() call.
public  voidpush(int index)
     Make stream jump to a new location, saving old location. Switch back with pop().
public  voidrelease(int marker)
    
public  voidreverseIndex(int tokenType)
     Track the indicated token type in the reverse index.
public  voidreverseIndex(Set tokenTypes)
     Track the indicated token types in the reverse index.
public  voidrewind(int marker)
    
public  voidrewind()
    
public  voidseek(int index)
    
public  voidsetTokenStream(TokenStream tokens)
    
public  voidsetUniqueNavigationNodes(boolean uniqueNavigationNodes)
    
public  intsize()
    
public  StringtoString()
    
public  StringtoString(Object start, Object stop)
    

Field Detail
DEFAULT_INITIAL_BUFFER_SIZE
final public static int DEFAULT_INITIAL_BUFFER_SIZE(Code)



INDEX_ALL
final public static Set INDEX_ALL(Code)
If tokenTypesToReverseIndex set to INDEX_ALL then indexing occurs for all token types.



INITIAL_CALL_STACK_SIZE
final public static int INITIAL_CALL_STACK_SIZE(Code)



_sp
protected int _sp(Code)
Stack pointer for stack of indexes; -1 indicates empty. Points at next location to push a value.



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



calls
protected int[] calls(Code)
Stack of indexes used for push/pop calls



down
protected Object down(Code)



eof
protected Object eof(Code)



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



nodes
protected List nodes(Code)
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
protected int p(Code)
The index into the nodes list of the current node (next node to consume). If -1, nodes array not filled yet.



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



tokenTypeToStreamIndexesMap
protected Map tokenTypeToStreamIndexesMap(Code)
During fillBuffer(), we can make a reverse index from a set of token types of interest to the list of indexes into the node stream. This lets us convert a node pointer to a stream index semi-efficiently for a list of interesting nodes such as function definition nodes (you'll want to seek to their bodies for an interpreter). Also useful for doing dynamic searches; i.e., go find me all PLUS nodes.



tokenTypesToReverseIndex
protected Set tokenTypesToReverseIndex(Code)
A set of token types user would like to index for faster lookup. If this is INDEX_ALL, then all token types are tracked. If null, then none are indexed.



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
CommonTreeNodeStream
public CommonTreeNodeStream(Object tree)(Code)



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



CommonTreeNodeStream
public CommonTreeNodeStream(TreeAdaptor adaptor, Object tree, int initialBufferSize)(Code)




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



LB
protected Object LB(int k)(Code)
Look backwards k nodes



LT
public Object LT(int k)(Code)



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)



fillBuffer
protected void fillBuffer()(Code)
Walk tree with depth-first-search and fill nodes buffer. Don't do DOWN, UP nodes if its a list (t is isNil).



fillBuffer
protected void fillBuffer(Object t)(Code)



fillReverseIndex
protected void fillReverseIndex(Object node, int streamIndex)(Code)
Given a node, add this to the reverse index tokenTypeToStreamIndexesMap. You can override this method to alter how indexing occurs. The default is to create a Map> This data structure allows you to find all nodes with type INT in order. If you really need to find a node of type, say, FUNC quickly then perhaps Map> would be better for you. The interior maps map a tree node to the index so you don't have to search linearly for a specific node. If you change this method, you will likely need to change getNodeIndex(), which extracts information.



get
public Object get(int i)(Code)



getNodeIndex
public int getNodeIndex(Object node)(Code)
Given a node pointer, return its index into the node stream. This is not its Token stream index. If there is no reverse map from node to stream index or the map does not contain entries for node's token type, a linear search of entire stream is used. Return -1 if exact node pointer not in stream.



getNodeIndexLinearly
protected int getNodeIndexLinearly(Object node)(Code)



getTokenStream
public TokenStream getTokenStream()(Code)



getTreeAdaptor
public TreeAdaptor getTreeAdaptor()(Code)



getTreeSource
public Object getTreeSource()(Code)



hasUniqueNavigationNodes
public boolean hasUniqueNavigationNodes()(Code)



index
public int index()(Code)



iterator
public Iterator iterator()(Code)



mark
public int mark()(Code)



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



push
public void push(int index)(Code)
Make stream jump to a new location, saving old location. Switch back with pop(). I manage dyanmic array manually to avoid creating Integer objects all over the place.



release
public void release(int marker)(Code)



reverseIndex
public void reverseIndex(int tokenType)(Code)
Track the indicated token type in the reverse index. Call this repeatedly for each type or use variant with Set argument to set all at once.
Parameters:
  tokenType -



reverseIndex
public void reverseIndex(Set tokenTypes)(Code)
Track the indicated token types in the reverse index. Set to INDEX_ALL to track all token types.



rewind
public void rewind(int marker)(Code)



rewind
public void rewind()(Code)



seek
public void seek(int index)(Code)



setTokenStream
public void setTokenStream(TokenStream tokens)(Code)



setUniqueNavigationNodes
public void setUniqueNavigationNodes(boolean uniqueNavigationNodes)(Code)



size
public int size()(Code)



toString
public String toString()(Code)
Used for testing, just return the token type stream



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



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.