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() { public void testMain() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Main.get()); TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Main.get());
assertEquals(TypedAST_Main.get(), resultTypedAst); 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 @Test
public void testMethod() { public void testMethod() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,7 @@
package testResources.TypedAST.TypedASTFeatures; package testResources.TypedAST.TypedASTFeatures;
import de.maishai.typedast.Type; import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.TypedBlock; import de.maishai.typedast.typedclass.*;
import de.maishai.typedast.typedclass.TypedClass;
import de.maishai.typedast.typedclass.TypedConstructor;
import de.maishai.typedast.typedclass.TypedProgram;
import jdk.jshell.spi.ExecutionControl;
import java.util.List; import java.util.List;
@ -14,22 +11,6 @@ public class TypedAST_Main {
List.of( List.of(
new TypedClass( new TypedClass(
"Main", "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(), List.of(),
List.of( List.of(
@ -45,6 +26,41 @@ public class TypedAST_Main {
List.of() 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,
null, null,
Type.REFERENCE("Main") Type.REFERENCE("Main")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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