From 88c78342d5b012a94599df5dc4264836ba8e9532 Mon Sep 17 00:00:00 2001 From: FelixKrespach Date: Sun, 1 Oct 2017 09:58:56 +0200 Subject: [PATCH] Final --- src/de/dhbwstuttgart/syntaxtree/statement/SwitchStmt.java | 1 + .../dhbwstuttgart/syntaxtree/visual/OutputGenerator.java | 6 ++++-- test/parser/WhileTest.jav | 6 +++--- test/typeinference/JavaTXCompilerTest.java | 8 ++++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/SwitchStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/SwitchStmt.java index 39af652d..a513a025 100644 --- a/src/de/dhbwstuttgart/syntaxtree/statement/SwitchStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/SwitchStmt.java @@ -11,6 +11,7 @@ public class SwitchStmt extends Statement { public final Expression expr; public final Block switchBlock; + public SwitchStmt(RefTypeOrTPHOrWildcardOrGeneric type,Expression expr, Block block, Token offset){ super(type,offset); this.expr=expr; diff --git a/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java b/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java index 409745f1..f373e6c7 100644 --- a/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java +++ b/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java @@ -212,7 +212,7 @@ public class OutputGenerator implements ASTVisitor { @Override public void visit(BreakStmt breakStmt) { - out.append("break" + breakStmt.indentifier+";"); + out.append("break"+ " " + breakStmt.indentifier); } @Override @@ -238,8 +238,10 @@ public class OutputGenerator implements ASTVisitor { @Override public void visit(IfStmt ifStmt) { - out.append("if"); + out.append("if ("); ifStmt.expr.accept(this); + out.append(")"); + //TODO implement to set ; if then block is empty ifStmt.then_block.accept(this); out.append("else"); ifStmt.else_block.accept(this); diff --git a/test/parser/WhileTest.jav b/test/parser/WhileTest.jav index d7ad4065..0e21f7f7 100644 --- a/test/parser/WhileTest.jav +++ b/test/parser/WhileTest.jav @@ -2,13 +2,13 @@ class WhileTest { void methode() { - Boolean BoolTrue=true; + Boolean boolVar=true; do { - }while(testTrue); + }while(boolVar); - while(test) + while(boolVar) { test = test; } diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index ca20f750..a0842e75 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -39,13 +39,13 @@ public class JavaTXCompilerTest extends JavaTXCompiler { //filesToTest.add(new File(rootDirectory+"Matrix.jav")); //filesToTest.add(new File(rootDirectory+"Import.jav")); - filesToTest.add(new File(rootDirectory+"BreakTest.jav")); - filesToTest.add(new File(rootDirectory+"WhileTest.jav")); - filesToTest.add(new File(rootDirectory+"IfTest.jav")); + //filesToTest.add(new File(rootDirectory+"BreakTest.jav")); + //filesToTest.add(new File(rootDirectory+"WhileTest.jav")); + //filesToTest.add(new File(rootDirectory+"IfTest.jav")); filesToTest.add(new File(rootDirectory+"AssertTest.jav")); //filesToTest.add(new File(rootDirectory+"PrePostOperationTest.jav")); //filesToTest.add(new File(rootDirectory+"SwitchTest.jav")); - filesToTest.add(new File(rootDirectory+"WhileTest.jav")); + //filesToTest.add(new File(rootDirectory+"WhileTest.jav")); for(File f : filesToTest){ SourceFile sf = this.parse(f); System.out.println("-------------------------------------|"+f.getName()+"|----------------------------------------------");