1 package persistence.antlr; 2 3 8 9 public class NoViableAltForCharException extends RecognitionException { 10 public char foundChar; 11 12 public NoViableAltForCharException(char c, CharScanner scanner) { 13 super("NoViableAlt", scanner.getFilename(), 14 scanner.getLine(), scanner.getColumn()); 15 foundChar = c; 16 } 17 18 19 public NoViableAltForCharException(char c, String fileName, int line) { 20 this(c, fileName, line, -1); 21 } 22 23 public NoViableAltForCharException(char c, String fileName, int line, int column) { 24 super("NoViableAlt", fileName, line, column); 25 foundChar = c; 26 } 27 28 31 public String getMessage() { 32 String mesg = "unexpected char: "; 33 34 38 if ((foundChar >= ' ') && (foundChar <= '~')) { 39 mesg += '\''; 40 mesg += foundChar; 41 mesg += '\''; 42 } 43 else { 44 mesg += "0x"; 45 46 int t = (int)foundChar >> 4; 47 48 if (t < 10) 49 mesg += (char)(t | 0x30); 50 else 51 mesg += (char)(t + 0x37); 52 53 t = (int)foundChar & 0xF; 54 55 if (t < 10) 56 mesg += (char)(t | 0x30); 57 else 58 mesg += (char)(t + 0x37); 59 } 60 return mesg; 61 } 62 } 63 | Popular Tags |