NewParser #16

Merged
i22005 merged 5 commits from NewParser into main 2024-07-01 21:07:27 +00:00
3 changed files with 35 additions and 2 deletions
Showing only changes of commit 2ae0988986 - Show all commits

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;
}
}
}