adapted to Implementation of main in TypedAST

This commit is contained in:
JonathanFleischmann 2024-06-23 14:47:22 +02:00
parent f0ca5324d8
commit 9cda095a0b
52 changed files with 90 additions and 26 deletions

View File

@ -127,12 +127,8 @@ public class TypingTests {
public void testMain() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Main.get());
assertEquals(TypedAST_Main.get(), resultTypedAst);
try {
throw new ExecutionControl.NotImplementedException("Main Class not yet implemented in TypedAST");
} catch (ExecutionControl.NotImplementedException e) {
throw new RuntimeException(e);
}
}
// TODO: Wie soll das Resultat aussehen? Soll tatsächlich main auch als Methode aufgeführt werden?
@Test
public void testMethod() {

View File

@ -13,6 +13,7 @@ public class AST_Break {
List.of(
new Class(
"Break",
null,
List.of(),
List.of(),
List.of(

View File

@ -13,6 +13,7 @@ public class AST_Class {
List.of(
new Class(
"Class",
null,
List.of(),
List.of(),
List.of(

View File

@ -12,6 +12,7 @@ public class AST_ClassObjects {
List.of(
new Class(
"ClassObjects",
null,
List.of(
new Declaration(
"b",

View File

@ -13,6 +13,7 @@ public class AST_Comment {
List.of(
new Class(
"Comment",
null,
List.of(),
List.of(),
List.of(

View File

@ -13,6 +13,7 @@ public class AST_CompAssign {
List.of(
new Class(
"CompAssign",
null,
List.of(),
List.of(
new Method(

View File

@ -12,6 +12,7 @@ public class AST_ComplexCalls {
List.of(
new Class(
"ComplexCalls",
null,
List.of(
new Declaration(
"classObject",

View File

@ -14,6 +14,7 @@ public class AST_Constructor {
List.of(
new Class(
"Constructor",
null,
List.of(),
List.of(),
List.of(

View File

@ -13,6 +13,7 @@ public class AST_Continue {
List.of(
new Class(
"Continue",
null,
List.of(),
List.of(
new Method(

View File

@ -13,6 +13,7 @@ public class AST_DataTypes {
List.of(
new Class(
"DataTypes",
null,
List.of(
new Declaration(
"x",

View File

@ -12,6 +12,7 @@ public class AST_Field {
List.of(
new Class(
"Field",
null,
List.of(
new Declaration(
"x",

View File

@ -13,6 +13,7 @@ public class AST_For {
List.of(
new Class(
"For",
null,
List.of(),
List.of(
new Method(

View File

@ -12,6 +12,7 @@ public class AST_If {
List.of(
new Class(
"If",
null,
List.of(),
List.of(
new Method(

View File

@ -13,6 +13,7 @@ public class AST_LogicExpr {
List.of(
new Class(
"LogicExpr",
null,
List.of(),
List.of(
new Method(

View File

@ -12,6 +12,7 @@ public class AST_Method {
List.of(
new Class(
"Method",
null,
List.of(),
List.of(
new Method(

View File

@ -13,6 +13,7 @@ public class AST_MethodCall {
List.of(
new Class(
"MethodCall",
null,
List.of(),
List.of(
new Method(

View File

@ -12,6 +12,7 @@ public class AST_MultipleClasses {
List.of(
new Class(
"MultipleClasses",
null,
List.of(
new Declaration(
"anotherClass",
@ -43,6 +44,7 @@ public class AST_MultipleClasses {
),
new Class(
"AnotherClass",
null,
List.of(
new Declaration(
"multipleClasses",

View File

@ -14,6 +14,7 @@ public class AST_Operators {
List.of(
new Class(
"Operators",
null,
List.of(),
List.of(
new Method(

View File

@ -13,6 +13,7 @@ public class AST_Overloaded {
List.of(
new Class(
"Overloaded",
null,
List.of(),
List.of(
new Method(

View File

@ -13,6 +13,7 @@ public class AST_Print {
List.of(
new Class(
"Print",
null,
List.of(),
List.of(
new Method(

View File

@ -12,6 +12,7 @@ public class AST_Return {
List.of(
new Class(
"Return",
null,
List.of(),
List.of(
new Method(

View File

@ -13,6 +13,7 @@ public class AST_Unary {
List.of(
new Class(
"Unary",
null,
List.of(),
List.of(),
List.of(

View File

@ -12,6 +12,7 @@ public class AST_VariableDefWithDecl {
List.of(
new Class(
"VariableDefWithDecl",
null,
List.of(),
List.of(),
List.of(

View File

@ -13,6 +13,7 @@ public class AST_While {
List.of(
new Class(
"While",
null,
List.of(),
List.of(
new Method(

View File

@ -135,6 +135,7 @@ public class TypedAST_Break {
),
null,
null,
null,
Type.REFERENCE("Break")
)
),

View File

@ -31,6 +31,7 @@ public class TypedAST_Class {
),
null,
null,
null,
Type.REFERENCE("Class")
)
),

View File

@ -117,6 +117,7 @@ public class TypedAST_ClassObjects {
),
null,
null,
null,
Type.REFERENCE("ClassObjects")
)
),

View File

@ -31,6 +31,7 @@ public class TypedAST_Comment {
),
null,
null,
null,
Type.REFERENCE("Comment")
)
),

View File

@ -275,6 +275,7 @@ public class TypedAST_CompAssign {
),
null,
null,
null,
Type.REFERENCE("CompAssign")
)
),

View File

@ -229,6 +229,7 @@ public class TypedAST_ComplexCalls {
),
null,
null,
null,
Type.REFERENCE("ComplexCalls")
)
),

View File

@ -149,6 +149,7 @@ public class TypedAST_Constructor {
),
null,
null,
null,
Type.REFERENCE("Constructor")
)
),

View File

@ -136,6 +136,7 @@ public class TypedAST_Continue {
),
null,
null,
null,
Type.REFERENCE("Continue")
)
),

View File

@ -174,6 +174,7 @@ public class TypedAST_DataTypes {
),
null,
null,
null,
Type.REFERENCE("DataTypes")
)
),

View File

@ -76,6 +76,7 @@ public class TypedAST_Field {
),
null,
null,
null,
Type.REFERENCE("Field")
)
),

View File

@ -166,6 +166,7 @@ public class TypedAST_For {
),
null,
null,
null,
Type.REFERENCE("For")
)
),

View File

@ -78,6 +78,7 @@ public class TypedAST_If {
),
null,
null,
null,
Type.REFERENCE("If")
)
),

View File

@ -558,6 +558,7 @@ public class TypedAST_LogicExpr {
),
null,
null,
null,
Type.REFERENCE("LogicExpr")
)
),

View File

@ -1,10 +1,7 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.TypedBlock;
import de.maishai.typedast.typedclass.TypedClass;
import de.maishai.typedast.typedclass.TypedConstructor;
import de.maishai.typedast.typedclass.TypedProgram;
import jdk.jshell.spi.ExecutionControl;
import de.maishai.typedast.typedclass.*;
import java.util.List;
@ -14,22 +11,6 @@ public class TypedAST_Main {
List.of(
new TypedClass(
"Main",
// new Block(
// List.of(
// new Declaration(
// "i",
// Type.INT
// ),
// new Assignment(
// new FieldVarAccess(
// false,
// null,
// "i"
// ),
// new IntLiteral(0)
// )
// )
// ),
List.of(),
List.of(),
List.of(
@ -45,6 +26,41 @@ public class TypedAST_Main {
List.of()
)
),
new TypedMain(
Type.VOID,
new TypedMethod(
"main",
Type.VOID,
List.of(),
List.of(),
new TypedBlock(
List.of(
new TypedLocalVariable(
"i",
Type.INT
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
0,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
)
),
Type.VOID
)
)
),
null,
null,
Type.REFERENCE("Main")

View File

@ -40,6 +40,7 @@ public class TypedAST_Method {
),
null,
null,
null,
Type.REFERENCE("Method")
)
),

View File

@ -204,6 +204,7 @@ public class TypedAST_MethodCall {
),
null,
null,
null,
Type.REFERENCE("MethodCall")
)
),

View File

@ -47,6 +47,7 @@ public class TypedAST_MultipleClasses {
),
null,
null,
null,
Type.REFERENCE("MultipleClasses")
),
new TypedClass(
@ -87,6 +88,7 @@ public class TypedAST_MultipleClasses {
),
null,
null,
null,
Type.REFERENCE("AnotherClass")
)
),

View File

@ -437,6 +437,7 @@ public class TypedAST_Operators {
),
null,
null,
null,
Type.REFERENCE("Operators")
)
),

View File

@ -115,6 +115,7 @@ public class TypedAST_Overloaded {
),
null,
null,
null,
Type.REFERENCE("Overloaded")
)
),

View File

@ -96,6 +96,7 @@ public class TypedAST_Print {
),
null,
null,
null,
Type.REFERENCE("Print")
)
),

View File

@ -122,6 +122,7 @@ public class TypedAST_Return {
),
null,
null,
null,
Type.REFERENCE("Return")
)
),

View File

@ -95,6 +95,7 @@ public class TypedAST_Unary {
),
null,
null,
null,
Type.REFERENCE("Unary")
)
),

View File

@ -66,6 +66,7 @@ public class TypedAST_VariableDefWithDecl {
),
null,
null,
null,
Type.REFERENCE("VariableDefWithDecl")
)
),

View File

@ -182,6 +182,7 @@ public class TypedAST_While {
),
null,
null,
null,
Type.REFERENCE("While")
)
),

View File

@ -35,6 +35,7 @@ public class TypedAbstractSyntax_ClassWithConstructor {
getConstructors(),
null,
null,
null,
Type.REFERENCE("ClassWithConstructor")
)
),

View File

@ -36,6 +36,7 @@ public class TypedAbstractSyntax_ClassWithField {
),
null,
null,
null,
Type.REFERENCE("ClassWithField")
)
),

View File

@ -118,6 +118,7 @@ public class TypedAbstractSyntax_ComplexClass {
getConstructors(),
null,
null,
null,
Type.REFERENCE("ComplexClass")
);
}

View File

@ -29,6 +29,7 @@ public class TypedAbstractSyntax_PublicClass {
),
null,
null,
null,
Type.REFERENCE("PublicClass")
)
),