From 881830235ab164c4df22e896944392efd08a7725 Mon Sep 17 00:00:00 2001 From: FelixKrespach Date: Fri, 22 Sep 2017 14:49:43 +0200 Subject: [PATCH] Break Class + Test --- .../StatementGenerator.java | 3 +++ .../syntaxtree/statement/BreakStmt.java | 24 +++++++++++++++++++ .../syntaxtree/visual/OutputGenerator.java | 2 ++ test/parser/BreakTest.jav | 9 +++++++ test/parser/TryCatchTest.jav | 14 +++++++++++ test/parser/WhileTest.jav | 19 ++++++++------- 6 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 src/de/dhbwstuttgart/syntaxtree/statement/BreakStmt.java create mode 100644 test/parser/BreakTest.jav create mode 100644 test/parser/TryCatchTest.jav diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index 45965d6f..c40b7789 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -324,6 +324,7 @@ public class StatementGenerator { private Statement convert(Java8Parser.AssertStatementContext stmt) { + /* if (stmt.expression().size()<2) { Expression expr = convert(stmt.expression(0)); @@ -334,7 +335,9 @@ public class StatementGenerator { Expression expr2 = convert(stmt.expression(1)); return new AssertStmt(expr1,expr2,stmt.getStart()); } + */ //TODO: Check Felix_K + throw new NotImplementedException(); } private Statement convert(Java8Parser.SwitchStatementContext stmt){ diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/BreakStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/BreakStmt.java new file mode 100644 index 00000000..7dcb05be --- /dev/null +++ b/src/de/dhbwstuttgart/syntaxtree/statement/BreakStmt.java @@ -0,0 +1,24 @@ +package de.dhbwstuttgart.syntaxtree.statement; + +import com.sun.scenario.effect.Offset; +import de.dhbwstuttgart.syntaxtree.StatementVisitor; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * Created by Felix_K on 20.09.2017. + */ +public class BreakStmt extends Statement +{ + public final TerminalNode indentifier; + + public BreakStmt(RefTypeOrTPHOrWildcardOrGeneric type, TerminalNode Indentifier, Token offset) + { + super(type, offset); + this.indentifier=Indentifier; + } + @Override + public void accept(StatementVisitor visitor) { + } +} diff --git a/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java b/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java index 0a17df62..a014fb68 100644 --- a/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java +++ b/src/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java @@ -237,6 +237,8 @@ public class OutputGenerator implements ASTVisitor { ifStmt.then_block.accept(this); out.append("\nelse"); ifStmt.else_block.accept(this); + + //TODO Felix_K } @Override diff --git a/test/parser/BreakTest.jav b/test/parser/BreakTest.jav new file mode 100644 index 00000000..0fefbfc1 --- /dev/null +++ b/test/parser/BreakTest.jav @@ -0,0 +1,9 @@ +class BreakTest +{ + void methode() + { + + break; + + } +} \ No newline at end of file diff --git a/test/parser/TryCatchTest.jav b/test/parser/TryCatchTest.jav new file mode 100644 index 00000000..e965d026 --- /dev/null +++ b/test/parser/TryCatchTest.jav @@ -0,0 +1,14 @@ +class TryCatchTest +{ + public void TryTest() + { + try + { + + } + catch() + { + + } + } +} \ No newline at end of file diff --git a/test/parser/WhileTest.jav b/test/parser/WhileTest.jav index 7269793d..e8dc16e7 100644 --- a/test/parser/WhileTest.jav +++ b/test/parser/WhileTest.jav @@ -1,16 +1,17 @@ class WhileTest { - void methode(){ - Boolean test; - do + void methode() { - test=test; - }while(test); + Boolean test; + do + { + test=test; + }while(test); - while(test){ - test = test; - } - return; + while(test) + { + test = test; + } } } \ No newline at end of file