KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > persistence > antlr > NoViableAltException


1 package persistence.antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/license.html
6  *
7  */

8
9 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 JavaDoc 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 JavaDoc 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 }
40
Popular Tags