From 62e7a1c87179a344be2ec19e43a9411031abbe76 Mon Sep 17 00:00:00 2001 From: luca9913 Date: Wed, 21 Jun 2023 10:10:32 +0200 Subject: [PATCH] Bug fix and test exclusion --- pom.xml | 3 +++ .../de/dhbwstuttgart/parser/antlr/Java17Parser.g4 | 2 +- .../parser/SyntaxTreeGenerator/StatementGenerator.java | 10 +--------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 26ae14e8..c03d39ab 100644 --- a/pom.xml +++ b/pom.xml @@ -63,6 +63,9 @@ http://maven.apache.org/maven-v4_0_0.xsd"> 3.1.0 --enable-preview + + **/JavaTXCompilerTest.java + diff --git a/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 b/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 index 6c658a7c..966b4458 100644 --- a/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 +++ b/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 @@ -475,7 +475,7 @@ blockStatement ; localVariableDeclaration - : variableModifier* (VAR identifier '=' expression | typeType variableDeclarators) + : variableModifier* (VAR | typeType) variableDeclarators ; identifier diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index afe9946a..37b28cb3 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -380,16 +380,8 @@ public class StatementGenerator { } else { type = TypeGenerator.convert(declaration.typeType(), reg, generics); } - if (Objects.isNull(declaration.variableDeclarators())) { - IdentifierContext identifier = declaration.identifier(); - Token offset = identifier.getStart(); - String name = identifier.getText(); - ret.add(new LocalVarDecl(name, type, offset)); - this.localVars.put(name, type); - ret.add(new Assign(new AssignToLocal(new LocalVar(name, type, offset)), convert(declaration.expression()), offset)); - } else { + if (!Objects.isNull(declaration.variableDeclarators())) ret.addAll(generateLocalVariableAssignments(declaration.variableDeclarators().variableDeclarator(), type)); - } return ret; }