KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > antlr > NoViableAltException


1 package antlr;
2
3 /* ANTLR Translator Generator
4  * Project led by Terence Parr at http://www.jGuru.com
5  * Software rights: http://www.antlr.org/RIGHTS.html
6  *
7  * $Id: //depot/code/org.antlr/main/main/antlr/NoViableAltException.java#6 $
8  */

9
10 import antlr.collections.AST;
11
12 public class NoViableAltException extends RecognitionException {
13     public Token token;
14     public AST node; // handles parsing and treeparsing
15

16     public NoViableAltException(AST t) {
17         super("NoViableAlt", "<AST>", -1, -1);
18         node = t;
19     }
20
21     public NoViableAltException(Token t, String JavaDoc fileName_) {
22         super("NoViableAlt", fileName_, t.getLine(), t.getColumn());
23         token = t;
24     }
25
26     /**
27      * Returns a clean error message (no line number/column information)
28      */

29     public String JavaDoc getMessage() {
30         if (token != null) {
31             return "unexpected token: " + token.getText();
32         }
33
34         // must a tree parser error if token==null
35
if (node == TreeParser.ASTNULL) {
36             return "unexpected end of subtree";
37         }
38         return "unexpected AST node: " + node.toString();
39     }
40 }
41
Popular Tags