001/*
002 * Cobertura - http://cobertura.sourceforge.net/
003 *
004 * This file was taken from JavaNCSS
005 * http://www.kclee.com/clemens/java/javancss/
006 * Copyright (C) 2000 Chr. Clemens Lee <clemens a.t kclee d.o.t com>
007 *
008 * Cobertura is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License as published
010 * by the Free Software Foundation; either version 2 of the License,
011 * or (at your option) any later version.
012 *
013 * Cobertura is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016 * General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with Cobertura; if not, write to the Free Software
020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
021 * USA
022 */
023
024
025/*
026 *
027 * WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING  
028 *
029 * WARNING TO COBERTURA DEVELOPERS
030 *
031 * DO NOT MODIFY THIS FILE!
032 *
033 * MODIFY THE FILES UNDER THE JAVANCSS DIRECTORY LOCATED AT THE ROOT OF THE COBERTURA PROJECT.
034 *
035 * FOLLOW THE PROCEDURE FOR MERGING THE LATEST JAVANCSS INTO COBERTURA LOCATED AT
036 * javancss/coberturaREADME.txt
037 *
038 * WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   
039 */
040/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 4.1 */
041/* JavaCCOptions: */
042package net.sourceforge.cobertura.javancss.parser.java15;
043
044/** Token Manager Error. */
045public class TokenMgrError extends Error
046{
047
048   /*
049    * Ordinals for various reasons why an Error of this type can be thrown.
050    */
051
052   /**
053    * Lexical error occurred.
054    */
055   static final int LEXICAL_ERROR = 0;
056
057   /**
058    * An attempt was made to create a second instance of a static token manager.
059    */
060   static final int STATIC_LEXER_ERROR = 1;
061
062   /**
063    * Tried to change to an invalid lexical state.
064    */
065   static final int INVALID_LEXICAL_STATE = 2;
066
067   /**
068    * Detected (and bailed out of) an infinite loop in the token manager.
069    */
070   static final int LOOP_DETECTED = 3;
071
072   /**
073    * Indicates the reason why the exception is thrown. It will have
074    * one of the above 4 values.
075    */
076   int errorCode;
077
078   /**
079    * Replaces unprintable characters by their escaped (or unicode escaped)
080    * equivalents in the given string
081    */
082   protected static final String addEscapes(String str) {
083      StringBuffer retval = new StringBuffer();
084      char ch;
085      for (int i = 0; i < str.length(); i++) {
086        switch (str.charAt(i))
087        {
088           case 0 :
089              continue;
090           case '\b':
091              retval.append("\\b");
092              continue;
093           case '\t':
094              retval.append("\\t");
095              continue;
096           case '\n':
097              retval.append("\\n");
098              continue;
099           case '\f':
100              retval.append("\\f");
101              continue;
102           case '\r':
103              retval.append("\\r");
104              continue;
105           case '\"':
106              retval.append("\\\"");
107              continue;
108           case '\'':
109              retval.append("\\\'");
110              continue;
111           case '\\':
112              retval.append("\\\\");
113              continue;
114           default:
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()));
118              } else {
119                 retval.append(ch);
120              }
121              continue;
122        }
123      }
124      return retval.toString();
125   }
126
127   /**
128    * Returns a detailed message for the Error when it is thrown by the
129    * token manager to indicate a lexical error.
130    * Parameters :
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.
138    */
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) + "\"");
145   }
146
147   /**
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 :
151    *
152    *     "Internal Error : Please file a bug report .... "
153    *
154    * from this method for such cases in the release version of your parser.
155    */
156   public String getMessage() {
157      return super.getMessage();
158   }
159
160   /*
161    * Constructors of various flavors follow.
162    */
163
164   /** No arg constructor. */
165   public TokenMgrError() {
166   }
167
168   /** Constructor with message and reason. */
169   public TokenMgrError(String message, int reason) {
170      super(message);
171      errorCode = reason;
172   }
173
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);
177   }
178}
179/* JavaCC - OriginalChecksum=1e47199681088f2adfb64cc30349ab20 (do not edit this line) */