forked from MarkusEble/Compilerbau25
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStmtParserMain.java
More file actions
31 lines (28 loc) · 841 Bytes
/
StmtParserMain.java
File metadata and controls
31 lines (28 loc) · 841 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
25
26
27
28
29
30
31
package com;
import java.io.OutputStreamWriter;
public class StmtParserMain {
public static void main(String[] args) throws Exception {
com.compiler.Lexer lexer = new com.compiler.Lexer();
com.compiler.StmtParser parser = new com.compiler.StmtParser(lexer);
String program = """
{
DECLARE a;
DECLARE b;
a = 1 + 2;
b = 5;
FUNCTION foo(c,d){
RETURN 0;
};
c = 1;
PRINT c;
PRINT a ? b + 1 : -1;
PRINT CALL foo(a,b);
PRINT 3 + 4;
}
""";
com.compiler.ast.ASTStmtNode rootNode = parser.parseProgram(program);
OutputStreamWriter outputWriter = new OutputStreamWriter(System.out);
rootNode.execute(outputWriter);
outputWriter.flush();
}
}