Clover coverage report - PMD - 3.7
Coverage timestamp: Wed May 31 2006 09:25:59 EDT

file stats: | LOC: | 131 |  | Methods: | 6
| NCLOC: | 70 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL

TokenMgrError.java

0%

0%

0%

0%

1 |  | /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
2 |  | package net.sourceforge.pmd.ast;
3 |  |
4 |  | public class TokenMgrError extends RuntimeException {
5 |  | /*
6 |  | * Ordinals for various reasons why an Error of this type can be thrown.
7 |  | */
8 |  |
9 |  | /**
10 |  | * Lexical error occured.
11 |  | */
12 |  | static final int LEXICAL_ERROR = 0;
13 |  |
14 |  | /**
15 |  | * An attempt wass made to create a second instance of a static token manager.
16 |  | */
17 |  | static final int STATIC_LEXER_ERROR = 1;
18 |  |
19 |  | /**
20 |  | * Tried to change to an invalid lexical state.
21 |  | */
22 |  | static final int INVALID_LEXICAL_STATE = 2;
23 |  |
24 |  | /**
25 |  | * Detected (and bailed out of) an infinite loop in the token manager.
26 |  | */
27 |  | static final int LOOP_DETECTED = 3;
28 |  |
29 |  | /**
30 |  | * Indicates the reason why the exception is thrown. It will have
31 |  | * one of the above 4 values.
32 |  | */
33 |  | int errorCode;
34 |  |
35 |  | /**
36 |  | * Replaces unprintable characters by their espaced (or unicode escaped)
37 |  | * equivalents in the given string
38 |  | */
39 | 0 | protected static final String addEscapes(String str) {
40 | 0 | StringBuffer retval = new StringBuffer();
41 | 0 | char ch;
42 | 0 | for (int i = 0; i < str.length(); i++) {
43 | 0 | switch (str.charAt(i)) {
44 | 0 | case 0:
45 | 0 | continue;
46 | 0 | case '\b':
47 | 0 | retval.append("\\b");
48 | 0 | continue;
49 | 0 | case '\t':
50 | 0 | retval.append("\\t");
51 | 0 | continue;
52 | 0 | case '\n':
53 | 0 | retval.append("\\n");
54 | 0 | continue;
55 | 0 | case '\f':
56 | 0 | retval.append("\\f");
57 | 0 | continue;
58 | 0 | case '\r':
59 | 0 | retval.append("\\r");
60 | 0 | continue;
61 | 0 | case '\"':
62 | 0 | retval.append("\\\"");
63 | 0 | continue;
64 | 0 | case '\'':
65 | 0 | retval.append("\\\'");
66 | 0 | continue;
67 | 0 | case '\\':
68 | 0 | retval.append("\\\\");
69 | 0 | continue;
70 | 0 | default:
71 | 0 | if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
72 | 0 | String s = "0000" + Integer.toString(ch, 16);
73 | 0 | retval.append("\\u" + s.substring(s.length() - 4, s.length()));
74 |  | } else {
75 | 0 | retval.append(ch);
76 |  | }
77 | 0 | continue;
78 |  | }
79 |  | }
80 | 0 | return retval.toString();
81 |  | }
82 |  |
83 |  | /**
84 |  | * Returns a detailed message for the Error when it is thrown by the
85 |  | * token manager to indicate a lexical error.
86 |  | * Parameters :
87 |  | * EOFSeen : indicates if EOF caused the lexicl error
88 |  | * curLexState : lexical state in which this error occured
89 |  | * errorLine : line number when the error occured
90 |  | * errorColumn : column number when the error occured
91 |  | * errorAfter : prefix that was seen before this error occured
92 |  | * curchar : the offending character
93 |  | * Note: You can customize the lexical error message by modifying this method.
94 |  | */
95 | 0 | protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
96 | 0 | return ("Lexical error at line " +
97 |  | errorLine + ", column " +
98 |  | errorColumn + ". Encountered: " +
99 | 0 | (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
100 |  | "after : \"" + addEscapes(errorAfter) + "\"");
101 |  | }
102 |  |
103 |  | /**
104 |  | * You can also modify the body of this method to customize your error messages.
105 |  | * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
106 |  | * of end-users concern, so you can return something like :
107 |  | * <p/>
108 |  | * "Internal Error : Please file a bug report .... "
109 |  | * <p/>
110 |  | * from this method for such cases in the release version of your parser.
111 |  | */
112 | 0 | public String getMessage() {
113 | 0 | return super.getMessage();
114 |  | }
115 |  |
116 |  | /*
117 |  | * Constructors of various flavors follow.
118 |  | */
119 |  |
120 | 0 | public TokenMgrError() {
121 |  | }
122 |  |
123 | 0 | public TokenMgrError(String message, int reason) {
124 | 0 | super(message);
125 | 0 | errorCode = reason;
126 |  | }
127 |  |
128 | 0 | public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
129 | 0 | this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
130 |  | }
131 |  | }