-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
24 lines (20 loc) · 902 Bytes
/
Copy pathMain.java
File metadata and controls
24 lines (20 loc) · 902 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
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import java.io.FileWriter;
import java.io.PrintWriter;
public class Main {
public static void main(String[] args) throws Exception{
tinyPythonLexer lexer = new tinyPythonLexer(CharStreams.fromFileName("test.tpy"));
CommonTokenStream tokens = new CommonTokenStream(lexer);
tinyPythonParser parser = new tinyPythonParser(tokens);
ParseTree tree = parser.program();
ParseTreeWalker walker = new ParseTreeWalker();
tinyPythonToJasmin toJavaBytecode = new tinyPythonToJasmin();
walker.walk(toJavaBytecode, tree);
try (PrintWriter writer = new PrintWriter(new FileWriter("Test.j"))) {
writer.print(toJavaBytecode.fffffinal);
}
}
}