-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMain.java
35 lines (28 loc) · 1.13 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.io.IOException;
import ast.node.Program;
import compileError.CompileError;
import main.grammar.LogicPLLexer;
import main.grammar.LogicPLParser;
import visitor.nameAnalyzer.NameAnalyzer;
import visitor.astPrinter.ASTPrinter;
import org.antlr.v4.runtime.*;
import visitor.typeAnalyzer.TypeAnalyzer;
public class Main {
public static void main(String[] args) throws java.io.IOException {
CharStream reader = CharStreams.fromFileName(args[0]);
LogicPLLexer lexer = new LogicPLLexer(reader);
CommonTokenStream tokens = new CommonTokenStream(lexer);
LogicPLParser parser = new LogicPLParser(tokens);
Program program = parser.program().p;
NameAnalyzer nameAnalyzer = new NameAnalyzer();
nameAnalyzer.visit(program);
TypeAnalyzer typeAnalyzer = new TypeAnalyzer();
typeAnalyzer.visit(program);
if (typeAnalyzer.typeErrors.size() > 0) {
for (CompileError compileError : typeAnalyzer.typeErrors)
System.out.println(compileError.getMessage());
return;
}
System.out.println("Compilation was Successful!!");
}
}