|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| package net.sourceforge.pmd.jsp.ast; |
|
8 |
| |
|
9 |
| public class TokenMgrError extends RuntimeException { |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| static final int LEXICAL_ERROR = 0; |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| static final int STATIC_LEXER_ERROR = 1; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| static final int INVALID_LEXICAL_STATE = 2; |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| static final int LOOP_DETECTED = 3; |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| int errorCode; |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
0
| protected static final String addEscapes(String str) {
|
|
45 |
0
| StringBuffer retval = new StringBuffer();
|
|
46 |
0
| char ch;
|
|
47 |
0
| for (int i = 0; i < str.length(); i++) {
|
|
48 |
0
| switch (str.charAt(i)) {
|
|
49 |
0
| case 0:
|
|
50 |
0
| continue;
|
|
51 |
0
| case '\b':
|
|
52 |
0
| retval.append("\\b");
|
|
53 |
0
| continue;
|
|
54 |
0
| case '\t':
|
|
55 |
0
| retval.append("\\t");
|
|
56 |
0
| continue;
|
|
57 |
0
| case '\n':
|
|
58 |
0
| retval.append("\\n");
|
|
59 |
0
| continue;
|
|
60 |
0
| case '\f':
|
|
61 |
0
| retval.append("\\f");
|
|
62 |
0
| continue;
|
|
63 |
0
| case '\r':
|
|
64 |
0
| retval.append("\\r");
|
|
65 |
0
| continue;
|
|
66 |
0
| case '\"':
|
|
67 |
0
| retval.append("\\\"");
|
|
68 |
0
| continue;
|
|
69 |
0
| case '\'':
|
|
70 |
0
| retval.append("\\\'");
|
|
71 |
0
| continue;
|
|
72 |
0
| case '\\':
|
|
73 |
0
| retval.append("\\\\");
|
|
74 |
0
| continue;
|
|
75 |
0
| default:
|
|
76 |
0
| if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
|
|
77 |
0
| String s = "0000" + Integer.toString(ch, 16);
|
|
78 |
0
| retval.append("\\u" + s.substring(s.length() - 4, s.length()));
|
|
79 |
| } else { |
|
80 |
0
| retval.append(ch);
|
|
81 |
| } |
|
82 |
0
| continue;
|
|
83 |
| } |
|
84 |
| } |
|
85 |
0
| return retval.toString();
|
|
86 |
| } |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
0
| protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
|
|
101 |
0
| return ("Lexical error at line " +
|
|
102 |
| errorLine + ", column " + |
|
103 |
| errorColumn + ". Encountered: " + |
|
104 |
0
| (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
|
|
105 |
| "after : \"" + addEscapes(errorAfter) + "\""); |
|
106 |
| } |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
| |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
0
| public String getMessage() {
|
|
118 |
0
| return super.getMessage();
|
|
119 |
| } |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
0
| public TokenMgrError() {
|
|
126 |
| } |
|
127 |
| |
|
128 |
0
| public TokenMgrError(String message, int reason) {
|
|
129 |
0
| super(message);
|
|
130 |
0
| errorCode = reason;
|
|
131 |
| } |
|
132 |
| |
|
133 |
0
| public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
|
|
134 |
0
| this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
|
|
135 |
| } |
|
136 |
| } |