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