fixed imports on records, added Enums and Interfaces

This commit is contained in:
laurenz 2024-04-24 16:38:30 +02:00
parent 55a15e8bda
commit 5bd8c12568
37 changed files with 161 additions and 99 deletions

View File

@ -1,7 +0,0 @@
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

@ -1,7 +0,0 @@
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

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

View File

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

View File

@ -0,0 +1,6 @@
package de.maishai.ast;
public interface Expression extends Node {
}

View File

@ -1,9 +0,0 @@
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

@ -1,7 +0,0 @@
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

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

View File

@ -0,0 +1,4 @@
package de.maishai.ast;
public interface Node {
}

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
public enum Operator {
ADD,
SUB,
MUL
}

View File

@ -1,8 +0,0 @@
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

@ -1,7 +0,0 @@
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,8 @@
package de.maishai.ast;
public enum ReturnType {
INT,
BOOL,
CHAR,
VOID
}

View File

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

View File

@ -0,0 +1,3 @@
package de.maishai.ast;
public interface Statement extends Node {
}

View File

@ -0,0 +1,7 @@
package de.maishai.ast;
public enum Type {
INT,
BOOL,
CHAR
}

View File

@ -1,7 +0,0 @@
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

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

View File

@ -1,7 +0,0 @@
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 {
}

View File

@ -0,0 +1,8 @@
package de.maishai.ast.records;
import de.maishai.ast.Expression;
import de.maishai.ast.Statement;
public record Assignment(Id loc, Expression value) implements Statement {
}

View File

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

View File

@ -1,7 +1,9 @@
package de.maishai.ast;
package de.maishai.ast.records;
import de.dhbw.horb.ast.Node;
import de.dhbw.horb.ast.Statement;
import de.maishai.ast.Node;
import de.maishai.ast.Statement;
import java.util.List;

View File

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

View File

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

View File

@ -0,0 +1,8 @@
package de.maishai.ast.records;
import de.maishai.ast.Node;
import java.util.List;
public record Class(Id id ,List<Variable> variables, List<Method> methods) implements Node {
}

View File

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

View File

@ -1,7 +1,9 @@
package de.maishai.ast;
package de.maishai.ast.records;
import de.dhbw.horb.ast.Expression;
import de.dhbw.horb.ast.Statement;
import de.maishai.ast.Expression;
import de.maishai.ast.Statement;
import java.util.List;

View File

@ -0,0 +1,7 @@
package de.maishai.ast.records;
import de.maishai.ast.Expression;
public record Id(String name) implements Expression {
}

View File

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

View File

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

View File

@ -0,0 +1,11 @@
package de.maishai.ast.records;
import de.maishai.ast.Node;
import de.maishai.ast.ReturnType;
import java.util.List;
public record Method(ReturnType type, Id id, List<Parameter> params, Block block) implements Node {
}

View File

@ -0,0 +1,8 @@
package de.maishai.ast.records;
import de.maishai.ast.Node;
import de.maishai.ast.Type;
public record Parameter(String name, Type type) implements Node {
}

View File

@ -0,0 +1,9 @@
package de.maishai.ast.records;
import de.maishai.ast.Node;
import java.util.List;
public record Program(List<Class> variables, List<Method> methods) implements Node {
}

View File

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

View File

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

View File

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

View File

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