-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
43 lines (37 loc) · 1.04 KB
/
Main.java
File metadata and controls
43 lines (37 loc) · 1.04 KB
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
37
38
39
40
41
42
43
import syntaxtree.*;
import visitor.*;
import java.io.*;
class Main {
public static void main (String [] args){
if(args.length == 0) {
System.err.println("Usage: Main <file1> <file2> ... <fileN>");
System.exit(1);
}
for(int i = 0 ; i < args.length ; i++) {
FileInputStream fis = null;
ClassInfo main = new ClassInfo();
try {
fis = new FileInputStream(args[i]);
MiniJavaParser parser = new MiniJavaParser(fis);
FirstVisitor firtstVisitor = new FirstVisitor();
Goal root = parser.Goal();
root.accept(firtstVisitor, main);
SecondVisitor secondVisitor = new SecondVisitor();
root.accept(secondVisitor, main);
main.printOffsets();
} catch (ParseException ex) {
System.out.println(ex.getMessage());
} catch (FileNotFoundException ex) {
System.err.println(ex.getMessage());
} catch(Exception ex){
System.err.println(ex.getMessage());
} finally {
try {
if (fis != null) fis.close();
} catch (IOException ex) {
System.err.println(ex.getMessage());
}
}
}
}
}