KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ppg > parse > ParserError


1 package ppg.parse;
2
3 import java.io.*;
4 import ppg.lex.*;
5
6 /**
7  * This error is thrown when the parser has an internal error -- the user should not see these
8  * in the ideal case -- ex: we have a null somewhere.
9  * If there is a problem with the source, either a syntaxError or SemanticError will be thrown,
10  * depending on nature of the error
11  */

12 public class ParserError extends Exception JavaDoc
13 {
14     /**
15      * This contains the errorMessage for that caused the exception
16      */

17     protected String JavaDoc errorMessage;
18     
19     /**
20      * @param message The massage that contains a description of the error
21      */

22     public ParserError(String JavaDoc message){
23         errorMessage = message;
24     }
25
26     /**
27      * @param file The file where the error came from.
28      * @param msg The message that contains a description of the error.
29      * @param tok Token from which to get the line number and the text
30          * of the error token.
31      */

32     public ParserError(String JavaDoc file, String JavaDoc msg, Token tok) {
33         //errorMessage = file+ ":" +tok.lineNumber() + ": at " +tok.tokenText+ " :" +msg;
34
}
35
36     /**
37      * In rare cases when no error message is know return a generic message
38      */

39     public ParserError() {
40         this("There is a parse error in your code...");
41     }
42     
43     /**
44      * @return String that is the message of the error
45      */

46     public String JavaDoc getErrorMessage(){
47         return errorMessage;
48     }
49 }
50
Popular Tags