2
* Cobertura - http://cobertura.sourceforge.net/
4
* This file was taken from JavaNCSS
5
* http://www.kclee.com/clemens/java/javancss/
6
* Copyright (C) 2000 Chr. Clemens Lee <clemens a.t kclee d.o.t com>
8
* Cobertura is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published
10
* by the Free Software Foundation; either version 2 of the License,
11
* or (at your option) any later version.
13
* Cobertura is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with Cobertura; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
29
* WARNING TO COBERTURA DEVELOPERS
31
* DO NOT MODIFY THIS FILE!
33
* MODIFY THE FILES UNDER THE JAVANCSS DIRECTORY LOCATED AT THE ROOT OF THE COBERTURA PROJECT.
35
* FOLLOW THE PROCEDURE FOR MERGING THE LATEST JAVANCSS INTO COBERTURA LOCATED AT
36
* javancss/coberturaREADME.txt
38
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
40
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */
42
package net.sourceforge.cobertura.javancss.parser.java15;
44
/** Token Manager Error. */
45
public class TokenMgrError extends Error
49
* Ordinals for various reasons why an Error of this type can be thrown.
53
* Lexical error occurred.
55
static final int LEXICAL_ERROR = 0;
58
* An attempt was made to create a second instance of a static token manager.
60
static final int STATIC_LEXER_ERROR = 1;
63
* Tried to change to an invalid lexical state.
65
static final int INVALID_LEXICAL_STATE = 2;
68
* Detected (and bailed out of) an infinite loop in the token manager.
70
static final int LOOP_DETECTED = 3;
73
* Indicates the reason why the exception is thrown. It will have
74
* one of the above 4 values.
79
* Replaces unprintable characters by their escaped (or unicode escaped)
80
* equivalents in the given string
82
protected static final String addEscapes(String str) {
83
StringBuffer retval = new StringBuffer();
85
for (int i = 0; i < str.length(); i++) {
86
switch (str.charAt(i))
100
retval.append("\\f");
103
retval.append("\\r");
106
retval.append("\\\"");
109
retval.append("\\\'");
112
retval.append("\\\\");
115
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
116
String s = "0000" + Integer.toString(ch, 16);
117
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
124
return retval.toString();
128
* Returns a detailed message for the Error when it is thrown by the
129
* token manager to indicate a lexical error.
131
* EOFSeen : indicates if EOF caused the lexical error
132
* curLexState : lexical state in which this error occurred
133
* errorLine : line number when the error occurred
134
* errorColumn : column number when the error occurred
135
* errorAfter : prefix that was seen before this error occurred
136
* curchar : the offending character
137
* Note: You can customize the lexical error message by modifying this method.
139
protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
140
return("Lexical error at line " +
141
errorLine + ", column " +
142
errorColumn + ". Encountered: " +
143
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
144
"after : \"" + addEscapes(errorAfter) + "\"");
148
* You can also modify the body of this method to customize your error messages.
149
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
150
* of end-users concern, so you can return something like :
152
* "Internal Error : Please file a bug report .... "
154
* from this method for such cases in the release version of your parser.
156
public String getMessage() {
157
return super.getMessage();
161
* Constructors of various flavors follow.
164
/** No arg constructor. */
165
public TokenMgrError() {
168
/** Constructor with message and reason. */
169
public TokenMgrError(String message, int reason) {
174
/** Full Constructor. */
175
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
176
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
179
/* JavaCC - OriginalChecksum=a8b95413d91ef43eb316f9594e077ab0 (do not edit this line) */