Merge remote-tracking branch 'origin/main'

This commit is contained in:
Ahmad 2024-06-22 22:19:14 +02:00
commit 976312d5ae
55 changed files with 2696 additions and 1247 deletions

View File

@ -8,15 +8,9 @@
# Fehlende Tests für Features (positive Tests):
- Mainmethod
- *=
- %=
- /=
- boolean als Datentyp (public boolean test;)
- do while
- break
- recipient mit methode zwischen drinnen (this.methode().a
- &&
- ||
- unaryOp
- Klammern von Expressions
- Multiline Comment
- Klammern von Expressions

View File

@ -2,12 +2,14 @@ package de.maishai.typedast.typedclass;
import de.maishai.ast.records.Print;
import de.maishai.typedast.*;
import lombok.AllArgsConstructor;
import org.objectweb.asm.Opcodes;
import java.util.List;
import static de.maishai.typedast.Help.TypedExpressionHelp.convertExpression;
@AllArgsConstructor
public class TypedPrint implements TypedStatement {
private TypedExpression value;
private Type type;

View File

@ -2,6 +2,7 @@ package de.maishai.typedast.typedclass;
import de.maishai.ast.records.*;
import de.maishai.typedast.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
@ -10,6 +11,7 @@ import org.objectweb.asm.Opcodes;
import static de.maishai.typedast.Help.TypedExpressionHelp.convertExpression;
@Data
@AllArgsConstructor
public class TypedWhile implements TypedStatement {
private TypedExpression cond;
private TypedBlock typedBlock;

View File

@ -1,5 +1,6 @@
import de.maishai.Compiler;
import de.maishai.ast.records.Program;
import de.maishai.typedast.typedclass.TypedProgram;
import org.junit.jupiter.api.Test;
import testResources.AST.ASTFeatures.*;
import testResources.AST.ASTMore.*;
@ -65,6 +66,13 @@ public class ScannerParserTests {
assertEquals(AbstractSyntax_ComplexClass.get(), resultAst);
}
// Feature Tests
@Test
@ -86,6 +94,12 @@ public class ScannerParserTests {
assertEquals(AST_Comment.get(), resultAst);
}
@Test
public void testCompAssign() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/CompAssign.java"));
assertEquals(AST_CompAssign.get(), resultAst);
}
@Test
public void testConstructor() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Constructor.java"));
@ -98,6 +112,12 @@ public class ScannerParserTests {
assertEquals(AST_Continue.get(), resultAst);
}
@Test
public void testDataTypes() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/DataTypes.java"));
assertEquals(AST_DataTypes.get(), resultAst);
}
@Test
public void testField() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Field.java"));
@ -116,18 +136,18 @@ public class ScannerParserTests {
assertEquals(AST_If.get(), resultAst);
}
// @Test
// public void testIncrDecr() {
// 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/test/testFiles/JavaTestfilesFeatures/LogicExpr.java"));
assertEquals(AST_LogicExpr.get(), resultAst);
}
@Test
public void testMain() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Main.java"));
assertEquals(AST_Main.get(), resultAst);
}
@Test
public void testMethod() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Method.java"));
@ -140,7 +160,12 @@ public class ScannerParserTests {
assertEquals(AST_MethodCall.get(), resultAst);
}
//TODO: Multiple Classes test
// @Test
// public void testMultipleClasses() {
// Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/MultipleClasses.java"));
// assertEquals(AST_MultipleClasses.get(), resultAst);
// }
// TODO: Implement
@Test
public void testOperators() {
@ -159,14 +184,12 @@ public class ScannerParserTests {
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/test/testFiles/JavaTestfilesFeatures/Return.java"));
// assertEquals(AST_Return.get(), resultAst);
// }
//TODO: fix
@Test
public void testReturn() {
Program resultAst = Compiler.generateASTFromFile(List.of("src/test/testFiles/JavaTestfilesFeatures/Return.java"));
assertEquals(AST_Return.get(), resultAst);
}
@Test
public void testVariableDefWithDecl() {

View File

@ -1,16 +1,15 @@
import de.maishai.Compiler;
import de.maishai.typedast.typedclass.TypedProgram;
import jdk.jshell.spi.ExecutionControl;
import org.junit.jupiter.api.Test;
import testResources.typedAST.TypedASTFeatures.*;
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 testResources.TypedAST.TypedASTMore.TypedAbstractSyntax_ClassWithConstructor;
import testResources.TypedAST.TypedASTMore.TypedAbstractSyntax_ClassWithField;
import testResources.TypedAST.TypedASTMore.TypedAbstractSyntax_PublicClass;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -58,103 +57,117 @@ public class TypingTests {
assertEquals(TypedAST_Comment.get(), resultTypedAst);
}
@Test
public void testCompAssign() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_CompAssign.get());
assertEquals(TypedAST_CompAssign.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 testContinue() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Continue.get());
assertEquals(TypedAST_Continue.get(), resultTypedAst);
}
@Test
public void testDataTypes() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_DataTypes.get());
assertEquals(TypedAST_DataTypes.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 testLogicExpr() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_LogicExpr.get());
assertEquals(TypedAST_LogicExpr.get(), resultTypedAst);
}
@Test
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);
}
}
@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);
// }
// 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);
}
@Test
public void testReturn() {
TypedProgram resultTypedAst = Compiler.generateTypedASTFromAst(AST_Return.get());
assertEquals(TypedAST_Return.get(), resultTypedAst);
}
@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,37 +1,37 @@
package testResources.typedAST.TypedASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_Operators {
public class AST_CompAssign {
public static Program get() {
return new Program(
List.of(
new Class(
"Operators",
"CompAssign",
List.of(),
List.of(
new Method(
Type.INT,
"add",
"increase",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new Binary(
new FieldVarAccess(
false,
@ -39,11 +39,14 @@ public class TypedAST_Operators {
"a"
),
Operator.ADD,
new FieldVarAccess(
false,
null,
"b"
)
new IntLiteral(1)
)
),
new Return(
new FieldVarAccess(
false,
null,
"a"
)
)
)
@ -51,20 +54,21 @@ public class TypedAST_Operators {
),
new Method(
Type.INT,
"sub",
"decrease",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new Binary(
new FieldVarAccess(
false,
@ -72,11 +76,14 @@ public class TypedAST_Operators {
"a"
),
Operator.SUB,
new FieldVarAccess(
false,
null,
"b"
)
new IntLiteral(1)
)
),
new Return(
new FieldVarAccess(
false,
null,
"a"
)
)
)
@ -84,20 +91,21 @@ public class TypedAST_Operators {
),
new Method(
Type.INT,
"mul",
"multiply",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new Binary(
new FieldVarAccess(
false,
@ -105,11 +113,14 @@ public class TypedAST_Operators {
"a"
),
Operator.MUL,
new FieldVarAccess(
false,
null,
"b"
)
new IntLiteral(2)
)
),
new Return(
new FieldVarAccess(
false,
null,
"a"
)
)
)
@ -117,20 +128,21 @@ public class TypedAST_Operators {
),
new Method(
Type.INT,
"div",
"divide",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new Binary(
new FieldVarAccess(
false,
@ -138,11 +150,14 @@ public class TypedAST_Operators {
"a"
),
Operator.DIV,
new FieldVarAccess(
false,
null,
"b"
)
new IntLiteral(2)
)
),
new Return(
new FieldVarAccess(
false,
null,
"a"
)
)
)
@ -150,20 +165,21 @@ public class TypedAST_Operators {
),
new Method(
Type.INT,
"mod",
"modulus",
List.of(
new Parameter(
"a",
Type.INT
),
new Parameter(
"b",
Type.INT
)
),
new Block(
List.of(
new Return(
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new Binary(
new FieldVarAccess(
false,
@ -171,11 +187,14 @@ public class TypedAST_Operators {
"a"
),
Operator.MOD,
new FieldVarAccess(
false,
null,
"b"
)
new IntLiteral(2)
)
),
new Return(
new FieldVarAccess(
false,
null,
"a"
)
)
)
@ -184,7 +203,7 @@ public class TypedAST_Operators {
),
List.of(
new Constructor(
"Operators",
"CompAssign",
List.of(),
new Block(
List.of()

View File

@ -1,143 +1,127 @@
package testResources.typedAST.TypedASTFeatures;
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.Program;
import de.maishai.typedast.Type;
import java.util.List;
public class TypedAST_MethodCall {
public class AST_DataTypes {
public static Program get() {
return new Program(
List.of(
new Class(
"MethodCall",
List.of(),
"DataTypes",
List.of(
new Declaration(
"x",
Type.INT
),
new Declaration(
"y",
Type.BOOL
),
new Declaration(
"z",
Type.CHAR
)
),
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",
"integer",
List.of(
new Parameter(
"x",
"i",
Type.INT
)
),
new Block(
List.of(
new Declaration(
"a",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new IntLiteral(1)
),
new Return(
new FieldVarAccess(
false,
null,
"x"
"a"
)
)
)
)
),
new Method(
Type.INT,
"method2",
Type.BOOL,
"bool",
List.of(
new Parameter(
"x",
Type.INT
),
new Parameter(
"y",
Type.INT
"b",
Type.BOOL
)
),
new Block(
List.of(
new Declaration(
"a",
Type.BOOL
),
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new BoolLiteral(true)
),
new Return(
new Binary(
new FieldVarAccess(
false,
null,
"x"
),
Operator.ADD,
new FieldVarAccess(
false,
null,
"y"
)
new FieldVarAccess(
false,
null,
"a"
)
)
)
)
),
new Method(
Type.CHAR,
"character",
List.of(
new Parameter(
"c",
Type.CHAR
)
),
new Block(
List.of(
new Declaration(
"a",
Type.CHAR
),
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new CharLiteral('a')
),
new Return(
new FieldVarAccess(
false,
null,
"a"
)
)
)
@ -146,7 +130,7 @@ public class TypedAST_MethodCall {
),
List.of(
new Constructor(
"MethodCall",
"DataTypes",
List.of(),
new Block(
List.of()

View File

@ -1,86 +0,0 @@
package testResources.AST.ASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;
import de.maishai.typedast.Type;
import java.util.List;
public class AST_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,46 @@
package testResources.AST.ASTFeatures;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import java.util.List;
public class AST_Main {
public static Program get() {
return new Program(
List.of(
new Class(
"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(
new Constructor(
"Main",
List.of(),
new Block(
List.of()
)
)
)
)
)
);
}
}

View File

@ -63,14 +63,14 @@ public class AST_Return {
)
),
new Method(
Type.REFERENCE("AST_Return"),
Type.REFERENCE("Return"),
"returnClass",
List.of(),
new Block(
List.of(
new Return(
new New(
Type.REFERENCE("AST_Return"),
Type.REFERENCE("Return"),
List.of()
)
)

View File

@ -66,6 +66,59 @@ public class AST_While {
)
)
)
),
new Method(
Type.VOID,
"doWhileLoop",
List.of(),
new Block(
List.of(
new Declaration(
"i",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new IntLiteral(0)
),
new DoWhile(
new Block(
List.of(
new Assignment(
new FieldVarAccess(
false,
null,
"i"
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.ADD,
new IntLiteral(1)
)
)
)
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.LT,
new IntLiteral(5)
)
)
)
)
)
),
List.of(

View File

@ -1,4 +1,4 @@
package testResources.typedAST.TypedASTFeatures;
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.TypedBlock;

View File

@ -1,4 +1,4 @@
package testResources.typedAST.TypedASTFeatures;
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,9 +1,5 @@
package testResources.typedAST.TypedASTFeatures;
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;

View File

@ -0,0 +1,285 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_CompAssign {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"CompAssign",
List.of(),
List.of(
new TypedMethod(
"increase",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(
1,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"decrease",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.SUB,
new TypedIntLiteral(
1,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"multiply",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.MUL,
new TypedIntLiteral(
2,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"divide",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.DIV,
new TypedIntLiteral(
2,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"modulus",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.MOD,
new TypedIntLiteral(
2,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
)
),
Type.INT
)
)
),
List.of(
new TypedConstructor(
"CompAssign",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("CompAssign")
)
),
null
);
}
}

View File

@ -1,8 +1,6 @@
package testResources.typedAST.TypedASTFeatures;
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.*;

View File

@ -1,127 +1,145 @@
package testResources.typedAST.TypedASTFeatures;
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_For {
public static Program get() {
return new Program(
public class TypedAST_Continue {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new Class(
"For",
new TypedClass(
"Continue",
List.of(),
List.of(
new Method(
new TypedMethod(
"continueLoop",
Type.VOID,
"testFor",
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"i",
Type.INT
),
new For(
new Assignment(
new FieldVarAccess(
false,
null,
"i"
)),
List.of(
new TypedFor(
new TypedAssignment(
new TypedIntLiteral(
0,
Type.INT
),
new IntLiteral(0)
),
new Binary(
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"i"
"i",
Type.INT
),
Type.INT
),
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.LT,
new IntLiteral(10)
),
new Assignment(
new FieldVarAccess(
false,
null,
"i"
new TypedIntLiteral(
5,
Type.INT
),
new Binary(
new FieldVarAccess(
Type.BOOL
),
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i"
"i",
Type.INT
),
Operator.ADD,
new IntLiteral(1)
)
new TypedIntLiteral(
1,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
),
new TypedBlock(
List.of(),
List.of(
new TypedIfElse(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.EQ,
new TypedIntLiteral(
3,
Type.INT
),
Type.BOOL
),
new TypedBlock(
List.of(),
List.of(
new TypedContinue()
),
Type.VOID
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID
)
),
Type.VOID
),
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()
)
)
)
),
Type.VOID
)
)
),
List.of(
new Constructor(
"For",
new TypedConstructor(
"Continue",
List.of(),
new Block(
List.of(
)
)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
// TODO: ist Konstruktor nicht immer vom Typ der Klasse?
List.of()
)
)
),
null,
null,
Type.REFERENCE("Continue")
)
)
),
null
);
}
}

View File

@ -0,0 +1,183 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_DataTypes {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"DataTypes",
List.of(
new TypedDeclaration(
"x",
Type.INT
),
new TypedDeclaration(
"y",
Type.BOOL
),
new TypedDeclaration(
"z",
Type.CHAR
)
),
List.of(
new TypedMethod(
"integer",
Type.INT,
List.of(
new TypedParameter(
"i",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(
new TypedLocalVariable(
"a",
Type.INT
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
1,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"bool",
Type.BOOL,
List.of(
new TypedParameter(
"b",
Type.BOOL
)
),
List.of(),
new TypedBlock(
List.of(
new TypedLocalVariable(
"a",
Type.BOOL
)
),
List.of(
new TypedAssignment(
new TypedBoolLiteral(
true,
Type.BOOL
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.BOOL
),
Type.BOOL
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.BOOL
),
Type.BOOL
)
),
Type.BOOL
)
),
new TypedMethod(
"character",
Type.CHAR,
List.of(
new TypedParameter(
"c",
Type.CHAR
)
),
List.of(),
new TypedBlock(
List.of(
new TypedLocalVariable(
"a",
Type.CHAR
)
),
List.of(
new TypedAssignment(
new TypedCharLiteral(
'a',
Type.CHAR
),
new TypedFieldVarAccess(
false,
null,
"a",
Type.CHAR
),
Type.CHAR
),
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"a",
Type.CHAR
),
Type.CHAR
)
),
Type.CHAR
)
)
),
List.of(
new TypedConstructor(
"DataTypes",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("DataTypes")
)
),
null
);
}
}

View File

@ -1,66 +1,85 @@
package testResources.typedAST.TypedASTFeatures;
package testResources.TypedAST.TypedASTFeatures;
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_Field {
public static Program get() {
return new Program(
public static TypedProgram get() {
return new TypedProgram(
List.of(
new Class(
new TypedClass(
"Field",
List.of(
new Declaration(
new TypedDeclaration(
"x",
Type.INT
),
new Declaration(
new TypedDeclaration(
"c",
Type.CHAR
)
),
List.of(
new Method(
Type.VOID,
new TypedMethod(
"fieldAccess",
Type.VOID,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
new TypedAssignment(
new TypedIntLiteral(
0,
Type.INT
),
new TypedFieldVarAccess(
true,
null,
"x"
"x",
Type.INT
),
new IntLiteral(0)
Type.INT
),
new Assignment(
new FieldVarAccess(
new TypedAssignment(
new TypedCharLiteral(
'a',
Type.CHAR
),
new TypedFieldVarAccess(
true,
null,
"c"
"c",
Type.CHAR
),
new CharLiteral('a')
Type.CHAR
)
)
),
Type.VOID
)
)
),
List.of(
new Constructor(
new TypedConstructor(
"Field",
List.of(),
new Block(
List.of()
)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
)
),
null,
null,
Type.REFERENCE("Field")
)
)
),
null
);
}
}

View File

@ -0,0 +1,175 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_For {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"For",
List.of(),
List.of(
new TypedMethod(
"testFor",
Type.VOID,
List.of(),
List.of(),
new TypedBlock(
List.of(
new TypedLocalVariable(
"i",
Type.INT
),
new TypedLocalVariable(
"j",
Type.INT
)
),
List.of(
new TypedFor(
new TypedAssignment(
new TypedIntLiteral(
0,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
),
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.LT,
new TypedIntLiteral(
10,
Type.INT
),
Type.BOOL
),
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(
1,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID
),
new TypedFor(
new TypedAssignment(
new TypedIntLiteral(
0,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"j",
Type.INT
),
Type.INT
),
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"j",
Type.INT
),
Operator.LT,
new TypedIntLiteral(
10,
Type.INT
),
Type.BOOL
),
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"j",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(
1,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"j",
Type.INT
),
Type.INT
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID
)
)
)
)
),
List.of(
new TypedConstructor(
"For",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("For")
)
),
null
);
}
}

View File

@ -1,84 +1,87 @@
package testResources.typedAST.TypedASTFeatures;
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_While {
public static Program get() {
return new Program(
public class TypedAST_If {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new Class(
"While",
new TypedClass(
"If",
List.of(),
List.of(
new Method(
new TypedMethod(
"ifMethod",
Type.VOID,
"whileLoop",
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(),
List.of(
new Declaration(
"i",
Type.INT
),
new Assignment(
new FieldVarAccess(
new TypedIfElse(
new TypedBoolLiteral(
false,
null,
"i"
Type.BOOL
),
new IntLiteral(0)
),
new While(
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.LT,
new IntLiteral(5)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
new Block(
new TypedBlock(
List.of(),
List.of(
new Assignment(
new FieldVarAccess(
false,
null,
"i"
new TypedIfElse(
new TypedBoolLiteral(
true,
Type.BOOL
),
new Binary(
new FieldVarAccess(
false,
null,
"i"
),
Operator.ADD,
new IntLiteral(1)
)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID
)
)
)
),
Type.VOID
),
Type.VOID
)
)
),
Type.VOID
)
)
),
List.of(
new Constructor(
"While",
new TypedConstructor(
"If",
List.of(),
new Block(
List.of()
)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
)
),
null,
null,
Type.REFERENCE("If")
)
)
),
null
);
}
}

View File

@ -1,332 +1,435 @@
package testResources.typedAST.TypedASTFeatures;
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_LogicExpr {
public static Program get() {
return new Program(
public static TypedProgram get() {
return new TypedProgram(
List.of(
new Class(
new TypedClass(
"LogicExpr",
List.of(),
List.of(
new Method(
Type.BOOL,
new TypedMethod(
"test",
Type.BOOL,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
new TypedLocalVariable(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
10,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y"
"x",
Type.INT
),
new IntLiteral(20)
Type.INT
),
new Return(
new Binary(
new FieldVarAccess(
new TypedAssignment(
new TypedIntLiteral(
20,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.LT,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.BOOL
),
Type.BOOL
)
)
),
Type.BOOL
)
),
new Method(
Type.BOOL,
new TypedMethod(
"test2",
Type.BOOL,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
new TypedLocalVariable(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
10,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y"
"x",
Type.INT
),
new IntLiteral(20)
Type.INT
),
new Return(
new Binary(
new FieldVarAccess(
new TypedAssignment(
new TypedIntLiteral(
20,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.GT,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.BOOL
),
Type.BOOL
)
)
),
Type.BOOL
)
),
new Method(
Type.BOOL,
new TypedMethod(
"test3",
Type.BOOL,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
new TypedLocalVariable(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
10,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y"
"x",
Type.INT
),
new IntLiteral(20)
Type.INT
),
new Return(
new Binary(
new FieldVarAccess(
new TypedAssignment(
new TypedIntLiteral(
20,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.EQ,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.BOOL
),
Type.BOOL
)
)
),
Type.BOOL
)
),
new Method(
Type.BOOL,
new TypedMethod(
"test4",
Type.BOOL,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
new TypedLocalVariable(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
10,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y"
"x",
Type.INT
),
new IntLiteral(20)
Type.INT
),
new Return(
new Binary(
new FieldVarAccess(
new TypedAssignment(
new TypedIntLiteral(
20,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.NE,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.BOOL
),
Type.BOOL
)
)
),
Type.BOOL
)
),
new Method(
Type.BOOL,
new TypedMethod(
"test5",
Type.BOOL,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
new TypedLocalVariable(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
10,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y"
"x",
Type.INT
),
new IntLiteral(20)
Type.INT
),
new Return(
new Binary(
new FieldVarAccess(
new TypedAssignment(
new TypedIntLiteral(
20,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.LE,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.BOOL
),
Type.BOOL
)
)
),
Type.BOOL
)
),
new Method(
Type.BOOL,
new TypedMethod(
"test6",
Type.BOOL,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"x",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"x"
),
new IntLiteral(10)
),
new Declaration(
new TypedLocalVariable(
"y",
Type.INT
),
new Assignment(
new FieldVarAccess(
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
10,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y"
"x",
Type.INT
),
new IntLiteral(20)
Type.INT
),
new Return(
new Binary(
new FieldVarAccess(
new TypedAssignment(
new TypedIntLiteral(
20,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.GE,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.BOOL
),
Type.BOOL
)
)
),
Type.BOOL
)
)
),
List.of(
new Constructor(
new TypedConstructor(
"LogicExpr",
List.of(),
new Block(
List.of()
)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
)
),
null,
null,
Type.REFERENCE("LogicExpr")
)
)
),
null
);
}
}

View File

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

View File

@ -0,0 +1,49 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_Method {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"Method",
List.of(),
List.of(
new TypedMethod(
"method",
Type.VOID,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
)
)
),
List.of(
new TypedConstructor(
"Method",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("Method")
)
),
null
);
}
}

View File

@ -0,0 +1,213 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_MethodCall {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"MethodCall",
List.of(),
List.of(
new TypedMethod(
"methodCall",
Type.INT,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedMethodCall(
new TypedFieldVarAccess(
false,
null,
"method",
Type.INT
),
List.of(),
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"methodCall1",
Type.INT,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedMethodCall(
new TypedFieldVarAccess(
false,
null,
"method1",
Type.INT
),
List.of(
new TypedIntLiteral(
1,
Type.INT
)
),
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"methodCall2",
Type.INT,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedMethodCall(
new TypedFieldVarAccess(
false,
null,
"method2",
Type.INT
),
List.of(
new TypedIntLiteral(
1,
Type.INT
),
new TypedIntLiteral(
2,
Type.INT
)
),
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"method",
Type.INT,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedIntLiteral(
0,
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"method1",
Type.INT,
List.of(
new TypedParameter(
"x",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"x",
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"method2",
Type.INT,
List.of(
new TypedParameter(
"x",
Type.INT
),
new TypedParameter(
"y",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x",
Type.INT
),
Operator.ADD,
new TypedFieldVarAccess(
false,
null,
"y",
Type.INT
),
Type.INT
),
Type.INT
)
),
Type.INT
)
)
),
List.of(
new TypedConstructor(
"MethodCall",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("MethodCall")
)
),
null
);
}
}

View File

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

View File

@ -0,0 +1,240 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_Operators {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"Operators",
List.of(),
List.of(
new TypedMethod(
"add",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
),
new TypedParameter(
"b",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.ADD,
new TypedFieldVarAccess(
false,
null,
"b",
Type.INT
),
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"sub",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
),
new TypedParameter(
"b",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.SUB,
new TypedFieldVarAccess(
false,
null,
"b",
Type.INT
),
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"mul",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
),
new TypedParameter(
"b",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.MUL,
new TypedFieldVarAccess(
false,
null,
"b",
Type.INT
),
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"div",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
),
new TypedParameter(
"b",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.DIV,
new TypedFieldVarAccess(
false,
null,
"b",
Type.INT
),
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"mod",
Type.INT,
List.of(
new TypedParameter(
"a",
Type.INT
),
new TypedParameter(
"b",
Type.INT
)
),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"a",
Type.INT
),
Operator.MOD,
new TypedFieldVarAccess(
false,
null,
"b",
Type.INT
),
Type.INT
),
Type.INT
)
),
Type.INT
)
)
),
List.of(
new TypedConstructor(
"Operators",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("Operators")
)
),
null
);
}
}

View File

@ -1,98 +1,124 @@
package testResources.typedAST.TypedASTFeatures;
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_Overloaded {
public static Program get() {
return new Program(
public static TypedProgram get() {
return new TypedProgram(
List.of(
new Class(
new TypedClass(
"Overloaded",
List.of(),
List.of(
new Method(
Type.INT,
new TypedMethod(
"overloadedMethod",
Type.INT,
List.of(),
new Block(
List.of(),
new TypedBlock(
List.of(),
List.of(
new Return(
new IntLiteral(0)
new TypedReturn(
new TypedIntLiteral(
0,
Type.INT
),
Type.INT
)
)
),
Type.INT
)
),
new Method(
Type.INT,
new TypedMethod(
"overloadedMethod",
Type.INT,
List.of(
new Parameter(
new TypedParameter(
"x",
Type.INT
)
),
new Block(
List.of(),
new TypedBlock(
List.of(),
List.of(
new Return(
new FieldVarAccess(
new TypedReturn(
new TypedFieldVarAccess(
false,
null,
"x"
)
"x",
Type.INT
),
Type.INT
)
)
),
Type.INT
)
),
new Method(
Type.INT,
new TypedMethod(
"overloadedMethod",
Type.INT,
List.of(
new Parameter(
new TypedParameter(
"x",
Type.INT
),
new Parameter(
new TypedParameter(
"y",
Type.INT
)
),
new Block(
List.of(),
new TypedBlock(
List.of(),
List.of(
new Return(
new Binary(
new FieldVarAccess(
new TypedReturn(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.ADD,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.INT
),
Type.INT
)
)
),
Type.INT
)
)
),
List.of(
new Constructor(
new TypedConstructor(
"Overloaded",
List.of(),
new Block(
List.of()
)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
)
),
null,
null,
Type.REFERENCE("Overloaded")
)
)
),
null
);
}
}

View File

@ -1,86 +1,105 @@
package testResources.typedAST.TypedASTFeatures;
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_Print {
public static Program get() {
return new Program(
public static TypedProgram get() {
return new TypedProgram(
List.of(
new Class(
new TypedClass(
"Print",
List.of(),
List.of(
new Method(
new TypedMethod(
"printIt",
Type.VOID,
"print",
List.of(
new Parameter(
new TypedParameter(
"c",
Type.CHAR
)
),
new Block(
List.of(),
new TypedBlock(
List.of(),
List.of(
new Print(
new FieldVarAccess(
new TypedPrint(
new TypedFieldVarAccess(
false,
null,
"c"
)
"c",
Type.CHAR
),
Type.VOID
)
)
),
Type.VOID
)
),
new Method(
Type.VOID,
new TypedMethod(
"printMoreComplex",
Type.VOID,
List.of(
new Parameter(
new TypedParameter(
"x",
Type.INT
),
new Parameter(
new TypedParameter(
"y",
Type.INT
)
),
new Block(
List.of(),
new TypedBlock(
List.of(),
List.of(
new Print(
new Binary(
new FieldVarAccess(
new TypedPrint(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"x"
"x",
Type.INT
),
Operator.LT,
new FieldVarAccess(
new TypedFieldVarAccess(
false,
null,
"y"
)
)
"y",
Type.INT
),
Type.BOOL
),
Type.VOID
)
)
),
Type.VOID
)
)
),
List.of(
new Constructor(
new TypedConstructor(
"Print",
List.of(),
new Block(
List.of()
)
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
)
),
null,
null,
Type.REFERENCE("Print")
)
)
),
null
);
}
}

View File

@ -0,0 +1,131 @@
package testResources.TypedAST.TypedASTFeatures;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import java.util.List;
public class TypedAST_Return {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"Return",
List.of(),
List.of(
new TypedMethod(
"returnInt",
Type.INT,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedIntLiteral(
10,
Type.INT
),
Type.INT
)
),
Type.INT
)
),
new TypedMethod(
"returnVoid",
Type.VOID,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
null,
Type.VOID
)
),
Type.VOID
)
),
new TypedMethod(
"returnBoolean",
Type.BOOL,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedBoolLiteral(
true,
Type.BOOL
),
Type.BOOL
)
),
Type.BOOL
)
),
new TypedMethod(
"returnChar",
Type.CHAR,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedCharLiteral(
'a',
Type.CHAR
),
Type.CHAR
)
),
Type.CHAR
)
),
new TypedMethod(
"returnClass",
Type.REFERENCE("Return"),
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedNew(
Type.REFERENCE("Return"),
List.of()
),
Type.REFERENCE("Return")
)
),
Type.REFERENCE("Return")
)
)
),
List.of(
new TypedConstructor(
"Return",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("Return")
)
),
null
);
}
}

View File

@ -1,55 +1,75 @@
package testResources.typedAST.TypedASTFeatures;
package testResources.TypedAST.TypedASTFeatures;
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_VariableDefWithDecl {
public static Program get() {
return new Program(
public static TypedProgram get() {
return new TypedProgram(
List.of(
new Class(
new TypedClass(
"VariableDefWithDecl",
List.of(),
List.of(),
List.of(
new Constructor(
new TypedConstructor(
"VariableDefWithDecl",
List.of(),
new Block(
new TypedBlock(
List.of(
new Declaration(
new TypedLocalVariable(
"a",
Type.INT
),
new Assignment(
new FieldVarAccess(
false,
null,
"a"
),
new IntLiteral(10)
),
new Declaration(
new TypedLocalVariable(
"b",
Type.INT
),
new Assignment(
new FieldVarAccess(
)
),
List.of(
new TypedAssignment(
new TypedIntLiteral(
10,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"b"
"a",
Type.INT
),
new IntLiteral(20)
Type.INT
),
new TypedAssignment(
new TypedIntLiteral(
20,
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"b",
Type.INT
),
Type.INT
)
)
)
),
Type.VOID
),
Type.VOID,
List.of()
)
)
),
null,
null,
Type.REFERENCE("VariableDefWithDecl")
)
)
),
null
);
}
}

View File

@ -0,0 +1,191 @@
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_While {
public static TypedProgram get() {
return new TypedProgram(
List.of(
new TypedClass(
"While",
List.of(),
List.of(
new TypedMethod(
"whileLoop",
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
),
new TypedWhile(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.LT,
new TypedIntLiteral(
5,
Type.INT
),
Type.BOOL
),
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(
1,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
)
),
Type.VOID
),
Type.VOID
)
)
)
),
new TypedMethod(
"doWhileLoop",
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
),
new TypedDoWhile(
new TypedBlock(
List.of(),
List.of(
new TypedAssignment(
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(
1,
Type.INT
),
Type.INT
),
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Type.INT
)
),
Type.VOID
),
new TypedBinary(
new TypedFieldVarAccess(
false,
null,
"i",
Type.INT
),
Operator.LT,
new TypedIntLiteral(
5,
Type.INT
),
Type.BOOL
),
Type.VOID
)
)
)
)
),
List.of(
new TypedConstructor(
"While",
List.of(),
new TypedBlock(
List.of(),
List.of(),
Type.VOID
),
Type.VOID,
List.of()
)
),
null,
null,
Type.REFERENCE("While")
)
),
null
);
}
}

View File

@ -1,4 +1,4 @@
package testResources.typedAST.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 testResources.typedAST.TypedASTMore;//public class ClassWithConstructorAndMethodCall {
package testResources.TypedAST.TypedASTMore;//public class ClassWithConstructorAndMethodCall {
// int x;
//
// public ClassWithConstructorAndMethodCall() {

View File

@ -1,4 +1,4 @@
package testResources.typedAST.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 testResources.typedAST.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 testResources.typedAST.TypedASTMore;//public class ClassWithField {
package testResources.TypedAST.TypedASTMore;//public class ClassWithField {
// int x;
//}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

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

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

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

View File

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

@ -1,3 +1,12 @@
public class Comment {
// This is a comment
// This is another comment
// With multiple lines
/* This is a comment
with multiple lines written in a block
which is closed/started with a * and a /
*/
}

View File

@ -0,0 +1,26 @@
public class CompAssign {
public int increase(int a) {
a += 1;
return a;
}
public int decrease(int a) {
a -= 1;
return a;
}
public int multiply(int a) {
a *= 2;
return a;
}
public int divide(int a) {
a /= 2;
return a;
}
public int modulus(int a) {
a %= 2;
return a;
}
}

View File

@ -0,0 +1,20 @@
public class DataTypes {
int x;
boolean y;
char z;
public int integer(int i) {
int a = 1;
return a;
}
public boolean bool(boolean b) {
boolean a = true;
return a;
}
public char character(char c) {
char a = 'a';
return a;
}
}

View File

@ -1,9 +0,0 @@
public class IncrDecr {
public int increment(int a) {
return a += 1;
}
public int decrement(int a) {
return a -= 1;
}
}

View File

@ -0,0 +1,5 @@
public class Main {
public static void main(String[] args) {
int i = 0;
}
}

View File

@ -15,7 +15,7 @@ public class Return {
return 'a';
}
public AST_Return returnClass() {
return new AST_Return();
public Return returnClass() {
return new Return();
}
}

View File

@ -5,4 +5,11 @@ public class While {
i = i + 1;
}
}
public void doWhileLoop() {
int i = 0;
do {
i = i + 1;
} while (i < 5);
}
}