Andis ast records

This commit is contained in:
laurenz 2024-04-24 15:51:54 +02:00
parent 8a11d9273f
commit 55a15e8bda
17 changed files with 119 additions and 0 deletions

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
import de.dhbw.horb.ast.Statement;
public record Assignment(Location loc, Expression value) implements Statement {
}

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
import de.dhbw.horb.ast.Operator;
public record Binary(Expression left, Operator op, Expression right) implements Expression{
}

View File

@ -0,0 +1,9 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Node;
import de.dhbw.horb.ast.Statement;
import java.util.List;
public record Block(List<Variable> vars, List<Statement> stmts) implements Node {
}

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
public record BoolConstant(Boolean value) implements Expression {
}

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Statement;
public record Break() implements Statement {
}

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Statement;
public record Continue() implements Statement {
}

View File

@ -0,0 +1,9 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Node;
import de.dhbw.horb.ast.Type;
import java.util.List;
public record Function(Type type, String name, List<Variable> params, Block block) implements Node {
}

View File

@ -0,0 +1,9 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
import de.dhbw.horb.ast.Statement;
import java.util.List;
public record FunctionCall(String name, List<Expression> args) implements Expression, Statement {
}

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
import de.dhbw.horb.ast.Statement;
public record IfElse(Expression cond, Block ifBlock, Block elseBlock) implements Statement {
}

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
public record IntConstant(Integer value) implements Expression {
}

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
public record Location(String name) implements Expression {
}

View File

@ -0,0 +1,8 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Node;
import java.util.List;
public record Program(List<Variable> variables, List<Function> methods) implements Node {
}

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
import de.dhbw.horb.ast.Statement;
public record Return(Expression ret) implements Statement {
}

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Statement;
public record ReturnVoid() implements Statement {
}

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Node;
import de.dhbw.horb.ast.Type;
public record Variable(String name, Type type) implements Node {
}

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Statement;
public record VoidFunctionCall(FunctionCall expr) implements Statement {
}

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
import de.dhbw.horb.ast.Expression;
import de.dhbw.horb.ast.Statement;
public record While(Expression cond, Block block) implements Statement {
}