Source Code Cross Referenced for TreeParser.java in  » Database-ORM » toplink » persistence » antlr » 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 » Database ORM » toplink » persistence.antlr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package persistence.antlr;
002:
003:        /* ANTLR Translator Generator
004:         * Project led by Terence Parr at http://www.jGuru.com
005:         * Software rights: http://www.antlr.org/license.html
006:         *
007:         */
008:
009:        import java.util.NoSuchElementException;
010:
011:        import persistence.antlr.collections.AST;
012:        import persistence.antlr.collections.impl.BitSet;
013:
014:        public class TreeParser {
015:            /** The AST Null object; the parsing cursor is set to this when
016:             *  it is found to be null.  This way, we can test the
017:             *  token type of a node without having to have tests for null
018:             *  everywhere.
019:             */
020:            public static ASTNULLType ASTNULL = new ASTNULLType();
021:
022:            /** Where did this rule leave off parsing; avoids a return parameter */
023:            protected AST _retTree;
024:
025:            /** guessing nesting level; guessing==0 implies not guessing */
026:            // protected int guessing = 0;
027:            /** Nesting level of registered handlers */
028:            // protected int exceptionLevel = 0;
029:            protected TreeParserSharedInputState inputState;
030:
031:            /** Table of token type to token names */
032:            protected String[] tokenNames;
033:
034:            /** AST return value for a rule is squirreled away here */
035:            protected AST returnAST;
036:
037:            /** AST support code; parser and treeparser delegate to this object */
038:            protected ASTFactory astFactory = new ASTFactory();
039:
040:            /** Used to keep track of indentdepth for traceIn/Out */
041:            protected int traceDepth = 0;
042:
043:            public TreeParser() {
044:                inputState = new TreeParserSharedInputState();
045:            }
046:
047:            /** Get the AST return value squirreled away in the parser */
048:            public AST getAST() {
049:                return returnAST;
050:            }
051:
052:            public ASTFactory getASTFactory() {
053:                return astFactory;
054:            }
055:
056:            public String getTokenName(int num) {
057:                return tokenNames[num];
058:            }
059:
060:            public String[] getTokenNames() {
061:                return tokenNames;
062:            }
063:
064:            protected void match(AST t, int ttype)
065:                    throws MismatchedTokenException {
066:                //System.out.println("match("+ttype+"); cursor is "+t);
067:                if (t == null || t == ASTNULL || t.getType() != ttype) {
068:                    throw new MismatchedTokenException(getTokenNames(), t,
069:                            ttype, false);
070:                }
071:            }
072:
073:            /**Make sure current lookahead symbol matches the given set
074:             * Throw an exception upon mismatch, which is catch by either the
075:             * error handler or by the syntactic predicate.
076:             */
077:            public void match(AST t, BitSet b) throws MismatchedTokenException {
078:                if (t == null || t == ASTNULL || !b.member(t.getType())) {
079:                    throw new MismatchedTokenException(getTokenNames(), t, b,
080:                            false);
081:                }
082:            }
083:
084:            protected void matchNot(AST t, int ttype)
085:                    throws MismatchedTokenException {
086:                //System.out.println("match("+ttype+"); cursor is "+t);
087:                if (t == null || t == ASTNULL || t.getType() == ttype) {
088:                    throw new MismatchedTokenException(getTokenNames(), t,
089:                            ttype, true);
090:                }
091:            }
092:
093:            /** @deprecated as of 2.7.2. This method calls System.exit() and writes
094:             *  directly to stderr, which is usually not appropriate when
095:             *  a parser is embedded into a larger application. Since the method is 
096:             *  <code>static</code>, it cannot be overridden to avoid these problems.
097:             *  ANTLR no longer uses this method internally or in generated code.
098:             */
099:            public static void panic() {
100:                System.err.println("TreeWalker: panic");
101:                System.exit(1);
102:            }
103:
104:            /** Parser error-reporting function can be overridden in subclass */
105:            public void reportError(RecognitionException ex) {
106:                System.err.println(ex.toString());
107:            }
108:
109:            /** Parser error-reporting function can be overridden in subclass */
110:            public void reportError(String s) {
111:                System.err.println("error: " + s);
112:            }
113:
114:            /** Parser warning-reporting function can be overridden in subclass */
115:            public void reportWarning(String s) {
116:                System.err.println("warning: " + s);
117:            }
118:
119:            /** Specify an object with support code (shared by
120:             *  Parser and TreeParser.  Normally, the programmer
121:             *  does not play with this, using setASTNodeType instead.
122:             */
123:            public void setASTFactory(ASTFactory f) {
124:                astFactory = f;
125:            }
126:
127:            /** Specify the type of node to create during tree building.
128:             * 	@deprecated since 2.7.2
129:             */
130:            public void setASTNodeType(String nodeType) {
131:                setASTNodeClass(nodeType);
132:            }
133:
134:            /** Specify the type of node to create during tree building */
135:            public void setASTNodeClass(String nodeType) {
136:                astFactory.setASTNodeType(nodeType);
137:            }
138:
139:            public void traceIndent() {
140:                for (int i = 0; i < traceDepth; i++)
141:                    System.out.print(" ");
142:            }
143:
144:            public void traceIn(String rname, AST t) {
145:                traceDepth += 1;
146:                traceIndent();
147:                System.out.println("> " + rname + "("
148:                        + (t != null ? t.toString() : "null") + ")"
149:                        + ((inputState.guessing > 0) ? " [guessing]" : ""));
150:            }
151:
152:            public void traceOut(String rname, AST t) {
153:                traceIndent();
154:                System.out.println("< " + rname + "("
155:                        + (t != null ? t.toString() : "null") + ")"
156:                        + ((inputState.guessing > 0) ? " [guessing]" : ""));
157:                traceDepth--;
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.