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