Source Code Cross Referenced for DefaultToolErrorHandler.java in  » IDE-Netbeans » cnd » 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 » IDE Netbeans » cnd » antlr 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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