-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSemantic.java
More file actions
31 lines (28 loc) · 835 Bytes
/
Copy pathTestSemantic.java
File metadata and controls
31 lines (28 loc) · 835 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
public class TestSemantic {
public static void main(String args[]) {
simplejava parser;
if (args.length < 1) {
System.out.print("Usage: java TestSemantic <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();
SemanticAnalyzer sa = new SemanticAnalyzer();
System.out.println("Parsing Successful");
prog.Accept(pt);
prog.Accept(sa);
if (!CompError.anyErrors())
System.out.println("No Semantic Errors");
} catch (ParseException e) {
System.out.println(e.getMessage());
System.out.println("Parsing Failed");
}
}
}