From 587d95f54626add179208d3ef91fd270a285eeaf Mon Sep 17 00:00:00 2001 From: JonathanFleischmann Date: Wed, 8 May 2024 14:10:48 +0200 Subject: [PATCH] adapted abstract syntax test files to new ast --- .../AbstractSyntax_ClassWithConstructor.java | 45 +++++++++++++++---- ...tax_ClassWithConstructorAndMethodCall.java | 10 ++++- ...ax_ClassWithConstructorWithParameters.java | 27 ++++++++--- ...bstractSyntax_ClassWithMethodAndField.java | 5 ++- ...tax_ClassWithMoreComplexMethodAndMain.java | 25 ++++++++--- 5 files changed, 90 insertions(+), 22 deletions(-) diff --git a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructor.java b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructor.java index 14aee94..fb450bb 100644 --- a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructor.java +++ b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructor.java @@ -52,21 +52,33 @@ public class AbstractSyntax_ClassWithConstructor { ); List statementList = List.of( new Assignment( - new Id("x"), + new FieldId( + true, + null, + new Id("x")), new IntLiteral(10) ), new For( new Assignment( - new Id("i"), + new FieldId( + false, + null, + new Id("i")), new IntLiteral(0) ), new Binary( - new Id("i"), + new FieldId( + false, + null, + new Id("i")), Operator.LT, new IntLiteral(6) ), new Assignment( - new Id("i"), + new FieldId( + false, + null, + new Id("i")), new Binary( new Id("i"), Operator.ADD, @@ -83,7 +95,10 @@ public class AbstractSyntax_ClassWithConstructor { List.of( new For( new Assignment( - new Id("j"), + new FieldId( + false, + null, + new Id("j")), new IntLiteral(0) ), new Binary( @@ -92,14 +107,27 @@ public class AbstractSyntax_ClassWithConstructor { new Id("x") ), new Assignment( - new Id("j"), - new IntLiteral(1) + new FieldId( + false, + null, + new Id("j")), + new Binary( + new FieldId( + false, + null, + new Id("j")), + Operator.ADD, + new IntLiteral(1) + ) ), new Block( List.of(), List.of( new Assignment( - new Id("x"), + new FieldId( + true, + null, + new Id("x")), new Binary( new Id("x"), Operator.MUL, @@ -112,6 +140,7 @@ public class AbstractSyntax_ClassWithConstructor { ) ) ) + ); Block block = new Block( localVariables, diff --git a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorAndMethodCall.java b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorAndMethodCall.java index 627846f..b3beba8 100644 --- a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorAndMethodCall.java +++ b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorAndMethodCall.java @@ -54,7 +54,10 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall { List.of(), List.of( new Assignment( - new Id("x"), + new FieldId( + true, + null, + new Id("x")), new IntLiteral(10) ), new While( @@ -68,7 +71,10 @@ public class AbstractSyntax_ClassWithConstructorAndMethodCall { List.of(), List.of( new Assignment( - new Id("x"), + new FieldId( + true, + null, + new Id("x")), new Binary( new Id("x"), Operator.MUL, diff --git a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorWithParameters.java b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorWithParameters.java index 2652d37..b311324 100644 --- a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorWithParameters.java +++ b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithConstructorWithParameters.java @@ -57,7 +57,10 @@ public class AbstractSyntax_ClassWithConstructorWithParameters { List.of(), List.of( new Assignment( - new Id("x"), + new FieldId( + true, + null, + new Id("x")), new Id("startValue") ), new While( @@ -75,12 +78,15 @@ public class AbstractSyntax_ClassWithConstructorWithParameters { ), List.of( new Assignment( - new Id("innerRepetitions"), + new FieldId( + false, + null, + new Id("innerRepetitions")), new Id("x") ), new While( new Binary( - new Id("repetitions"), + new Id("innerRepetitions"), Operator.GT, new IntLiteral(0) ), @@ -88,7 +94,10 @@ public class AbstractSyntax_ClassWithConstructorWithParameters { List.of(), List.of( new Assignment( - new Id("x"), + new FieldId( + true, + null, + new Id("x")), new Binary( new Id("x"), Operator.MUL, @@ -96,7 +105,10 @@ public class AbstractSyntax_ClassWithConstructorWithParameters { ) ), new Assignment( - new Id("innerRepetitions"), + new FieldId( + false, + null, + new Id("innerRepetitions")), new Binary(new Id("innerRepetitions"), Operator.SUB, new IntLiteral(1)) @@ -106,7 +118,10 @@ public class AbstractSyntax_ClassWithConstructorWithParameters { ) ), new Assignment( - new Id("repetitions"), + new FieldId( + false, + null, + new Id("repetitions")), new Binary(new Id("repetitions"), Operator.SUB, new IntLiteral(1) diff --git a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMethodAndField.java b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMethodAndField.java index ff54632..7c6834d 100644 --- a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMethodAndField.java +++ b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMethodAndField.java @@ -53,7 +53,10 @@ class AbstractSyntax_ClassWithMethodAndField { List.of(), List.of( new Assignment( - new Id("c"), + new FieldId( + true, + null, + new Id("c")), new Id("character") ) ) diff --git a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMoreComplexMethodAndMain.java b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMoreComplexMethodAndMain.java index 4232798..cb4670b 100644 --- a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMoreComplexMethodAndMain.java +++ b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMoreComplexMethodAndMain.java @@ -63,11 +63,17 @@ public class AbstractSyntax_ClassWithMoreComplexMethodAndMain { ), List.of( new Assignment( - new Id("i"), + new FieldId( + false, + null, + new Id("i")), new IntLiteral(11) ), new Assignment( - new Id("returnValue"), + new FieldId( + false, + null, + new Id("returnValue")), new BoolLiteral(false) ), new While( @@ -80,14 +86,20 @@ public class AbstractSyntax_ClassWithMoreComplexMethodAndMain { List.of(), List.of( new Assignment( - new Id("i"), + new FieldId( + true, + null, + new Id("i")), new Binary(new Id("i"), Operator.SUB, new IntLiteral(1)) ), new Assignment( - new Id("returnValue"), + new FieldId( + false, + null, + new Id("returnValue")), new Unary( UnaryOperator.NOT, new Id("returnValue") @@ -115,7 +127,10 @@ public class AbstractSyntax_ClassWithMoreComplexMethodAndMain { TypeClassWithMoreComplexMethodAndMain.setObjectType(new Id("ClassWithMoreComplexMethodAndMain")); List statementList = List.of( new Assignment( - new Id("instance"), + new FieldId( + true, + null, + new Id("instance")), new New( TypeClassWithMoreComplexMethodAndMain, List.of()