working on translating testfiles into AST and then into TypedAST

This commit is contained in:
JonathanFleischmann 2024-06-22 17:16:10 +02:00
parent b3ce4b5ff8
commit 81590c62c5
92 changed files with 2215 additions and 93 deletions

View File

@ -1,5 +0,0 @@
package testfiles.ASTFeatures;
public class AST_MultipleClasses {
}

View File

@ -1,8 +1,8 @@
import de.maishai.Compiler;
import de.maishai.ast.records.Program;
import org.junit.jupiter.api.Test;
import testfiles.ASTFeatures.*;
import testfiles.ASTMore.*;
import testResources.AST.ASTFeatures.*;
import testResources.AST.ASTMore.*;
import java.util.List;
@ -12,56 +12,56 @@ public class ScannerParserTests {
@Test
public void testPublicClass() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/PublicClass.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/PublicClass.java"));
assertEquals(AbstractSyntax_PublicClass.get(), resultAst);
}
@Test
public void testClassWithField() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithField.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithField.java"));
assertEquals(AbstractSyntax_ClassWithField.get(), resultAst);
}
@Test
public void testClassWithConstructor() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructor.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructor.java"));
assertEquals(AbstractSyntax_ClassWithConstructor.get(), resultAst);
}
@Test
public void testClassWithMethod() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithMethod.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithMethod.java"));
assertEquals(AbstractSyntax_ClassWithMethod.get(), resultAst);
}
@Test
public void testClassWithConstructorWithCodeInComments() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructorWithCodeInComments.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithCodeInComments.java"));
assertEquals(AbstractSyntax_ClassWithConstructorWithCodeInComments.get(), resultAst);
}
@Test
public void testClassWithConstructorWithParameters() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructorWithParameters.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorWithParameters.java"));
assertEquals(AbstractSyntax_ClassWithConstructorWithParameters.get(), resultAst);
}
// @Test
// public void testClassWithMethodAndField() {
// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithMethodAndField.java"));
// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithMethodAndField.java"));
// assertEquals(AbstractSyntax_ClassWithMethodAndField.get(), resultAst);
// }
//TODO: fix
@Test
public void testClassWithConstructorAndMethodCall() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ClassWithConstructorAndMethodCall.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ClassWithConstructorAndMethodCall.java"));
assertEquals(AbstractSyntax_ClassWithConstructorAndMethodCall.get(), resultAst);
}
@Test
public void testComplexClass() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfiles/ComplexClass.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesMore/ComplexClass.java"));
assertEquals(AbstractSyntax_ComplexClass.get(), resultAst);
}
@ -69,74 +69,74 @@ public class ScannerParserTests {
@Test
public void testClass() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Class.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Class.java"));
assertEquals(AST_Class.get(), resultAst);
}
// @Test
// public void testClassObjects() {
// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/ClassObjects.java"));
// assertEquals(AST_ClassObjects.get(), resultAst);
// }
//TODO: fix
@Test
public void testClassObjects() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/ClassObjects.java"));
assertEquals(AST_ClassObjects.get(), resultAst);
}
//TODO: nochmal drüberschauen, nachfragen wegen true/false bei FieldVarAccess
@Test
public void testComment() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Comment.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Comment.java"));
assertEquals(AST_Comment.get(), resultAst);
}
@Test
public void testConstructor() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Constructor.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Constructor.java"));
assertEquals(AST_Constructor.get(), resultAst);
}
@Test
public void testContinue() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Continue.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Continue.java"));
assertEquals(AST_Continue.get(), resultAst);
}
@Test
public void testField() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Field.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Field.java"));
assertEquals(AST_Field.get(), resultAst);
}
@Test
public void testFor() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/For.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/For.java"));
assertEquals(AST_For.get(), resultAst);
}
@Test
public void testIf() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/If.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/If.java"));
assertEquals(AST_If.get(), resultAst);
}
// @Test
// public void testIncrDecr() {
// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/IncrDecr.java"));
// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/IncrDecr.java"));
// assertEquals(AST_IncrDecr.get(), resultAst);
// }
@Test
public void testLogicExpr() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/LogicExpr.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/LogicExpr.java"));
assertEquals(AST_LogicExpr.get(), resultAst);
}
@Test
public void testMethod() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Method.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Method.java"));
assertEquals(AST_Method.get(), resultAst);
}
@Test
public void testMethodCall() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/MethodCall.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/MethodCall.java"));
assertEquals(AST_MethodCall.get(), resultAst);
}
@ -144,39 +144,39 @@ public class ScannerParserTests {
@Test
public void testOperators() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Operators.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Operators.java"));
assertEquals(AST_Operators.get(), resultAst);
}
@Test
public void testOverloaded() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Overloaded.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Overloaded.java"));
assertEquals(AST_Overloaded.get(), resultAst);
}
// @Test
// public void testPrint() {
// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Print.java"));
// assertEquals(AST_Print.get(), resultAst);
// }
@Test
public void testPrint() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Print.java"));
assertEquals(AST_Print.get(), resultAst);
}
//TODO: fix
// @Test
// public void testReturn() {
// Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/Return.java"));
// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Return.java"));
// assertEquals(AST_Return.get(), resultAst);
// }
//TODO: fix
@Test
public void testVariableDefWithDecl() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/VariableDefWithDecl.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/VariableDefWithDecl.java"));
assertEquals(AST_VariableDefWithDecl.get(), resultAst);
}
@Test
public void testWhile() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/main/resources/JavaTestfilesFeatures/While.java"));
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/While.java"));
assertEquals(AST_While.get(), resultAst);
}
}

View File

@ -1,9 +1,16 @@
import de.maishai.Compiler;
import de.maishai.typedast.typedclass.TypedProgram;
import org.junit.jupiter.api.Test;
import testfiles.ASTFeatures.*;
import testfiles.ASTMore.*;
import testfiles.TypedASTMore.*;
import testResources.typedAST.TypedASTFeatures.*;
import testResources.AST.ASTFeatures.*;
import testResources.AST.ASTMore.AbstractSyntax_ClassWithConstructor;
import testResources.AST.ASTMore.AbstractSyntax_ClassWithField;
import testResources.AST.ASTMore.AbstractSyntax_ComplexClass;
import testResources.AST.ASTMore.AbstractSyntax_PublicClass;
import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_ClassWithConstructor;
import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_ClassWithField;
import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_ComplexClass;
import testResources.typedAST.TypedASTMore.TypedAbstractSyntax_PublicClass;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -27,9 +34,127 @@ public class TypingTests {
assertEquals(TypedAbstractSyntax_ClassWithConstructor.get(), resultTypedAst);
}
// @Test
// public void testComplexClass() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_ComplexClass.get());
// assertEquals(TypedAbstractSyntax_ComplexClass.get(), resultTypedAst);
// }
@Test
public void testComplexClass() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AbstractSyntax_ComplexClass.get());
assertEquals(TypedAbstractSyntax_ComplexClass.get(), resultTypedAst);
public void testClass() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Class.get());
assertEquals(TypedAST_Class.get(), resultTypedAst);
}
@Test
public void testClassObjects() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_ClassObjects.get());
assertEquals(TypedAST_ClassObjects.get(), resultTypedAst);
}
@Test
public void testComment() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Comment.get());
assertEquals(TypedAST_Comment.get(), resultTypedAst);
}
@Test
public void testConstructor() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Constructor.get());
assertEquals(TypedAST_Constructor.get(), resultTypedAst);
}
//
// @Test
// public void testContinue() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Continue.get());
// assertEquals(TypedAST_Continue.get(), resultTypedAst);
// }
//
// @Test
// public void testField() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Field.get());
// assertEquals(TypedAST_Field.get(), resultTypedAst);
// }
//
// @Test
// public void testFor() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_For.get());
// assertEquals(TypedAST_For.get(), resultTypedAst);
// }
//
// @Test
// public void testIf() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(testResources.AST.ASTFeatures.AST_If.get());
// assertEquals(TypedAST_If.get(), resultTypedAst);
// }
//
// @Test
// public void testIncrDecr() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_IncrDecr.get());
// assertEquals(TypedAST_IncrDecr.get(), resultTypedAst);
// }
//TODO: fix
//
// @Test
// public void testLogicExpr() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_LogicExpr.get());
// assertEquals(TypedAST_LogicExpr.get(), resultTypedAst);
// }
//
// @Test
// public void testMethod() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Method.get());
// assertEquals(TypedAST_Method.get(), resultTypedAst);
// }
//
// @Test
// public void testMethodCall() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_MethodCall.get());
// assertEquals(TypedAST_MethodCall.get(), resultTypedAst);
// }
//
// @Test
// public void testMultipleClasses() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_MultipleClasses.get());
// assertEquals(TypedAST_MultipleClasses.get(), resultTypedAst);
// }
// // TODO: Implement
//
// @Test
// public void testOperators() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Operators.get());
// assertEquals(TypedAST_Operators.get(), resultTypedAst);
// }
//
// @Test
// public void testOverloaded() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Overloaded.get());
// assertEquals(TypedAST_Overloaded.get(), resultTypedAst);
// }
//
// @Test
// public void testPrint() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Print.get());
// assertEquals(TypedAST_Print.get(), resultTypedAst);
// }
//TODO: fix
//
// @Test
// public void testReturn() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Return.get());
// assertEquals(TypedAST_Return.get(), resultTypedAst);
// }
//TODO: fix
//
// @Test
// public void testVariableDefWithDecl() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_VariableDefWithDecl.get());
// assertEquals(TypedAST_VariableDefWithDecl.get(), resultTypedAst);
// }
//
// @Test
// public void testWhile() {
// TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_While.get());
// assertEquals(TypedAST_While.get(), resultTypedAst);
// }
}

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.Block;
import de.maishai.ast.records.Constructor;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;
@ -14,8 +14,8 @@ public class AST_ClassObjects {
"ClassObjects",
List.of(
new Declaration(
"c",
Type.CHAR
"b",
Type.REFERENCE("ClassObjects")
)
),
getMethods(),
@ -66,19 +66,29 @@ public class AST_ClassObjects {
"d",
Type.REFERENCE("ClassObjects")
),
new Assignment(
new FieldVarAccess(
false,
null,
"d"),
new New(
Type.REFERENCE("ClassObjects"),
List.of()
)
),
new Assignment(
new FieldVarAccess(
false,
null,
"c"),
new FieldVarAccess(
true,
false,
new FieldVarAccess(
true,
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"d"),
"b"),
@ -93,7 +103,7 @@ public class AST_ClassObjects {
new FieldVarAccess(
true,
new FieldVarAccess(
false,
true,
null,
"c"),
"b"),

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.Block;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -0,0 +1,5 @@
package testResources.AST.ASTFeatures;
public class AST_MultipleClasses {
}

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testfiles.ASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithConstructor {
package testResources.AST.ASTMore;//public class ClassWithConstructor {
// int x;
// public classWithConstructor() {
// this.x = 10;

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithConstructorAndMethodCall {
package testResources.AST.ASTMore;//public class ClassWithConstructorAndMethodCall {
// int x;
//
// public ClassWithConstructorAndMethodCall() {

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithConstructorWithCodeInComments {
package testResources.AST.ASTMore;//public class ClassWithConstructorWithCodeInComments {
// int x;
// public ClassWithConstructorWithCodeInComments() {
// this.x = 10;

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithConstructorWithParameters {
package testResources.AST.ASTMore;//public class ClassWithConstructorWithParameters {
// int x;
// public ClassWithConstructorWithParameters(int startValue, int repetitions) {
// this.x = startValue;

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithField {
package testResources.AST.ASTMore;//public class ClassWithField {
// int x;
//}

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithMethod {
package testResources.AST.ASTMore;//public class ClassWithMethod {
// public boolean method() {
// return false;
// }

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithMethodAndField {
package testResources.AST.ASTMore;//public class ClassWithMethodAndField {
// char c;
//
// public ClassWithMethodAndField(char character) {

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ClassWithMoreComplexMethodAndMain {
package testResources.AST.ASTMore;//public class ClassWithMoreComplexMethodAndMain {
// ClassWithMoreComplexMethodAndMain instance;
//
// public boolean moreComplexMethod() {

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class ComplexClass {
package testResources.AST.ASTMore;//public class ComplexClass {
//
// int x;
// int y;

View File

@ -1,4 +1,4 @@
package testfiles.ASTMore;//public class PublicClass {
package testResources.AST.ASTMore;//public class PublicClass {
//}
import de.maishai.ast.records.Block;

View File

@ -0,0 +1,40 @@
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 java.util.List;
public class TypedAST_Class {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"Class",
List.of(),
List.of(),
List.of(
new TypedConstructor(
"Class",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("Class")
)
),
null
);
}
}

View File

@ -0,0 +1,163 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_ClassObjects {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"ClassObjects",
List.of(
new TypedDeclaration(
"b",
Type.REFERENCE("ClassObjects")
)
),
List.of(
new TypedMethod(
"objectsMethod",
Type.VOID,
List.of(),
List.of(new TypedLocalVariable(
"c",
Type.REFERENCE("ClassObjects")
),
new TypedLocalVariable(
"d",
Type.REFERENCE("ClassObjects")
)
),
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedNew(
Type.REFERENCE("ClassObjects"),
List.of()
),
new TypedFieldVarAccess(
true,
null,
"b",
Type.REFERENCE("ClassObjects")),
Type.VOID
),
new TypedAssignment(
new TypedNew(
Type.REFERENCE("ClassObjects"),
List.of(
new TypedIntLiteral(2)
)
),
new TypedFieldVarAccess(
false,
null,
"c",
Type.REFERENCE("ClassObjects")),
Type.VOID
),
new TypedAssignment(
new TypedNew(
Type.REFERENCE("ClassObjects"),
List.of()
),
new TypedFieldVarAccess(
false,
null,
"d",
Type.REFERENCE("ClassObjects")),
Type.VOID
),
new TypedAssignment(
new TypedFieldVarAccess(
false,
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
true,
null,
"d",
Type.REFERENCE("ClassObjects")),
"b",
Type.REFERENCE("ClassObjects")),
"b",
Type.REFERENCE("ClassObjects")),
"b",
Type.REFERENCE("ClassObjects")),
new TypedFieldVarAccess(
false,
null,
"c",
Type.REFERENCE("ClassObjects")),
Type.VOID
),
new TypedMethodCall(
new TypedFieldVarAccess(
false,
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
true,
null,
"c",
Type.REFERENCE("ClassObjects")),
"b",
Type.REFERENCE("ClassObjects")),
"b",
Type.REFERENCE("ClassObjects")),
"objectsMethod",
Type.VOID),
List.of(),
Type.VOID
)
),
Type.VOID
)
)
),
List.of(
new TypedConstructor(
"ClassObjects",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.REFERENCE("ClassObjects"),
List.of()
),
new TypedConstructor(
"ClassObjects",
List.of(
new TypedParameter(
"a",
Type.INT
)
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.REFERENCE("ClassObjects"),
List.of()
)
),
null,
null,
Type.REFERENCE("ClassObjects")
)
),
null
);
}
}

View File

@ -0,0 +1,44 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.records.Block;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.Constructor;
import de.maishai.ast.records.Program;
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 java.util.List;
public class TypedAST_Comment {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"Comment",
List.of(),
List.of(),
List.of(
new TypedConstructor(
"Comment",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("Comment")
)
),
null
);
}
}

View File

@ -0,0 +1,146 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_Constructor {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"Constructor",
List.of(),
List.of(),
List.of(
new TypedConstructor(
"Constructor",
List.of(),
new TypedBlock(
List.of(
new TypedLocalVariable(
"i",
Type.INT
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
1,
Type.INT),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
)
),
Type.VOID
),
Type.VOID,
List.of()
),
new TypedConstructor(
"Constructor",
List.of(
new TypedParameter(
"x",
Type.INT
)
),
new TypedBlock(
List.of(
new TypedLocalVariable(
"i",
Type.INT
)
),
List.of(
new TypedAssignment(
new TypedFieldVarAccess(
false,
null,
"x",
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
)
),
Type.VOID
),
Type.VOID,
List.of()
),
new TypedConstructor(
"Constructor",
List.of(
new TypedParameter(
"x",
Type.INT
),
new TypedParameter(
"y",
Type.INT
)
),
new TypedBlock(
List.of(
new TypedLocalVariable(
"i",
Type.INT
)
),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x",
Type.INT
),
Operator.ADD,
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
)
),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("Constructor")
)
),
null
);
}
}

View File

@ -0,0 +1,103 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Continue {
public static Program get() {
return new Program(
List.of(
new Class(
"Continue",
List.of(),
List.of(
new Method(
Type.VOID,
"continueLoop",
List.of(),
new Block(
List.of(
new Declaration(
"i",
Type.INT
),
new For(
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new IntLiteral(0)
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.LT,
new IntLiteral(5)
),
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.ADD,
new IntLiteral(1)
)
),
new Block(
List.of(
new IfElse(
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.EQ,
new IntLiteral(3)
),
new Block(
List.of(
new Continue()
)
),
null
)
)
)
)
)
)
)
),
List.of(
new Constructor(
"Continue",
List.of(),
new Block(
List.of(
)
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,66 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Field {
public static Program get() {
return new Program(
List.of(
new Class(
"Field",
List.of(
new Declaration(
"x",
Type.INT
),
new Declaration(
"c",
Type.CHAR
)
),
List.of(
new Method(
Type.VOID,
"fieldAccess",
List.of(),
new Block(
List.of(
new Assignment(
new FieldVarAccess(
true,
null,
"x"
),
new IntLiteral(0)
),
new Assignment(
new FieldVarAccess(
true,
null,
"c"
),
new CharLiteral('a')
)
)
)
)
),
List.of(
new Constructor(
"Field",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,127 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_For {
public static Program get() {
return new Program(
List.of(
new Class(
"For",
List.of(),
List.of(
new Method(
Type.VOID,
"testFor",
List.of(),
new Block(
List.of(
new Declaration(
"i",
Type.INT
),
new For(
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new IntLiteral(0)
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.LT,
new IntLiteral(10)
),
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.ADD,
new IntLiteral(1)
)
),
new Block(
List.of()
)
),
new Declaration(
"j",
Type.INT
),
new For(
new Assignment(
new FieldVarAccess(
false,
null,
"j"
),
new IntLiteral(0)
),
new Binary(
new FieldVarAccess(
false,
null,
"j"
),
Operator.LT,
new IntLiteral(10)
),
new Assignment(
new FieldVarAccess(
false,
null,
"j"
),
new Binary(
new FieldVarAccess(
false,
null,
"j"
),
Operator.ADD,
new IntLiteral(1)
)
),
new Block(
List.of()
)
)
)
)
)
),
List.of(
new Constructor(
"For",
List.of(),
new Block(
List.of(
)
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,61 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_If {
public static Program get() {
return new Program(
List.of(
new Class(
"If",
List.of(),
List.of(
new Method(
Type.VOID,
"ifMethod",
List.of(),
new Block(
List.of(
new IfElse(
new BoolLiteral(false),
new Block(
List.of()
),
new Block(
List.of(
new IfElse(
new BoolLiteral(true),
new Block(
List.of()
),
new Block(
List.of()
)
)
)
)
)
)
)
)
),
List.of(
new Constructor(
"If",
List.of(),
new Block(
List.of(
)
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,86 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_IncrDecr {
public static Program get() {
return new Program(
List.of(
new Class(
"IncrDecr",
List.of(),
List.of(
new Method(
Type.INT,
"increment",
List.of(
new Parameter(
"a",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.ADD,
new IntLiteral(
1
)
)
)
)
)
),
new Method(
Type.INT,
"decrement",
List.of(
new Parameter(
"a",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"a"
),
Operator.SUB,
new IntLiteral(
1
)
)
)
)
)
)
),
List.of(
new Constructor(
"IncrDecr",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,332 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_LogicExpr {
public static Program get() {
return new Program(
List.of(
new Class(
"LogicExpr",
List.of(),
List.of(
new Method(
Type.BOOL,
"test",
List.of(),
new Block(
List.of(
new Declaration(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"y"
),
new IntLiteral(20)
),
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.LT,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
),
new Method(
Type.BOOL,
"test2",
List.of(),
new Block(
List.of(
new Declaration(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"y"
),
new IntLiteral(20)
),
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.GT,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
),
new Method(
Type.BOOL,
"test3",
List.of(),
new Block(
List.of(
new Declaration(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"y"
),
new IntLiteral(20)
),
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.EQ,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
),
new Method(
Type.BOOL,
"test4",
List.of(),
new Block(
List.of(
new Declaration(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"y"
),
new IntLiteral(20)
),
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.NE,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
),
new Method(
Type.BOOL,
"test5",
List.of(),
new Block(
List.of(
new Declaration(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"y"
),
new IntLiteral(20)
),
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.LE,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
),
new Method(
Type.BOOL,
"test6",
List.of(),
new Block(
List.of(
new Declaration(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"y"
),
new IntLiteral(20)
),
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.GE,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
)
),
List.of(
new Constructor(
"LogicExpr",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,39 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Method {
public static Program get() {
return new Program(
List.of(
new Class(
"Method",
List.of(),
List.of(
new Method(
Type.VOID,
"method",
List.of(),
new Block(
List.of()
)
)
),
List.of(
new Constructor(
"Method",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,160 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_MethodCall {
public static Program get() {
return new Program(
List.of(
new Class(
"MethodCall",
List.of(),
List.of(
new Method(
Type.INT,
"methodCall",
List.of(),
new Block(
List.of(
new Return(
new MethodCall(
new FieldVarAccess(
false,
null,
"method"
),
List.of()
)
)
)
)
),
new Method(
Type.INT,
"methodCall1",
List.of(),
new Block(
List.of(
new Return(
new MethodCall(
new FieldVarAccess(
false,
null,
"method1"
),
List.of(
new IntLiteral(1)
)
)
)
)
)
),
new Method(
Type.INT,
"methodCall2",
List.of(),
new Block(
List.of(
new Return(
new MethodCall(
new FieldVarAccess(
false,
null,
"method2"
),
List.of(
new IntLiteral(1),
new IntLiteral(2)
)
)
)
)
)
),
new Method(
Type.INT,
"method",
List.of(),
new Block(
List.of(
new Return(
new IntLiteral(0)
)
)
)
),
new Method(
Type.INT,
"method1",
List.of(
new Parameter(
"x",
Type.INT
)
),
new Block(
List.of(
new Return(
new FieldVarAccess(
false,
null,
"x"
)
)
)
)
),
new Method(
Type.INT,
"method2",
List.of(
new Parameter(
"x",
Type.INT
),
new Parameter(
"y",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.ADD,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
)
),
List.of(
new Constructor(
"MethodCall",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,5 @@
package testResources.typedAST.TypedASTFeatures;
public class TypedAST_MultipleClasses {
}

View File

@ -0,0 +1,198 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Operators {
public static Program get() {
return new Program(
List.of(
new Class(
"Operators",
List.of(),
List.of(
new Method(
Type.INT,
"add",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"a"
),
Operator.ADD,
new FieldVarAccess(
false,
null,
"b"
)
)
)
)
)
),
new Method(
Type.INT,
"sub",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"a"
),
Operator.SUB,
new FieldVarAccess(
false,
null,
"b"
)
)
)
)
)
),
new Method(
Type.INT,
"mul",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"a"
),
Operator.MUL,
new FieldVarAccess(
false,
null,
"b"
)
)
)
)
)
),
new Method(
Type.INT,
"div",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"a"
),
Operator.DIV,
new FieldVarAccess(
false,
null,
"b"
)
)
)
)
)
),
new Method(
Type.INT,
"mod",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"a"
),
Operator.MOD,
new FieldVarAccess(
false,
null,
"b"
)
)
)
)
)
)
),
List.of(
new Constructor(
"Operators",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,98 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Overloaded {
public static Program get() {
return new Program(
List.of(
new Class(
"Overloaded",
List.of(),
List.of(
new Method(
Type.INT,
"overloadedMethod",
List.of(),
new Block(
List.of(
new Return(
new IntLiteral(0)
)
)
)
),
new Method(
Type.INT,
"overloadedMethod",
List.of(
new Parameter(
"x",
Type.INT
)
),
new Block(
List.of(
new Return(
new FieldVarAccess(
false,
null,
"x"
)
)
)
)
),
new Method(
Type.INT,
"overloadedMethod",
List.of(
new Parameter(
"x",
Type.INT
),
new Parameter(
"y",
Type.INT
)
),
new Block(
List.of(
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.ADD,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
)
),
List.of(
new Constructor(
"Overloaded",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,86 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Print {
public static Program get() {
return new Program(
List.of(
new Class(
"Print",
List.of(),
List.of(
new Method(
Type.VOID,
"print",
List.of(
new Parameter(
"c",
Type.CHAR
)
),
new Block(
List.of(
new Print(
new FieldVarAccess(
false,
null,
"c"
)
)
)
)
),
new Method(
Type.VOID,
"printMoreComplex",
List.of(
new Parameter(
"x",
Type.INT
),
new Parameter(
"y",
Type.INT
)
),
new Block(
List.of(
new Print(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.LT,
new FieldVarAccess(
false,
null,
"y"
)
)
)
)
)
)
),
List.of(
new Constructor(
"Print",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,95 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Return {
public static Program get() {
return new Program(
List.of(
new Class(
"Return",
List.of(),
List.of(
new Method(
Type.INT,
"returnInt",
List.of(),
new Block(
List.of(
new Return(
new IntLiteral(10)
)
)
)
),
new Method(
Type.VOID,
"returnVoid",
List.of(),
new Block(
List.of(
new Return(
null
)
)
)
),
new Method(
Type.BOOL,
"returnBoolean",
List.of(),
new Block(
List.of(
new Return(
new BoolLiteral(true)
)
)
)
),
new Method(
Type.CHAR,
"returnChar",
List.of(),
new Block(
List.of(
new Return(
new CharLiteral('a')
)
)
)
),
new Method(
Type.REFERENCE("AST_Return"),
"returnClass",
List.of(),
new Block(
List.of(
new Return(
new New(
Type.REFERENCE("AST_Return"),
List.of()
)
)
)
)
)
),
List.of(
new Constructor(
"Return",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,55 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_VariableDefWithDecl {
public static Program get() {
return new Program(
List.of(
new Class(
"VariableDefWithDecl",
List.of(),
List.of(),
List.of(
new Constructor(
"VariableDefWithDecl",
List.of(),
new Block(
List.of(
new Declaration(
"a",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new IntLiteral(10)
),
new Declaration(
"b",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"b"
),
new IntLiteral(20)
)
)
)
)
)
)
)
);
}
}

View File

@ -0,0 +1,84 @@
package testResources.typedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_While {
public static Program get() {
return new Program(
List.of(
new Class(
"While",
List.of(),
List.of(
new Method(
Type.VOID,
"whileLoop",
List.of(),
new Block(
List.of(
new Declaration(
"i",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new IntLiteral(0)
),
new While(
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.LT,
new IntLiteral(5)
),
new Block(
List.of(
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.ADD,
new IntLiteral(1)
)
)
)
)
)
)
)
)
),
List.of(
new Constructor(
"While",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithConstructor {
package testResources.typedAST.TypedASTMore;//public class ClassWithConstructor {
// int x;
// public classWithConstructor() {
// this.x = 10;

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithConstructorAndMethodCall {
package testResources.typedAST.TypedASTMore;//public class ClassWithConstructorAndMethodCall {
// int x;
//
// public ClassWithConstructorAndMethodCall() {

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithConstructorWithCodeInComments {
package testResources.typedAST.TypedASTMore;//public class ClassWithConstructorWithCodeInComments {
// int x;
// public ClassWithConstructorWithCodeInComments() {
// this.x = 10;

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithConstructorWithParameters {
package testResources.typedAST.TypedASTMore;//public class ClassWithConstructorWithParameters {
// int x;
// public classWithConstructorWithParameters(int startValue, int repetitions) {
// this.x = startValue;

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithField {
package testResources.typedAST.TypedASTMore;//public class ClassWithField {
// int x;
//}

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithMethod {
package testResources.typedAST.TypedASTMore;//public class ClassWithMethod {
// public boolean method() {
// return false;
// }

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithMethodAndField {
package testResources.typedAST.TypedASTMore;//public class ClassWithMethodAndField {
// char c;
//
// public ClassWithMethodAndField(char character) {

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ClassWithMoreComplexMethodAndMain {
package testResources.typedAST.TypedASTMore;//public class ClassWithMoreComplexMethodAndMain {
// ClassWithMoreComplexMethodAndMain instance;
//
// public boolean moreComplexMethod() {

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class ComplexClass {
package testResources.typedAST.TypedASTMore;//public class ComplexClass {
//
// int x;
// int y;

View File

@ -1,4 +1,4 @@
package testfiles.TypedASTMore;//public class PublicClass {
package testResources.typedAST.TypedASTMore;//public class PublicClass {
//}
import de.maishai.typedast.Type;

View File

@ -1,4 +1,3 @@
public class ClassCanBeTyped{
public int c;
public ClassCanBeTyped d;