From 48fc1dd7b41467a0de28f297c9cfcdf4890f3ecc Mon Sep 17 00:00:00 2001 From: ahmad Date: Sat, 4 May 2024 10:49:26 +0200 Subject: [PATCH] Build the typed ast --- .../typedast/typedclass/Assignment.java | 25 +++++++++++++++++ .../maishai/typedast/typedclass/Binary.java | 24 ++++++++++++++++ .../de/maishai/typedast/typedclass/Block.java | 23 +++++++++++++++ .../typedast/typedclass/BoolLiteral.java | 23 +++++++++++++++ .../de/maishai/typedast/typedclass/Break.java | 20 +++++++++++++ .../typedast/typedclass/CharLiteral.java | 21 ++++++++++++++ .../typedast/typedclass/Constructor.java | 24 ++++++++++++++++ .../maishai/typedast/typedclass/Continue.java | 22 +++++++++++++++ .../maishai/typedast/typedclass/DoWhile.java | 23 +++++++++++++++ .../de/maishai/typedast/typedclass/Field.java | 2 +- .../maishai/typedast/typedclass/FieldId.java | 23 +++++++++++++++ .../de/maishai/typedast/typedclass/For.java | 26 +++++++++++++++++ .../de/maishai/typedast/typedclass/Id.java | 23 +++++++++++++++ .../maishai/typedast/typedclass/IfElse.java | 25 +++++++++++++++++ .../typedast/typedclass/IntLiteral.java | 22 +++++++++++++++ .../typedast/typedclass/LocalVariable.java | 22 +++++++++++++++ .../typedast/typedclass/MainMethod.java | 22 +++++++++++++++ .../typedast/typedclass/MethodCall.java | 28 +++++++++++++++++++ .../de/maishai/typedast/typedclass/New.java | 25 +++++++++++++++++ .../maishai/typedast/typedclass/Program.java | 22 +++++++++++++++ .../maishai/typedast/typedclass/Return.java | 24 ++++++++++++++++ .../typedast/typedclass/ReturnVoid.java | 21 ++++++++++++++ .../de/maishai/typedast/typedclass/Unary.java | 23 +++++++++++++++ .../de/maishai/typedast/typedclass/While.java | 24 ++++++++++++++++ 24 files changed, 536 insertions(+), 1 deletion(-) create mode 100644 src/main/java/de/maishai/typedast/typedclass/Assignment.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Binary.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Block.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/BoolLiteral.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Break.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/CharLiteral.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Constructor.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Continue.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/DoWhile.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/FieldId.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/For.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Id.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/IfElse.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/IntLiteral.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/LocalVariable.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/MainMethod.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/MethodCall.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/New.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Program.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Return.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/ReturnVoid.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/Unary.java create mode 100644 src/main/java/de/maishai/typedast/typedclass/While.java diff --git a/src/main/java/de/maishai/typedast/typedclass/Assignment.java b/src/main/java/de/maishai/typedast/typedclass/Assignment.java new file mode 100644 index 0000000..50d7b89 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Assignment.java @@ -0,0 +1,25 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class Assignment implements Statement { + private Id loc; + private Assignment assignment; + private Expression value; + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Binary.java b/src/main/java/de/maishai/typedast/typedclass/Binary.java new file mode 100644 index 0000000..2a7a015 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Binary.java @@ -0,0 +1,24 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.ast.Operator; +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class Binary implements Expression { + private Expression left; + private Operator op; + private Expression right; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Block.java b/src/main/java/de/maishai/typedast/typedclass/Block.java new file mode 100644 index 0000000..ffc6403 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Block.java @@ -0,0 +1,23 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.List; +import java.util.Map; +@Data +public class Block implements Node { + private List vars; + private List stmts; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/BoolLiteral.java b/src/main/java/de/maishai/typedast/typedclass/BoolLiteral.java new file mode 100644 index 0000000..6e9397c --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/BoolLiteral.java @@ -0,0 +1,23 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class BoolLiteral implements Expression { + + private boolean value; + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Break.java b/src/main/java/de/maishai/typedast/typedclass/Break.java new file mode 100644 index 0000000..822e83d --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Break.java @@ -0,0 +1,20 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class Break implements Statement { + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/CharLiteral.java b/src/main/java/de/maishai/typedast/typedclass/CharLiteral.java new file mode 100644 index 0000000..9820e3a --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/CharLiteral.java @@ -0,0 +1,21 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class CharLiteral implements Expression { + private char value; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Constructor.java b/src/main/java/de/maishai/typedast/typedclass/Constructor.java new file mode 100644 index 0000000..fbe661e --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Constructor.java @@ -0,0 +1,24 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.List; +import java.util.Map; +@Data +public class Constructor implements Node { + + private Id id; + private List params; + private Block block; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Continue.java b/src/main/java/de/maishai/typedast/typedclass/Continue.java new file mode 100644 index 0000000..f4d3cb4 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Continue.java @@ -0,0 +1,22 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class Continue implements Statement { + + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/DoWhile.java b/src/main/java/de/maishai/typedast/typedclass/DoWhile.java new file mode 100644 index 0000000..16f6783 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/DoWhile.java @@ -0,0 +1,23 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class DoWhile implements Statement { + private Block block; + private Expression cond; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Field.java b/src/main/java/de/maishai/typedast/typedclass/Field.java index 7f7821c..b0710bb 100644 --- a/src/main/java/de/maishai/typedast/typedclass/Field.java +++ b/src/main/java/de/maishai/typedast/typedclass/Field.java @@ -8,7 +8,7 @@ import java.util.Map; @Data public class Field implements Node { - private String name; + private Id id; private Type type; @Override diff --git a/src/main/java/de/maishai/typedast/typedclass/FieldId.java b/src/main/java/de/maishai/typedast/typedclass/FieldId.java new file mode 100644 index 0000000..d3b26db --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/FieldId.java @@ -0,0 +1,23 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class FieldId implements Node { + private Boolean field; + private Expression recipient; + private Id id; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/For.java b/src/main/java/de/maishai/typedast/typedclass/For.java new file mode 100644 index 0000000..d0b6913 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/For.java @@ -0,0 +1,26 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; + +@Data +public class For implements Statement { + private Expression assign; + private Expression cond; + private Expression inc; + private Block block; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Id.java b/src/main/java/de/maishai/typedast/typedclass/Id.java new file mode 100644 index 0000000..ab5a140 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Id.java @@ -0,0 +1,23 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; + +@Data +public class Id implements Expression { + private String name; + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/IfElse.java b/src/main/java/de/maishai/typedast/typedclass/IfElse.java new file mode 100644 index 0000000..5639b1d --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/IfElse.java @@ -0,0 +1,25 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; + +@Data +public class IfElse implements Statement { + private Expression cond; + private Block ifBlock; + private Block elseBlock; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/IntLiteral.java b/src/main/java/de/maishai/typedast/typedclass/IntLiteral.java new file mode 100644 index 0000000..9f6b8d3 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/IntLiteral.java @@ -0,0 +1,22 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; + +@Data +public class IntLiteral implements Expression { + private Integer value; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/LocalVariable.java b/src/main/java/de/maishai/typedast/typedclass/LocalVariable.java new file mode 100644 index 0000000..349e3e2 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/LocalVariable.java @@ -0,0 +1,22 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class LocalVariable implements Node { + private Id name; + private Type type; + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/MainMethod.java b/src/main/java/de/maishai/typedast/typedclass/MainMethod.java new file mode 100644 index 0000000..331022f --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/MainMethod.java @@ -0,0 +1,22 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; + +@Data +public class MainMethod implements Node { + private Block block; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} + diff --git a/src/main/java/de/maishai/typedast/typedclass/MethodCall.java b/src/main/java/de/maishai/typedast/typedclass/MethodCall.java new file mode 100644 index 0000000..50a5a9d --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/MethodCall.java @@ -0,0 +1,28 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class MethodCall implements Expression, Statement { + private Boolean field; + private Expression recipient; + private Id id; + private List args; + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/New.java b/src/main/java/de/maishai/typedast/typedclass/New.java new file mode 100644 index 0000000..8942427 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/New.java @@ -0,0 +1,25 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class New implements Expression, Statement { + private Type type; + private List args; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Program.java b/src/main/java/de/maishai/typedast/typedclass/Program.java new file mode 100644 index 0000000..4e788da --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Program.java @@ -0,0 +1,22 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class Program implements Node { + private List classes; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Return.java b/src/main/java/de/maishai/typedast/typedclass/Return.java new file mode 100644 index 0000000..26dc908 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Return.java @@ -0,0 +1,24 @@ +package de.maishai.typedast.typedclass; + + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class Return implements Statement { + private Expression ret; + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/ReturnVoid.java b/src/main/java/de/maishai/typedast/typedclass/ReturnVoid.java new file mode 100644 index 0000000..fa55836 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/ReturnVoid.java @@ -0,0 +1,21 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class ReturnVoid implements Statement { + + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/Unary.java b/src/main/java/de/maishai/typedast/typedclass/Unary.java new file mode 100644 index 0000000..d7bed41 --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/Unary.java @@ -0,0 +1,23 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.ast.UnaryOperator; +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; +@Data +public class Unary implements Expression { + private UnaryOperator op; + private Expression right; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +} diff --git a/src/main/java/de/maishai/typedast/typedclass/While.java b/src/main/java/de/maishai/typedast/typedclass/While.java new file mode 100644 index 0000000..7c4842e --- /dev/null +++ b/src/main/java/de/maishai/typedast/typedclass/While.java @@ -0,0 +1,24 @@ +package de.maishai.typedast.typedclass; + +import de.maishai.typedast.Expression; +import de.maishai.typedast.Node; +import de.maishai.typedast.Statement; +import de.maishai.typedast.Type; +import lombok.Data; + +import java.util.Map; + +@Data +public class While implements Statement { + private Expression cond; + private Block block; + @Override + public Type typeCheck(Map localVar, Map classes) { + return null; + } + + @Override + public Node convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node c) { + return null; + } +}