Source Code Cross Referenced for DefaultToolErrorHandler.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 persistence.antlr.collections.impl.BitSet;
010:
011:        class DefaultToolErrorHandler implements  ToolErrorHandler {
012:            DefaultToolErrorHandler(persistence.antlr.Tool tool) {
013:                antlrTool = tool;
014:            }
015:
016:            private final persistence.antlr.Tool antlrTool;
017:
018:            CharFormatter javaCharFormatter = new JavaCharFormatter();
019:
020:            /** Dump token/character sets to a string array suitable for
021:             * {@link persistence.antlr.Tool.warning(String[], String, int, int)
022:             * @param output The array that will contain the token/character set dump,
023:             *               one element per k (lookahead) value
024:             * @param outputStartIndex The index into <code>output</code> that the
025:             *                         dump should start at.
026:             * @param lexicalAnalysis  true for lexical rule
027:             * @param depth  The depth of the ambiguity
028:             * @param sets  An array of bitsets containing the ambiguities
029:             */
030:            private void dumpSets(String[] output, int outputStartIndex,
031:                    Grammar grammar, boolean lexicalAnalysis, int depth,
032:                    Lookahead[] sets) {
033:                StringBuffer line = new StringBuffer(100);
034:                for (int i = 1; i <= depth; i++) {
035:                    line.append("k==").append(i).append(':');
036:                    if (lexicalAnalysis) {
037:                        String bits = sets[i].fset.toStringWithRanges(",",
038:                                javaCharFormatter);
039:                        if (sets[i].containsEpsilon()) {
040:                            line.append("<end-of-token>");
041:                            if (bits.length() > 0) {
042:                                line.append(',');
043:                            }
044:                        }
045:                        line.append(bits);
046:                    } else {
047:                        line.append(sets[i].fset.toString(",",
048:                                grammar.tokenManager.getVocabulary()));
049:                    }
050:                    output[outputStartIndex++] = line.toString();
051:                    line.setLength(0);
052:                }
053:            }
054:
055:            /** Issue a warning about ambiguity between a alternates
056:             * @param blk  The block being analyzed
057:             * @param lexicalAnalysis  true for lexical rule
058:             * @param depth  The depth of the ambiguity
059:             * @param sets  An array of bitsets containing the ambiguities
060:             * @param altIdx1  The zero-based index of the first ambiguous alternative
061:             * @param altIdx2  The zero-based index of the second ambiguous alternative
062:             */
063:            public void warnAltAmbiguity(Grammar grammar, AlternativeBlock blk,
064:                    boolean lexicalAnalysis, int depth, Lookahead[] sets,
065:                    int altIdx1, int altIdx2) {
066:                final StringBuffer line = new StringBuffer(100);
067:                if (blk instanceof  RuleBlock
068:                        && ((RuleBlock) blk).isLexerAutoGenRule()) {
069:                    Alternative ai = blk.getAlternativeAt(altIdx1);
070:                    Alternative aj = blk.getAlternativeAt(altIdx2);
071:                    RuleRefElement rri = (RuleRefElement) ai.head;
072:                    RuleRefElement rrj = (RuleRefElement) aj.head;
073:                    String ri = CodeGenerator
074:                            .reverseLexerRuleName(rri.targetRule);
075:                    String rj = CodeGenerator
076:                            .reverseLexerRuleName(rrj.targetRule);
077:                    line.append("lexical nondeterminism between rules ");
078:                    line.append(ri).append(" and ").append(rj).append(" upon");
079:                } else {
080:                    if (lexicalAnalysis) {
081:                        line.append("lexical ");
082:                    }
083:                    line.append("nondeterminism between alts ");
084:                    line.append(altIdx1 + 1).append(" and ");
085:                    line.append(altIdx2 + 1).append(" of block upon");
086:                }
087:                final String[] output = new String[depth + 1];
088:                ;
089:                output[0] = line.toString();
090:                dumpSets(output, 1, grammar, lexicalAnalysis, depth, sets);
091:                antlrTool.warning(output, grammar.getFilename(), blk.getLine(),
092:                        blk.getColumn());
093:
094:            }
095:
096:            /** Issue a warning about ambiguity between an alternate and exit path.
097:             * @param blk  The block being analyzed
098:             * @param lexicalAnalysis  true for lexical rule
099:             * @param depth  The depth of the ambiguity
100:             * @param sets  An array of bitsets containing the ambiguities
101:             * @param altIdx  The zero-based index of the ambiguous alternative
102:             */
103:            public void warnAltExitAmbiguity(Grammar grammar,
104:                    BlockWithImpliedExitPath blk, boolean lexicalAnalysis,
105:                    int depth, Lookahead[] sets, int altIdx) {
106:                String[] output = new String[depth + 2];
107:                output[0] = (lexicalAnalysis ? "lexical " : "")
108:                        + "nondeterminism upon";
109:                dumpSets(output, 1, grammar, lexicalAnalysis, depth, sets);
110:                output[depth + 1] = "between alt " + (altIdx + 1)
111:                        + " and exit branch of block";
112:                antlrTool.warning(output, grammar.getFilename(), blk.getLine(),
113:                        blk.getColumn());
114:            }
115:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.