forked from Diogo-Valadares/Compiladores
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
32 lines (25 loc) · 901 Bytes
/
Main.java
File metadata and controls
32 lines (25 loc) · 901 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
import java.io.FileNotFoundException;
import java.io.FileReader;
import java_cup.runtime.*;
class Main {
static boolean do_debug_parse = false;
static public void main(String[] args) throws java.io.IOException {
/* create a parsing object */
Parser parser_obj = new Parser(new scanner(new FileReader(args[0])));
/* open input files, etc. here */
Symbol parse_tree = null;
try {
if (do_debug_parse)
parse_tree = parser_obj.debug_parse();
else
parse_tree = parser_obj.parse();
} catch (Exception e) {
System.out.println(e.getCause());
for (StackTraceElement stackElement : e.getStackTrace()) {
System.out.println(stackElement.getFileName() + " " +stackElement.getMethodName() + " " + stackElement.getLineNumber());
}
} finally {
/* do close out here */
}
}
}