Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TokenMgrError.java

00001 package edu.ksu.cis.bandera.abstraction.predicate.parser;
00002 
00003 /* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 0.7pre2 */
00004 public class TokenMgrError extends Error
00005 {
00006    /*
00007     * Ordinals for various reasons why an Error of this type can be thrown.
00008     */
00009 
00010    /**
00011     * Lexical error occured.
00012     */
00013    static final int LEXICAL_ERROR = 0;
00014 
00015    /**
00016     * An attempt wass made to create a second instance of a static token manager.
00017     */
00018    static final int STATIC_LEXER_ERROR = 1;
00019 
00020    /**
00021     * Tried to change to an invalid lexical state.
00022     */
00023    static final int INVALID_LEXICAL_STATE = 2;
00024 
00025    /**
00026     * Detected (and bailed out of) an infinite loop in the token manager.
00027     */
00028    static final int LOOP_DETECTED = 3;
00029 
00030    /**
00031     * Indicates the reason why the exception is thrown. It will have
00032     * one of the above 4 values.
00033     */
00034    int errorCode;
00035 
00036    /*
00037     * Constructors of various flavors follow.
00038     */
00039 
00040    public TokenMgrError() {
00041    }   
00042    public TokenMgrError(String message, int reason) {
00043       super(message);
00044       errorCode = reason;
00045    }   
00046    public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
00047       this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
00048    }   
00049    /**
00050     * Replaces unprintable characters by their espaced (or unicode escaped)
00051     * equivalents in the given string
00052     */
00053    protected static final String addEscapes(String str) {
00054       StringBuffer retval = new StringBuffer();
00055       char ch;
00056       for (int i = 0; i < str.length(); i++) {
00057         switch (str.charAt(i))
00058         {
00059            case 0 :
00060               continue;
00061            case '\b':
00062               retval.append("\\b");
00063               continue;
00064            case '\t':
00065               retval.append("\\t");
00066               continue;
00067            case '\n':
00068               retval.append("\\n");
00069               continue;
00070            case '\f':
00071               retval.append("\\f");
00072               continue;
00073            case '\r':
00074               retval.append("\\r");
00075               continue;
00076            case '\"':
00077               retval.append("\\\"");
00078               continue;
00079            case '\'':
00080               retval.append("\\\'");
00081               continue;
00082            case '\\':
00083               retval.append("\\\\");
00084               continue;
00085            default:
00086               if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
00087                  String s = "0000" + Integer.toString(ch, 16);
00088                  retval.append("\\u" + s.substring(s.length() - 4, s.length()));
00089               } else {
00090                  retval.append(ch);
00091               }
00092               continue;
00093         }
00094       }
00095       return retval.toString();
00096    }   
00097    /**
00098     * You can also modify the body of this method to customize your error messages.
00099     * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
00100     * of end-users concern, so you can return something like :
00101     *
00102     *     "Internal Error : Please file a bug report .... "
00103     *
00104     * from this method for such cases in the release version of your parser.
00105     */
00106    public String getMessage() {
00107       return super.getMessage();
00108    }   
00109    /**
00110     * Returns a detailed message for the Error when it is thrown by the
00111     * token manager to indicate a lexical error.
00112     * Parameters :
00113     *    EOFSeen     : indicates if EOF caused the lexicl error
00114     *    curLexState : lexical state in which this error occured
00115     *    errorLine   : line number when the error occured
00116     *    errorColumn : column number when the error occured
00117     *    errorAfter  : prefix that was seen before this error occured
00118     *    curchar     : the offending character
00119     * Note: You can customize the lexical error message by modifying this method.
00120     */
00121    private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
00122       return("Lexical error at line " +
00123            errorLine + ", column " +
00124            errorColumn + ".  Encountered: " +
00125            (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
00126            "after : \"" + addEscapes(errorAfter) + "\"");
00127    }   
00128 }

Generated at Thu Feb 7 06:57:42 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001