-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomParser.java
More file actions
33 lines (28 loc) · 977 Bytes
/
CustomParser.java
File metadata and controls
33 lines (28 loc) · 977 Bytes
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
import java_cup.runtime.Symbol;
public class CustomParser extends parser {
private String fileName;
public boolean invalid_parse = false;
public CustomParser(Lexer lexer, String fileName) {
super(lexer);
this.fileName = fileName;
}
public void syntax_error(Symbol info) {
invalid_parse = true;
// System.err.print(this.fileName + ":"
// + (info.left + 1) + ":"
// + (info.right + 1) + ": ");
return;
}
public void report_error(String message, Object info) {
invalid_parse = true;
// // System.err.println(message);
// // }
// public void report_error(String message, Symbol info) {
// System.err.println(info);
if (info instanceof Symbol) {
Symbol info2 = (Symbol) info;
System.err.print(this.fileName + ":" + (info2.left + 1) + ":" + (info2.right + 1) + ": ");
}
System.err.println(message);
}
}