-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.java
37 lines (32 loc) · 1.2 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
36
37
package ui;
import ast.Program;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import parser.DynamicCheck;
import parser.GameLexer;
import parser.GameParser;
import parser.ParseTreeToAST;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
// can change to any .txt file inside src/inputs/*
GameLexer lexer = new GameLexer(CharStreams.fromFileName("src/inputs/input.txt"));
for (Token token : lexer.getAllTokens()) {
System.out.println(token);
}
lexer.reset();
TokenStream tokens = new CommonTokenStream(lexer);
System.out.println("Done tokenizing");
GameParser parser = new GameParser(tokens);
ParseTreeToAST visitor = new ParseTreeToAST();
Program parsedProgram = visitor.visitProgram(parser.program());
// dynamic check
DynamicCheck dynamicCheck = new DynamicCheck(parsedProgram);
dynamicCheck.check();
System.out.println("Done parsing");
// print out object for now
App.createGame(parsedProgram);
}
}