-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterpreterError.java
46 lines (41 loc) · 1.05 KB
/
InterpreterError.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public class InterpreterError extends Exception {
String message;
public InterpreterError(String msg) {
message = msg;
}
public String toString(){
return message;
}
}
class LexerError extends InterpreterError {
Token token;
public LexerError(Token t, String msg) {
super(msg);
token = t;
}
public String toString(){
return "line "+token.line+", column "+token.column+": "+super.toString();
}
}
class ParserError extends InterpreterError {
Token token;
public ParserError(Token ts, String msg) {
super(msg);
token = ts;
}
public String toString(){
return "line "+token.line+", column "+token.column+": "+super.toString();
}
}
class SemanticError extends InterpreterError {
Token start;
Token end;
public SemanticError(Token ts, Token te, String msg) {
super(msg);
start = ts;
end= te;
}
public String toString(){
return "line "+start.line+", column "+start.column+": "+super.toString();
}
}