1 22 package org.jboss.aop.annotation.factory.duplicate.ast; 23 24 public class TokenMgrError extends Error 25 { 26 27 private static final long serialVersionUID = -8256510811060336766L; 28 29 32 33 36 static final int LEXICAL_ERROR = 0; 37 38 41 static final int STATIC_LEXER_ERROR = 1; 42 43 46 static final int INVALID_LEXICAL_STATE = 2; 47 48 51 static final int LOOP_DETECTED = 3; 52 53 57 int errorCode; 58 59 63 protected static final String addEscapes(String str) { 64 StringBuffer retval = new StringBuffer (); 65 char ch; 66 for (int i = 0; i < str.length(); i++) { 67 switch (str.charAt(i)) 68 { 69 case 0 : 70 continue; 71 case '\b': 72 retval.append("\\b"); 73 continue; 74 case '\t': 75 retval.append("\\t"); 76 continue; 77 case '\n': 78 retval.append("\\n"); 79 continue; 80 case '\f': 81 retval.append("\\f"); 82 continue; 83 case '\r': 84 retval.append("\\r"); 85 continue; 86 case '\"': 87 retval.append("\\\""); 88 continue; 89 case '\'': 90 retval.append("\\\'"); 91 continue; 92 case '\\': 93 retval.append("\\\\"); 94 continue; 95 default: 96 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 97 String s = "0000" + Integer.toString(ch, 16); 98 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 99 } else { 100 retval.append(ch); 101 } 102 continue; 103 } 104 } 105 return retval.toString(); 106 } 107 108 120 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 121 return("Lexical error at line " + 122 errorLine + ", column " + 123 errorColumn + ". Encountered: " + 124 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 125 "after : \"" + addEscapes(errorAfter) + "\""); 126 } 127 128 137 public String getMessage() { 138 return super.getMessage(); 139 } 140 141 144 145 public TokenMgrError() { 146 } 147 148 public TokenMgrError(String message, int reason) { 149 super(message); 150 errorCode = reason; 151 } 152 153 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 154 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 155 } 156 } 157 | Popular Tags |