mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 15:38:03 +00:00
adapted abstract syntax test files to new ast
This commit is contained in:
parent
4c34a8db44
commit
48e0ebf521
@ -15,6 +15,7 @@
|
||||
import de.maishai.ast.*;
|
||||
import de.maishai.ast.records.*;
|
||||
import de.maishai.ast.records.Class;
|
||||
import de.maishai.typedast.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -22,17 +23,16 @@ public class AbstractSyntax_ClassWithConstructor {
|
||||
public static Class get() {
|
||||
List<Declaration> declarations = List.of(
|
||||
new Declaration(
|
||||
new Id("x"),
|
||||
"x",
|
||||
Type.INT
|
||||
)
|
||||
);
|
||||
List<Method> methods = List.of();
|
||||
List<Constructor> constructors = getConstructors();
|
||||
return new Class(
|
||||
new Id("ClassWithConstructor"),
|
||||
"ClassWithConstructor",
|
||||
declarations,
|
||||
methods,
|
||||
null,
|
||||
constructors
|
||||
);
|
||||
}
|
||||
@ -44,78 +44,87 @@ public class AbstractSyntax_ClassWithConstructor {
|
||||
private static Constructor getConstructor1() {
|
||||
List<Parameter> parameters = List.of();
|
||||
|
||||
List<LocalVariable> localVariables = List.of(
|
||||
new LocalVariable(
|
||||
new Id("i"),
|
||||
List<Declaration> localVariables = List.of(
|
||||
new Declaration(
|
||||
"i",
|
||||
Type.INT
|
||||
)
|
||||
);
|
||||
List<Statement> statementList = List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("x")),
|
||||
"x"),
|
||||
new IntLiteral(10)
|
||||
),
|
||||
new For(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("i")),
|
||||
"i"),
|
||||
new IntLiteral(0)
|
||||
),
|
||||
new Binary(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("i")),
|
||||
"i"),
|
||||
Operator.LT,
|
||||
new IntLiteral(6)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("i")),
|
||||
"i"),
|
||||
new Binary(
|
||||
new Id("i"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"i"),
|
||||
Operator.ADD,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
),
|
||||
new Block(
|
||||
List.of(
|
||||
new LocalVariable(
|
||||
new Id("j"),
|
||||
new Declaration(
|
||||
"j",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
List.of(
|
||||
new For(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("j")),
|
||||
"j"),
|
||||
new IntLiteral(0)
|
||||
),
|
||||
new Binary(
|
||||
new Id("j"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"j"),
|
||||
Operator.LT,
|
||||
new Id("x")
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"x")
|
||||
),
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("j")),
|
||||
"j"),
|
||||
new Binary(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("j")),
|
||||
"j"),
|
||||
Operator.ADD,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
@ -124,14 +133,20 @@ public class AbstractSyntax_ClassWithConstructor {
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("x")),
|
||||
"x"),
|
||||
new Binary(
|
||||
new Id("x"),
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
Operator.MUL,
|
||||
new Id("x")
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x")
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -148,8 +163,7 @@ public class AbstractSyntax_ClassWithConstructor {
|
||||
);
|
||||
|
||||
return new Constructor(
|
||||
true,
|
||||
new Id("ClassWithConstructor"),
|
||||
"ClassWithConstructor",
|
||||
parameters,
|
||||
block
|
||||
);
|
||||
|
@ -21,6 +21,7 @@
|
||||
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;
|
||||
|
||||
@ -28,17 +29,16 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
|
||||
public static Class get() {
|
||||
List<Declaration> declarationList = List.of(
|
||||
new Declaration(
|
||||
new Id("x"),
|
||||
"x",
|
||||
Type.INT
|
||||
)
|
||||
);
|
||||
List<Method> methodList = getMethods();
|
||||
List<Constructor> constructorList = getConstructors();
|
||||
return new Class(
|
||||
new Id("ClassWithConstructorAndMethodCall"),
|
||||
"ClassWithConstructorAndMethodCall",
|
||||
declarationList,
|
||||
methodList,
|
||||
null,
|
||||
constructorList
|
||||
);
|
||||
}
|
||||
@ -52,31 +52,38 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("x")),
|
||||
"x"),
|
||||
new IntLiteral(10)
|
||||
),
|
||||
new While(
|
||||
new MethodCall(
|
||||
false,
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("methodCall"),
|
||||
"methodCall"),
|
||||
List.of()
|
||||
),
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("x")),
|
||||
"x"),
|
||||
new Binary(
|
||||
new Id("x"),
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
Operator.MUL,
|
||||
new Id("x")
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x")
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -85,8 +92,7 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
|
||||
)
|
||||
);
|
||||
return new Constructor(
|
||||
true,
|
||||
new Id("ClassWithConstructorAndMethodCall"),
|
||||
"ClassWithConstructorAndMethodCall",
|
||||
List.of(),
|
||||
block
|
||||
);
|
||||
@ -98,15 +104,18 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall {
|
||||
|
||||
private static Method getMethod1() {
|
||||
return new Method(
|
||||
ReturnType.BOOL,
|
||||
new Id("methodCall"),
|
||||
Type.BOOL,
|
||||
"methodCall",
|
||||
List.of(),
|
||||
new Block(
|
||||
List.of(),
|
||||
List.of(
|
||||
new IfElse(
|
||||
new Binary(
|
||||
new Id("x"),
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
Operator.GT,
|
||||
new IntLiteral(100)
|
||||
),
|
||||
|
@ -16,6 +16,7 @@
|
||||
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;
|
||||
|
||||
@ -23,16 +24,15 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
|
||||
public static Class get() {
|
||||
List<Declaration> declarations = List.of(
|
||||
new Declaration(
|
||||
new Id("x"),
|
||||
"x",
|
||||
Type.INT
|
||||
)
|
||||
);
|
||||
List<Constructor> constructors = getConstructors();
|
||||
return new Class(
|
||||
new Id("ClassWithConstructorWithParameters"),
|
||||
"ClassWithConstructorWithParameters",
|
||||
declarations,
|
||||
List.of(),
|
||||
null,
|
||||
constructors
|
||||
);
|
||||
}
|
||||
@ -56,36 +56,48 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("x")),
|
||||
new Id("startValue")
|
||||
"x"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"startValue")
|
||||
),
|
||||
new While(
|
||||
new Binary(
|
||||
new Id("repetitions"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"repetitions"),
|
||||
Operator.GT,
|
||||
new IntLiteral(0)
|
||||
),
|
||||
new Block(
|
||||
List.of(
|
||||
new LocalVariable(
|
||||
new Id("innerRepetitions"),
|
||||
new Declaration(
|
||||
"innerRepetitions",
|
||||
Type.INT
|
||||
)
|
||||
),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("innerRepetitions")),
|
||||
new Id("x")
|
||||
"innerRepetitions"),
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x")
|
||||
),
|
||||
new While(
|
||||
new Binary(
|
||||
new Id("innerRepetitions"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"innerRepetitions"),
|
||||
Operator.GT,
|
||||
new IntLiteral(0)
|
||||
),
|
||||
@ -93,22 +105,32 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("x")),
|
||||
"x"),
|
||||
new Binary(
|
||||
new Id("x"),
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x"),
|
||||
Operator.MUL,
|
||||
new Id("x")
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"x")
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("innerRepetitions")),
|
||||
new Binary(new Id("innerRepetitions"),
|
||||
"innerRepetitions"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"innerRepetitions"),
|
||||
Operator.SUB,
|
||||
new IntLiteral(1))
|
||||
|
||||
@ -117,11 +139,15 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
|
||||
)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("repetitions")),
|
||||
new Binary(new Id("repetitions"),
|
||||
"repetitions"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"repetitions"),
|
||||
Operator.SUB,
|
||||
new IntLiteral(1)
|
||||
)
|
||||
@ -132,8 +158,7 @@ public class AbstractSyntax_ClassWithConstructorWithParameters {
|
||||
)
|
||||
);
|
||||
return new Constructor(
|
||||
true,
|
||||
new Id("classWithConstructorWithParameters"),
|
||||
"classWithConstructorWithParameters",
|
||||
parameters,
|
||||
block
|
||||
);
|
||||
|
@ -6,6 +6,7 @@ import de.maishai.ast.records.Class;
|
||||
import de.maishai.ast.records.Constructor;
|
||||
import de.maishai.ast.records.Declaration;
|
||||
import de.maishai.ast.records.Method;
|
||||
import de.maishai.typedast.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -13,17 +14,16 @@ public class AbstractSyntax_ClassWithField {
|
||||
public static Class get() {
|
||||
List<Declaration> declarations = List.of(
|
||||
new Declaration(
|
||||
new Id("x"),
|
||||
"x",
|
||||
Type.INT
|
||||
)
|
||||
);
|
||||
List<Method> methods = List.of();
|
||||
List<Constructor> constructors = List.of();
|
||||
return new Class(
|
||||
new Id("ClassWithAssignment"),
|
||||
"ClassWithAssignment",
|
||||
declarations,
|
||||
methods,
|
||||
null,
|
||||
constructors
|
||||
);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
import de.maishai.ast.records.Class;
|
||||
import de.maishai.ast.records.*;
|
||||
import de.maishai.typedast.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -13,10 +14,9 @@ public class AbstractSyntax_ClassWithMethod {
|
||||
public static Class get() {
|
||||
List<Method> methods = getMethods();
|
||||
return new Class(
|
||||
new Id("ClassWithMethod"),
|
||||
"ClassWithMethod",
|
||||
List.of(),
|
||||
methods,
|
||||
null,
|
||||
List.of()
|
||||
);
|
||||
}
|
||||
@ -27,8 +27,8 @@ public class AbstractSyntax_ClassWithMethod {
|
||||
|
||||
private static Method getMethod1() {
|
||||
return new Method(
|
||||
ReturnType.BOOL,
|
||||
new Id("method"),
|
||||
Type.BOOL,
|
||||
"method",
|
||||
List.of(),
|
||||
new Block(
|
||||
List.of(),
|
||||
|
@ -13,6 +13,7 @@
|
||||
import de.maishai.ast.*;
|
||||
import de.maishai.ast.records.*;
|
||||
import de.maishai.ast.records.Class;
|
||||
import de.maishai.typedast.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -20,17 +21,16 @@ class AbstractSyntax_ClassWithMethodAndField {
|
||||
public static Class get() {
|
||||
List<Declaration> declarations = List.of(
|
||||
new Declaration(
|
||||
new Id("c"),
|
||||
"c",
|
||||
Type.CHAR
|
||||
)
|
||||
);
|
||||
List<Method> methods = getMethods();
|
||||
List<Constructor> constructors = getConstructors();
|
||||
return new Class(
|
||||
new Id("ClassWithMethodAndField"),
|
||||
"ClassWithMethodAndField",
|
||||
declarations,
|
||||
methods,
|
||||
null,
|
||||
constructors
|
||||
);
|
||||
}
|
||||
@ -41,8 +41,7 @@ class AbstractSyntax_ClassWithMethodAndField {
|
||||
|
||||
private static Constructor getConstructor1() {
|
||||
return new Constructor(
|
||||
true,
|
||||
new Id("ClassWithMethodAndField"),
|
||||
"ClassWithMethodAndField",
|
||||
List.of(
|
||||
new Parameter(
|
||||
"character",
|
||||
@ -53,11 +52,14 @@ class AbstractSyntax_ClassWithMethodAndField {
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("c")),
|
||||
new Id("character")
|
||||
"c"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"character")
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -70,8 +72,8 @@ class AbstractSyntax_ClassWithMethodAndField {
|
||||
|
||||
private static Method getMethod1() {
|
||||
return new Method(
|
||||
ReturnType.BOOL,
|
||||
new Id("method"),
|
||||
Type.BOOL,
|
||||
"method",
|
||||
List.of(),
|
||||
new Block(
|
||||
List.of(),
|
||||
|
@ -13,72 +13,73 @@
|
||||
// return returnValue;
|
||||
// }
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
// instance = new ClassWithMoreComplexMethodAndMain()
|
||||
// public void setInstance(ClassWithMoreComplexMethodAndMain setInstance) {
|
||||
// this.instance = setInstance;
|
||||
// }
|
||||
//}
|
||||
|
||||
import de.maishai.ast.*;
|
||||
import de.maishai.ast.records.*;
|
||||
import de.maishai.ast.records.Class;
|
||||
import de.maishai.typedast.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AbstractSyntax_ClassWithMoreComplexMethodAndMain {
|
||||
public static Class get() {
|
||||
Type TypeClassWithMoreComplexMethodAndMain = Type.OBJECT;
|
||||
TypeClassWithMoreComplexMethodAndMain.setObjectType(new Id("ClassWithMoreComplexMethodAndMain"));
|
||||
List<Declaration> declarations = List.of(
|
||||
new Declaration(
|
||||
new Id("instance"),
|
||||
TypeClassWithMoreComplexMethodAndMain
|
||||
"instance",
|
||||
Type.REFERENCE("ClassWithMoreComplexMethodAndMain")
|
||||
)
|
||||
);
|
||||
List<Method> methods = getMethods();
|
||||
List<Constructor> constructors = List.of();
|
||||
return new Class(
|
||||
new Id("ClassWithMoreComplexMethodAndMain"),
|
||||
"ClassWithMoreComplexMethodAndMain",
|
||||
declarations,
|
||||
methods,
|
||||
getMainMethod(),
|
||||
constructors
|
||||
);
|
||||
}
|
||||
|
||||
private static List<Method> getMethods() {
|
||||
return List.of(getMethod1());
|
||||
return List.of(getMethod1(), getMethod2());
|
||||
}
|
||||
|
||||
private static Method getMethod1() {
|
||||
Block block = new Block(
|
||||
List.of(
|
||||
new LocalVariable(
|
||||
new Id("i"),
|
||||
new Declaration(
|
||||
"i",
|
||||
Type.INT
|
||||
),
|
||||
new LocalVariable(
|
||||
new Id("returnValue"),
|
||||
new Declaration(
|
||||
"returnValue",
|
||||
Type.BOOL
|
||||
)
|
||||
),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("i")),
|
||||
"i"),
|
||||
new IntLiteral(11)
|
||||
),
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("returnValue")),
|
||||
"returnValue"),
|
||||
new BoolLiteral(false)
|
||||
),
|
||||
new While(
|
||||
new Binary(
|
||||
new Id("i"),
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"i"),
|
||||
Operator.GT,
|
||||
new IntLiteral(0)
|
||||
),
|
||||
@ -86,62 +87,80 @@ public class AbstractSyntax_ClassWithMoreComplexMethodAndMain {
|
||||
List.of(),
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
new Id("i")),
|
||||
new Binary(new Id("i"),
|
||||
"i"),
|
||||
new Binary(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"i"),
|
||||
Operator.SUB,
|
||||
new IntLiteral(1))
|
||||
|
||||
),
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
new Id("returnValue")),
|
||||
"returnValue"
|
||||
),
|
||||
new Unary(
|
||||
UnaryOperator.NOT,
|
||||
new Id("returnValue")
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"returnValue")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
new Return(
|
||||
new Id("returnValue")
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"returnValue")
|
||||
)
|
||||
)
|
||||
);
|
||||
return new Method(
|
||||
ReturnType.BOOL,
|
||||
new Id("moreComplexMethod"),
|
||||
Type.BOOL,
|
||||
"moreComplexMethod",
|
||||
List.of(),
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private static MainMethod getMainMethod() {
|
||||
Type TypeClassWithMoreComplexMethodAndMain = Type.OBJECT;
|
||||
TypeClassWithMoreComplexMethodAndMain.setObjectType(new Id("ClassWithMoreComplexMethodAndMain"));
|
||||
List<Statement> statementList = List.of(
|
||||
new Assignment(
|
||||
new FieldId(
|
||||
true,
|
||||
null,
|
||||
new Id("instance")),
|
||||
new New(
|
||||
TypeClassWithMoreComplexMethodAndMain,
|
||||
List.of()
|
||||
)
|
||||
private static Method getMethod2() {
|
||||
List<Parameter> parameters = List.of(
|
||||
new Parameter(
|
||||
"setInstance",
|
||||
Type.REFERENCE("ClassWithMoreComplexMethodAndMain")
|
||||
)
|
||||
);
|
||||
|
||||
Block block = new Block(
|
||||
List.of(),
|
||||
statementList
|
||||
List.of(
|
||||
new Assignment(
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"instance"),
|
||||
new FieldVarAccess(
|
||||
true,
|
||||
null,
|
||||
"setInstance")
|
||||
)
|
||||
)
|
||||
);
|
||||
return new MainMethod(
|
||||
return new Method(
|
||||
Type.VOID,
|
||||
"setInstance",
|
||||
parameters,
|
||||
block
|
||||
);
|
||||
}
|
||||
|
@ -9,10 +9,9 @@ import java.util.List;
|
||||
public class AbstractSyntax_OnlyClass {
|
||||
public static Class get() {
|
||||
return new Class(
|
||||
new Id("OnlyClass"),
|
||||
"OnlyClass",
|
||||
List.of(),
|
||||
List.of(),
|
||||
null,
|
||||
List.of()
|
||||
);
|
||||
}
|
||||
|
@ -8,10 +8,9 @@ import java.util.List;
|
||||
public class AbstractSyntax_PublicClass {
|
||||
public static Class get() {
|
||||
return new Class(
|
||||
new Id("PublicClass"),
|
||||
"PublicClass",
|
||||
List.of(),
|
||||
List.of(),
|
||||
null,
|
||||
List.of()
|
||||
);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class ClassWithMoreComplexMethodAndMain {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
instance = new ClassWithMoreComplexMethodAndMain()
|
||||
public void setInstance(ClassWithMoreComplexMethodAndMain setInstance) {
|
||||
this.instance = setInstance;
|
||||
}
|
||||
}
|
@ -19,135 +19,135 @@ import de.maishai.typedast.typedclass.*;
|
||||
import java.util.List;
|
||||
|
||||
public class TypedAbstractSyntax_ClassWithConstructor {
|
||||
public static TypedClass get() {
|
||||
TypedClass typedClass = new TypedClass();
|
||||
typedClass.setIsPublic(true);
|
||||
typedClass.setTypedId(new TypedId("ClassWithConstructor"));
|
||||
|
||||
TypedField typedField = new TypedField();
|
||||
typedField.setTypedId(new TypedId("x"));
|
||||
typedField.setType(Type.INT);
|
||||
|
||||
typedClass.setTypedFields(List.of(typedField));
|
||||
typedClass.setTypedMethods(List.of());
|
||||
typedClass.setTypedMainMethod(null);
|
||||
typedClass.setTypedConstructors(getConstructors());
|
||||
return typedClass;
|
||||
}
|
||||
|
||||
private static List<TypedConstructor> getConstructors() {
|
||||
return List.of(getConstructor1());
|
||||
}
|
||||
|
||||
private static TypedConstructor getConstructor1() {
|
||||
TypedConstructor typedConstructor = new TypedConstructor();
|
||||
typedConstructor.setIsPublic(true);
|
||||
typedConstructor.setTypedId(new TypedId("ClassWithConstructor"));
|
||||
typedConstructor.setTypedParameters(List.of());
|
||||
|
||||
TypedBlock typedBlock = new TypedBlock();
|
||||
|
||||
TypedLocalVariable typedLocalVariable = new TypedLocalVariable();
|
||||
typedLocalVariable.setTypedId(new TypedId("i"));
|
||||
typedLocalVariable.setType(Type.INT);
|
||||
|
||||
typedBlock.setVars(List.of(typedLocalVariable));
|
||||
|
||||
TypedAssignment typedAssignment = new TypedAssignment();
|
||||
typedAssignment.setLoc(new TypedId("x"));
|
||||
// typedAssignment.setAssignSign(AssignSign.ASSIGN);
|
||||
typedAssignment.setValue(new TypedIntLiteral(10));
|
||||
|
||||
TypedFor typedFor = new TypedFor();
|
||||
|
||||
TypedAssignment typedAssignmentFor = new TypedAssignment();
|
||||
typedAssignmentFor.setLoc(new TypedId("i"));
|
||||
// typedAssignmentFor.setAssignSign(AssignSign.ASSIGN);
|
||||
typedAssignmentFor.setValue(new TypedIntLiteral(0));
|
||||
|
||||
// typedFor.setAssign(typedAssignmentFor);
|
||||
|
||||
TypedBinary typedBinaryFor = new TypedBinary();
|
||||
typedBinaryFor.setLeft(new TypedId("i"));
|
||||
typedBinaryFor.setOp(Operator.LT);
|
||||
typedBinaryFor.setRight(new TypedIntLiteral(6));
|
||||
|
||||
typedFor.setCond(typedBinaryFor);
|
||||
|
||||
TypedBinary typedBinaryForIncr = new TypedBinary();
|
||||
typedBinaryForIncr.setLeft(new TypedId("i"));
|
||||
typedBinaryForIncr.setOp(Operator.ADD);
|
||||
typedBinaryForIncr.setRight(new TypedIntLiteral(1));
|
||||
|
||||
TypedAssignment typedAssignmentForIncr = new TypedAssignment();
|
||||
typedAssignmentForIncr.setLoc(new TypedId("i"));
|
||||
// typedAssignmentForIncr.setAssignSign(AssignSign.ASSIGN);
|
||||
typedAssignmentForIncr.setValue(typedBinaryForIncr);
|
||||
|
||||
// typedFor.setInc(typedAssignmentForIncr);
|
||||
|
||||
TypedBlock typedBlockFor = new TypedBlock();
|
||||
|
||||
TypedLocalVariable typedLocalVariableFor = new TypedLocalVariable();
|
||||
typedLocalVariableFor.setTypedId(new TypedId("j"));
|
||||
typedLocalVariableFor.setType(Type.INT);
|
||||
|
||||
typedBlockFor.setVars(List.of(typedLocalVariableFor));
|
||||
|
||||
TypedFor typedInnerFor = new TypedFor();
|
||||
|
||||
TypedAssignment typedAssignmentInnerFor = new TypedAssignment();
|
||||
typedAssignmentInnerFor.setLoc(new TypedId("j"));
|
||||
// typedAssignmentInnerFor.setAssignSign(AssignSign.ASSIGN);
|
||||
typedAssignmentInnerFor.setValue(new TypedIntLiteral(0));
|
||||
|
||||
// typedInnerFor.setAssign(typedAssignmentInnerFor);
|
||||
|
||||
TypedBinary typedBinaryInnerFor = new TypedBinary();
|
||||
typedBinaryInnerFor.setLeft(new TypedId("j"));
|
||||
typedBinaryInnerFor.setOp(Operator.LT);
|
||||
typedBinaryInnerFor.setRight(new TypedId("x"));
|
||||
|
||||
typedInnerFor.setCond(typedBinaryInnerFor);
|
||||
|
||||
TypedAssignment typedAssignmentInnerForIncr = new TypedAssignment();
|
||||
typedAssignmentInnerForIncr.setLoc(new TypedId("j"));
|
||||
// typedAssignmentInnerForIncr.setAssignSign(AssignSign.ADD_ASSIGN);
|
||||
typedAssignmentInnerForIncr.setValue(new TypedIntLiteral(1));
|
||||
|
||||
// typedInnerFor.setInc(typedAssignmentInnerForIncr);
|
||||
|
||||
TypedBlock typedBlockInnerFor = new TypedBlock();
|
||||
typedBlockInnerFor.setVars(List.of());
|
||||
|
||||
TypedAssignment typedAssignmentInnerForBlock = new TypedAssignment();
|
||||
typedAssignmentInnerForBlock.setLoc(new TypedId("x"));
|
||||
// typedAssignmentInnerForBlock.setAssignSign(AssignSign.ASSIGN);
|
||||
|
||||
TypedBinary typedBinaryInnerForBlock = new TypedBinary();
|
||||
typedBinaryInnerForBlock.setLeft(new TypedId("x"));
|
||||
typedBinaryInnerForBlock.setOp(Operator.MUL);
|
||||
typedBinaryInnerForBlock.setRight(new TypedId("x"));
|
||||
|
||||
typedAssignmentInnerForBlock.setValue(typedBinaryInnerForBlock);
|
||||
|
||||
typedBlockInnerFor.setStmts(List.of(typedAssignmentInnerForBlock));
|
||||
|
||||
typedInnerFor.setTypedBlock(typedBlockInnerFor);
|
||||
|
||||
typedBlockFor.setStmts(List.of(typedInnerFor));
|
||||
|
||||
typedFor.setTypedBlock(typedBlockFor);
|
||||
|
||||
typedBlock.setStmts(
|
||||
List.of(
|
||||
typedAssignment,
|
||||
typedFor
|
||||
)
|
||||
);
|
||||
|
||||
typedConstructor.setTypedBlock(typedBlock);
|
||||
|
||||
return typedConstructor;
|
||||
}
|
||||
// public static TypedClass get() {
|
||||
// TypedClass typedClass = new TypedClass();
|
||||
// typedClass.setIsPublic(true);
|
||||
// typedClass.setTypedId(new TypedId("ClassWithConstructor"));
|
||||
//
|
||||
// TypedField typedField = new TypedField();
|
||||
// typedField.setTypedId(new TypedId("x"));
|
||||
// typedField.setType(Type.INT);
|
||||
//
|
||||
// typedClass.setTypedFields(List.of(typedField));
|
||||
// typedClass.setTypedMethods(List.of());
|
||||
// typedClass.setTypedMainMethod(null);
|
||||
// typedClass.setTypedConstructors(getConstructors());
|
||||
// return typedClass;
|
||||
// }
|
||||
//
|
||||
// private static List<TypedConstructor> getConstructors() {
|
||||
// return List.of(getConstructor1());
|
||||
// }
|
||||
//
|
||||
// private static TypedConstructor getConstructor1() {
|
||||
// TypedConstructor typedConstructor = new TypedConstructor();
|
||||
// typedConstructor.setIsPublic(true);
|
||||
// typedConstructor.setTypedId(new TypedId("ClassWithConstructor"));
|
||||
// typedConstructor.setTypedParameters(List.of());
|
||||
//
|
||||
// TypedBlock typedBlock = new TypedBlock();
|
||||
//
|
||||
// TypedLocalVariable typedLocalVariable = new TypedLocalVariable();
|
||||
// typedLocalVariable.setTypedId(new TypedId("i"));
|
||||
// typedLocalVariable.setType(Type.INT);
|
||||
//
|
||||
// typedBlock.setVars(List.of(typedLocalVariable));
|
||||
//
|
||||
// TypedAssignment typedAssignment = new TypedAssignment();
|
||||
// typedAssignment.setLoc(new TypedId("x"));
|
||||
//// typedAssignment.setAssignSign(AssignSign.ASSIGN);
|
||||
// typedAssignment.setValue(new TypedIntLiteral(10));
|
||||
//
|
||||
// TypedFor typedFor = new TypedFor();
|
||||
//
|
||||
// TypedAssignment typedAssignmentFor = new TypedAssignment();
|
||||
// typedAssignmentFor.setLoc(new TypedId("i"));
|
||||
//// typedAssignmentFor.setAssignSign(AssignSign.ASSIGN);
|
||||
// typedAssignmentFor.setValue(new TypedIntLiteral(0));
|
||||
//
|
||||
//// typedFor.setAssign(typedAssignmentFor);
|
||||
//
|
||||
// TypedBinary typedBinaryFor = new TypedBinary();
|
||||
// typedBinaryFor.setLeft(new TypedId("i"));
|
||||
// typedBinaryFor.setOp(Operator.LT);
|
||||
// typedBinaryFor.setRight(new TypedIntLiteral(6));
|
||||
//
|
||||
// typedFor.setCond(typedBinaryFor);
|
||||
//
|
||||
// TypedBinary typedBinaryForIncr = new TypedBinary();
|
||||
// typedBinaryForIncr.setLeft(new TypedId("i"));
|
||||
// typedBinaryForIncr.setOp(Operator.ADD);
|
||||
// typedBinaryForIncr.setRight(new TypedIntLiteral(1));
|
||||
//
|
||||
// TypedAssignment typedAssignmentForIncr = new TypedAssignment();
|
||||
// typedAssignmentForIncr.setLoc(new TypedId("i"));
|
||||
//// typedAssignmentForIncr.setAssignSign(AssignSign.ASSIGN);
|
||||
// typedAssignmentForIncr.setValue(typedBinaryForIncr);
|
||||
//
|
||||
//// typedFor.setInc(typedAssignmentForIncr);
|
||||
//
|
||||
// TypedBlock typedBlockFor = new TypedBlock();
|
||||
//
|
||||
// TypedLocalVariable typedLocalVariableFor = new TypedLocalVariable();
|
||||
// typedLocalVariableFor.setTypedId(new TypedId("j"));
|
||||
// typedLocalVariableFor.setType(Type.INT);
|
||||
//
|
||||
// typedBlockFor.setVars(List.of(typedLocalVariableFor));
|
||||
//
|
||||
// TypedFor typedInnerFor = new TypedFor();
|
||||
//
|
||||
// TypedAssignment typedAssignmentInnerFor = new TypedAssignment();
|
||||
// typedAssignmentInnerFor.setLoc(new TypedId("j"));
|
||||
//// typedAssignmentInnerFor.setAssignSign(AssignSign.ASSIGN);
|
||||
// typedAssignmentInnerFor.setValue(new TypedIntLiteral(0));
|
||||
//
|
||||
//// typedInnerFor.setAssign(typedAssignmentInnerFor);
|
||||
//
|
||||
// TypedBinary typedBinaryInnerFor = new TypedBinary();
|
||||
// typedBinaryInnerFor.setLeft(new TypedId("j"));
|
||||
// typedBinaryInnerFor.setOp(Operator.LT);
|
||||
// typedBinaryInnerFor.setRight(new TypedId("x"));
|
||||
//
|
||||
// typedInnerFor.setCond(typedBinaryInnerFor);
|
||||
//
|
||||
// TypedAssignment typedAssignmentInnerForIncr = new TypedAssignment();
|
||||
// typedAssignmentInnerForIncr.setLoc(new TypedId("j"));
|
||||
//// typedAssignmentInnerForIncr.setAssignSign(AssignSign.ADD_ASSIGN);
|
||||
// typedAssignmentInnerForIncr.setValue(new TypedIntLiteral(1));
|
||||
//
|
||||
//// typedInnerFor.setInc(typedAssignmentInnerForIncr);
|
||||
//
|
||||
// TypedBlock typedBlockInnerFor = new TypedBlock();
|
||||
// typedBlockInnerFor.setVars(List.of());
|
||||
//
|
||||
// TypedAssignment typedAssignmentInnerForBlock = new TypedAssignment();
|
||||
// typedAssignmentInnerForBlock.setLoc(new TypedId("x"));
|
||||
//// typedAssignmentInnerForBlock.setAssignSign(AssignSign.ASSIGN);
|
||||
//
|
||||
// TypedBinary typedBinaryInnerForBlock = new TypedBinary();
|
||||
// typedBinaryInnerForBlock.setLeft(new TypedId("x"));
|
||||
// typedBinaryInnerForBlock.setOp(Operator.MUL);
|
||||
// typedBinaryInnerForBlock.setRight(new TypedId("x"));
|
||||
//
|
||||
// typedAssignmentInnerForBlock.setValue(typedBinaryInnerForBlock);
|
||||
//
|
||||
// typedBlockInnerFor.setStmts(List.of(typedAssignmentInnerForBlock));
|
||||
//
|
||||
// typedInnerFor.setTypedBlock(typedBlockInnerFor);
|
||||
//
|
||||
// typedBlockFor.setStmts(List.of(typedInnerFor));
|
||||
//
|
||||
// typedFor.setTypedBlock(typedBlockFor);
|
||||
//
|
||||
// typedBlock.setStmts(
|
||||
// List.of(
|
||||
// typedAssignment,
|
||||
// typedFor
|
||||
// )
|
||||
// );
|
||||
//
|
||||
// typedConstructor.setTypedBlock(typedBlock);
|
||||
//
|
||||
// return typedConstructor;
|
||||
// }
|
||||
}
|
@ -9,18 +9,18 @@ import de.maishai.typedast.typedclass.*;
|
||||
import java.util.List;
|
||||
|
||||
public class TypedAbstractSyntax_ClassWithField {
|
||||
public static TypedClass get() {
|
||||
TypedClass typedClass = new TypedClass();
|
||||
typedClass.setIsPublic(true);
|
||||
typedClass.setTypedId(new TypedId("ClassWithField"));
|
||||
typedClass.setTypedFields(
|
||||
List.of(
|
||||
new TypedField(new TypedId("x"), Type.INT)
|
||||
)
|
||||
);
|
||||
typedClass.setTypedMethods(List.of());
|
||||
typedClass.setTypedMainMethod(null);
|
||||
typedClass.setTypedConstructors(List.of());
|
||||
return typedClass;
|
||||
}
|
||||
// public static TypedClass get() {
|
||||
// TypedClass typedClass = new TypedClass();
|
||||
// typedClass.setIsPublic(true);
|
||||
// typedClass.setTypedId(new TypedId("ClassWithField"));
|
||||
// typedClass.setTypedFields(
|
||||
// List.of(
|
||||
// new TypedField(new TypedId("x"), Type.INT)
|
||||
// )
|
||||
// );
|
||||
// typedClass.setTypedMethods(List.of());
|
||||
// typedClass.setTypedMainMethod(null);
|
||||
// typedClass.setTypedConstructors(List.of());
|
||||
// return typedClass;
|
||||
// }
|
||||
}
|
@ -10,37 +10,37 @@ import de.maishai.typedast.typedclass.*;
|
||||
import java.util.List;
|
||||
|
||||
public class TypedAbstractSyntax_ClassWithMethod {
|
||||
public static TypedClass get() {
|
||||
TypedClass typedClass = new TypedClass();
|
||||
typedClass.setIsPublic(true);
|
||||
typedClass.setTypedId(new TypedId("ClassWithMethod"));
|
||||
typedClass.setTypedFields(List.of());
|
||||
typedClass.setTypedMethods(getMethods());
|
||||
return typedClass;
|
||||
}
|
||||
|
||||
private static List<TypedMethod> getMethods() {
|
||||
return List.of(getMethod1());
|
||||
}
|
||||
|
||||
private static TypedMethod getMethod1() {
|
||||
TypedMethod typedMethod = new TypedMethod();
|
||||
typedMethod.setIsPublic(true);
|
||||
typedMethod.setTypedId(new TypedId("method"));
|
||||
typedMethod.setReturnType(Type.BOOL);
|
||||
typedMethod.setTypedParameters(List.of());
|
||||
|
||||
TypedBoolLiteral typedBoolLiteral = new TypedBoolLiteral();
|
||||
typedBoolLiteral.setValue(false);
|
||||
|
||||
TypedReturn typedReturn = new TypedReturn();
|
||||
typedReturn.setRet(typedBoolLiteral);
|
||||
|
||||
TypedBlock typedBlock = new TypedBlock();
|
||||
typedBlock.setVars(List.of());
|
||||
typedBlock.setStmts(List.of(typedReturn));
|
||||
|
||||
typedMethod.setTypedBlock(typedBlock);
|
||||
return typedMethod;
|
||||
}
|
||||
// public static TypedClass get() {
|
||||
// TypedClass typedClass = new TypedClass();
|
||||
// typedClass.setIsPublic(true);
|
||||
// typedClass.setTypedId(new TypedId("ClassWithMethod"));
|
||||
// typedClass.setTypedFields(List.of());
|
||||
// typedClass.setTypedMethods(getMethods());
|
||||
// return typedClass;
|
||||
// }
|
||||
//
|
||||
// private static List<TypedMethod> getMethods() {
|
||||
// return List.of(getMethod1());
|
||||
// }
|
||||
//
|
||||
// private static TypedMethod getMethod1() {
|
||||
// TypedMethod typedMethod = new TypedMethod();
|
||||
// typedMethod.setIsPublic(true);
|
||||
// typedMethod.setTypedId(new TypedId("method"));
|
||||
// typedMethod.setReturnType(Type.BOOL);
|
||||
// typedMethod.setTypedParameters(List.of());
|
||||
//
|
||||
// TypedBoolLiteral typedBoolLiteral = new TypedBoolLiteral();
|
||||
// typedBoolLiteral.setValue(false);
|
||||
//
|
||||
// TypedReturn typedReturn = new TypedReturn();
|
||||
// typedReturn.setRet(typedBoolLiteral);
|
||||
//
|
||||
// TypedBlock typedBlock = new TypedBlock();
|
||||
// typedBlock.setVars(List.of());
|
||||
// typedBlock.setStmts(List.of(typedReturn));
|
||||
//
|
||||
// typedMethod.setTypedBlock(typedBlock);
|
||||
// return typedMethod;
|
||||
// }
|
||||
}
|
@ -6,14 +6,14 @@ import de.maishai.typedast.typedclass.*;
|
||||
import java.util.List;
|
||||
|
||||
public class TypedAbstractSyntax_OnlyClass {
|
||||
public static TypedClass get() {
|
||||
TypedClass typedClass = new TypedClass();
|
||||
typedClass.setIsPublic(false);
|
||||
typedClass.setTypedId(new TypedId("OnlyClass"));
|
||||
typedClass.setTypedFields(List.of());
|
||||
typedClass.setTypedMethods(List.of());
|
||||
typedClass.setTypedMainMethod(null);
|
||||
typedClass.setTypedConstructors(List.of());
|
||||
return typedClass;
|
||||
}
|
||||
// public static TypedClass get() {
|
||||
// TypedClass typedClass = new TypedClass();
|
||||
// typedClass.setIsPublic(false);
|
||||
// typedClass.setTypedId(new TypedId("OnlyClass"));
|
||||
// typedClass.setTypedFields(List.of());
|
||||
// typedClass.setTypedMethods(List.of());
|
||||
// typedClass.setTypedMainMethod(null);
|
||||
// typedClass.setTypedConstructors(List.of());
|
||||
// return typedClass;
|
||||
// }
|
||||
}
|
@ -6,14 +6,14 @@ import de.maishai.typedast.typedclass.*;
|
||||
import java.util.List;
|
||||
|
||||
public class TypedAbstractSyntax_PublicClass {
|
||||
public static TypedClass get() {
|
||||
TypedClass typedClass = new TypedClass();
|
||||
typedClass.setIsPublic(true);
|
||||
typedClass.setTypedId(new TypedId("PublicClass"));
|
||||
typedClass.setTypedFields(List.of());
|
||||
typedClass.setTypedMethods(List.of());
|
||||
typedClass.setTypedMainMethod(null);
|
||||
typedClass.setTypedConstructors(List.of());
|
||||
return typedClass;
|
||||
}
|
||||
// public static TypedClass get() {
|
||||
// TypedClass typedClass = new TypedClass();
|
||||
// typedClass.setIsPublic(true);
|
||||
// typedClass.setTypedId(new TypedId("PublicClass"));
|
||||
// typedClass.setTypedFields(List.of());
|
||||
// typedClass.setTypedMethods(List.of());
|
||||
// typedClass.setTypedMainMethod(null);
|
||||
// typedClass.setTypedConstructors(List.of());
|
||||
// return typedClass;
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user