Source Code Cross Referenced for RAWSyntaxTree.java in  » IDE » tIDE » javaparser » 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 » IDE » tIDE » javaparser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package javaparser;
002:
003:        import java.io.*;
004:        import javaparser.javacc_gen.*;
005:
006:        import java.util.*;
007:        import javax.swing.tree.*;
008:
009:        /** This builds the complete syntax tree as the tokens come from the trace methods of the parser.
010:         */
011:        public class RAWSyntaxTree implements  ParserOutputProcessor {
012:            private RAWParserTreeNode actual; // root at the beginning
013:
014:            public RAWParserTreeNode root;
015:
016:            public final String javaName;
017:
018:            public RAWSyntaxTree(String javaName) {
019:                actual = new RAWParserTreeNode("");
020:                this .javaName = javaName;
021:                root = actual;
022:            }
023:
024:            int level = 0;
025:
026:            public void addNode(String name) {
027:                level++;
028:                RAWParserTreeNode n = RAWParserTreeNodeFactory.getInstance()
029:                        .create(name);
030:                actual.add(n);
031:                actual = n;
032:            }
033:
034:            /**
035:             *  Called by the parser when it returns from a previously
036:             *  encountered node (for which it has called addNode)
037:             */
038:            public void returnFromNode(String name) {
039:                level--;
040:                //System.out.println("return from "+name);
041:                actual = actual.parent;
042:            }
043:
044:            /**
045:             *  Called by the parser when it has encountered a token
046:             *  at the current treeposition, which is defined by all
047:             *  already received calls of addNode() and returnFromNode().
048:             */
049:            public void addLeaf(final Token t) {
050:                if (t.kind == JavaParserConstants.EOF)
051:                    return;
052:
053:                RAWParserTreeNode nn = RAWParserTreeNodeFactory.getInstance()
054:                        .create(t);
055:                actual.add(nn);
056:
057:                //System.out.println("add leaf "+t+" ("+t.kind+")");
058:            }
059:
060:            public void terminateRecurse() {
061:                RAWParserTreeNodeFactory.terminateRecurse(root);
062:            }
063:
064:            public static void main(String[] arguments) throws Exception {
065:                //testOldRAWTree();
066:
067:                testNewRAWTree();
068:            }
069:
070:            /** two times quicker using RAWTreeNode as MutableTN...
071:            OLd tree: 483  171  156  187  171
072:
073:            New tree:
074:
075:            With recycling:  109  78  62  62  63  62  78  62  156  62
076:            RAWParserTreeNodeFactory: 57709 free, 519291 reused.
077:
078:            Without  	     109  124  94  124  78  125  77  125  78  125
079:            Directcreat		  109  109  78  124  78  125  78  124  78  125
080:
081:             */
082:            public static void testNewRAWTree() throws Exception {
083:                System.out.println("NEW Tree");
084:                for (int i = 0; i < 10; i++) {
085:                    FileReader sr = new FileReader(
086:                            new File(
087:                                    "C:/sources/other/Script/src/tide/editor/maineditorframe.java"));
088:                    JavaParser pa = new JavaParser(sr);
089:                    pa.disable_tracing();
090:
091:                    long t0 = System.currentTimeMillis();
092:                    RAWSyntaxTree st = new RAWSyntaxTree("??javaName??");
093:                    pa.parserOutputProcessor = st;
094:                    pa.CompilationUnit();
095:                    System.out.print(" " + (System.currentTimeMillis() - t0)
096:                            + " ");
097:
098:                    st.terminateRecurse();
099:                }
100:
101:                System.out.println("\n"
102:                        + RAWParserTreeNodeFactory.getInstance());
103:            }
104:            /*
105:             public static void testOldRAWTree() throws Exception
106:             {
107:             System.out.println("OLD Tree");
108:             for(int i=0; i<5; i++)
109:             {
110:             FileReader sr = new FileReader(new File("C:/sources/other/Script/src/tide/editor/maineditorframe.java"));
111:             JavaParser pa = new JavaParser(sr);
112:             pa.disable_tracing();
113:
114:             long t0 = System.currentTimeMillis();
115:             SyntaxTree st = new SyntaxTree("??javaName??");
116:             pa.parserOutputProcessor = st;
117:             pa.CompilationUnit();
118:             System.out.print(" "+(System.currentTimeMillis()-t0)+" ");
119:             }
120:             System.out.println();
121:             }*/
122:
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.