forked from FordTang/CS142_CompilersInterpreters
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompiler.java
More file actions
35 lines (30 loc) · 1002 Bytes
/
Compiler.java
File metadata and controls
35 lines (30 loc) · 1002 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
34
35
package crux;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
public class Compiler {
public static String studentName = "Ford Tang";
public static String studentID = "46564602";
public static String uciNetID = "FordT1";
public static void main(String[] args) throws IOException
{
String sourceFilename = args[0];
Scanner s = null;
try {
s = new Scanner(new FileReader(sourceFilename));
} catch (IOException e) {
e.printStackTrace();
System.err.println("Error accessing the source file: \"" + sourceFilename + "\"");
System.exit(-2);
}
Parser p = new Parser(s);
p.parse();
if (p.hasError()) {
System.out.println("Error parsing file.");
System.out.println(p.errorReport());
System.exit(-3);
}
System.out.println(p.parseTreeReport());
}
}