01: package ro.infoiasi.donald.compiler.parser;
02:
03: import ro.infoiasi.donald.compiler.cfg.Terminal;
04:
05: public class SyntaxError extends Exception {
06: Terminal a;
07:
08: public SyntaxError() {
09: super ();
10: }
11:
12: public SyntaxError(Terminal a) {
13: super ();
14: this .a = a;
15: }
16:
17: public SyntaxError(String message) {
18: super (message);
19: }
20:
21: public SyntaxError(String message, Terminal a) {
22: super (message);
23: this .a = a;
24: }
25:
26: public String toString() {
27: StringBuffer sb = new StringBuffer();
28: sb.append("Syntax error");
29: if (a != null) {
30: sb.append(" near tooken " + a);
31: }
32: String message = getMessage();
33: if (message != null) {
34: sb.append(": " + message);
35: }
36: return sb.toString();
37: }
38: }
|