-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
35 lines (27 loc) · 964 Bytes
/
Main.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
import syntaxtree.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
FileInputStream fis = null;
try {
MiniJavaParser parser = new MiniJavaParser(System.in);
Goal root = parser.Goal();
FirstPassVisitor visitor1 = new FirstPassVisitor();
root.accept(visitor1, null);
SecondPassVisitor visitor2 = new SecondPassVisitor(visitor1.classes);
root.accept(visitor2, null);
File newFile = new File("output.txt");
newFile.setWritable(true);
FileOutputStream file = new FileOutputStream(newFile);
file.write(visitor2.finalSpigletCode.getBytes());
file.close();
System.out.println("Intermediate Representation finished!");
} catch (ParseException ex) {
System.out.println(ex.getMessage());
} catch (FileNotFoundException ex) {
System.err.println(ex.getMessage());
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}