01: package persistence.antlr;
02:
03: /* ANTLR Translator Generator
04: * Project led by Terence Parr at http://www.jGuru.com
05: * Software rights: http://www.antlr.org/license.html
06: *
07: */
08:
09: import persistence.antlr.collections.AST;
10:
11: public class NoViableAltException extends RecognitionException {
12: public Token token;
13: public AST node; // handles parsing and treeparsing
14:
15: public NoViableAltException(AST t) {
16: super ("NoViableAlt", "<AST>", t.getLine(), t.getColumn());
17: node = t;
18: }
19:
20: public NoViableAltException(Token t, String fileName_) {
21: super ("NoViableAlt", fileName_, t.getLine(), t.getColumn());
22: token = t;
23: }
24:
25: /**
26: * Returns a clean error message (no line number/column information)
27: */
28: public String getMessage() {
29: if (token != null) {
30: return "unexpected token: " + token.getText();
31: }
32:
33: // must a tree parser error if token==null
34: if (node == TreeParser.ASTNULL) {
35: return "unexpected end of subtree";
36: }
37: return "unexpected AST node: " + node.toString();
38: }
39: }
|