Changed For Loop Structure
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
i22035 2024-06-30 22:17:52 +02:00
parent dfded3e592
commit 2ae0988986
3 changed files with 35 additions and 2 deletions

View File

@ -207,10 +207,17 @@ public class ASTBuilder extends SimpleJavaBaseVisitor<ASTNode> {
crement = (IStatementNode) visit(ctx.statementExpression(i));
}
BlockNode forBlock = (BlockNode) visit(ctx.blockStatement());
BlockNode forBlock = new BlockNode();
BlockNode forStatements = (BlockNode) visit(ctx.blockStatement());
if(forStatements != null) {
forBlock.addStatement((IStatementNode) forStatements);
}
if(crement != null){
forBlock.addStatement((crement));
BlockNode forCrement = new BlockNode();
forCrement.addStatement((crement));
forBlock.addStatement(forCrement);
}
WhileNode While = new WhileNode(condition, forBlock);

View File

@ -200,6 +200,20 @@ class AstBuilderTest {
//assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
}
//Noch nicht speziell Increment nur zum Development Testen per Debug
@Test
@DisplayName("Increment Test")
public void incrementTest(){
ClassNode classNode = Helper.generateEmptyClass("TestClass");
classNode.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a"));
ProgramNode expected = new ProgramNode();
expected.addClass(classNode);
ASTNode actual = Helper.generateAST("src/test/resources/input/javaCases/Increment.java");
assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);
}

View File

@ -0,0 +1,12 @@
public class Increment {
public int test;
public void increment(int p) {
test = p++;
for(int i = 1; i<=10, i++) {
int a = 5;
}
}
}