-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
35 lines (31 loc) · 1.14 KB
/
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 java_cup.runtime.ComplexSymbolFactory;
import lexical.LexicalAnalyzer;
import org.objectweb.asm.Opcodes;
import semantic.symbolTable.Display;
import semantic.syntaxTree.Node;
import semantic.syntaxTree.program.ClassDCL;
import semantic.symbolTable.typeTree.TypeTree;
import syntax.Parser;
import java.io.FileReader;
import java.io.IOException;
public class Main implements Opcodes {
public static void main(String[] args) throws IOException {
// order of initialization is important
Node.init();
Display.init();
TypeTree.init();
parseInput();
}
private static void parseInput() throws IOException {
ComplexSymbolFactory symbolFactory = new ComplexSymbolFactory();
Parser parser = new Parser(new LexicalAnalyzer(new FileReader("test.txt"), symbolFactory), symbolFactory);
try {
parser.parse();
ClassDCL clazz = Parser.finalResult;
clazz.generateCode(null, null, null, null, null, null);
System.out.println("Code compiled successfully");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}