1 19 20 21 package org.netbeans.modules.debugger.jpda.expr; 22 23 class TokenMgrError extends Error 24 { 25 28 29 32 static final int LEXICAL_ERROR = 0; 33 34 37 static final int STATIC_LEXER_ERROR = 1; 38 39 42 static final int INVALID_LEXICAL_STATE = 2; 43 44 47 static final int LOOP_DETECTED = 3; 48 49 53 int errorCode; 54 55 59 protected static final String addEscapes(String str) { 60 StringBuffer retval = new StringBuffer (); 61 char ch; 62 for (int i = 0; i < str.length(); i++) { 63 switch (str.charAt(i)) 64 { 65 case 0 : 66 continue; 67 case '\b': 68 retval.append("\\b"); 69 continue; 70 case '\t': 71 retval.append("\\t"); 72 continue; 73 case '\n': 74 retval.append("\\n"); 75 continue; 76 case '\f': 77 retval.append("\\f"); 78 continue; 79 case '\r': 80 retval.append("\\r"); 81 continue; 82 case '\"': 83 retval.append("\\\""); 84 continue; 85 case '\'': 86 retval.append("\\\'"); 87 continue; 88 case '\\': 89 retval.append("\\\\"); 90 continue; 91 default: 92 if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { 93 String s = "0000" + Integer.toString(ch, 16); 94 retval.append("\\u" + s.substring(s.length() - 4, s.length())); 95 } else { 96 retval.append(ch); 97 } 98 continue; 99 } 100 } 101 return retval.toString(); 102 } 103 104 116 protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { 117 return("Lexical error at line " + 118 errorLine + ", column " + 119 errorColumn + ". Encountered: " + 120 (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") + 121 "after : \"" + addEscapes(errorAfter) + "\""); 122 } 123 124 133 public String getMessage() { 134 return super.getMessage(); 135 } 136 137 140 141 public TokenMgrError() { 142 } 143 144 public TokenMgrError(String message, int reason) { 145 super(message); 146 errorCode = reason; 147 } 148 149 public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { 150 this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); 151 } 152 } 153 | Popular Tags |