-
Notifications
You must be signed in to change notification settings - Fork 25
/
InterpreterMain.java
37 lines (33 loc) · 1003 Bytes
/
InterpreterMain.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
import java.io.OutputStreamWriter;
public class InterpreterMain {
public static void main(String[] args) throws Exception {
String input = new String("""
{
DECLARE in0;
DECLARE in1;
DECLARE out;
in0 = 0;
in1 = 0;
out = 0;
IF (in0) {
out = 1;
} ELSE IF (in1) {
out = 2;
} ELSE {
out = 3;
}
PRINT out;
}
""");
compiler.CompileEnv compileEnv = new compiler.CompileEnv(input, false);
compileEnv.compile();
OutputStreamWriter outStream = new OutputStreamWriter(System.out, "UTF-8");
/*System.out.println("AST:");
compileEnv.dumpAst(System.out);*/
System.out.println("\n\nPROGRAM:");
compileEnv.dump(System.out);
System.out.println("EXECUTE:");
compileEnv.execute(outStream);
outStream.flush();
}
}