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