-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsjc.java
More file actions
36 lines (33 loc) · 986 Bytes
/
Copy pathsjc.java
File metadata and controls
36 lines (33 loc) · 986 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
36
public class sjc {
public static void main(String args[]) {
simplejava parser;
if (args.length < 1) {
System.out.print("Usage: java sjc <filename>");
return;
}
try {
parser = new simplejava(new java.io.FileInputStream(args[0]));
} catch (java.io.FileNotFoundException e) {
System.out.println("File " + args[0] + " not found.");
return;
}
try {
ASTProgram prog = parser.program();
ASTPrintTree pt = new ASTPrintTree();
AATPrintTree pat = new AATPrintTree();
SemanticAnalyzer sa = new SemanticAnalyzer();
CodeGenerator cg = new CodeGenerator(args[0] + ".s");
System.out.println("Parsing Successful");
prog.Accept(pt);
AATStatement assem = (AATStatement) prog.Accept(sa);
if (!CompError.anyErrors()) {
assem.Accept(pat);
assem.Accept(cg);
cg.GenerateLibrary();
}
} catch (ParseException e) {
System.out.println(e.getMessage());
System.out.println("Parsing Failed");
}
}
}