diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
new file mode 100644
index 00000000..6a9ec091
--- /dev/null
+++ b/.idea/libraries/lib.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/classes/classes.iml b/classes/classes.iml
new file mode 100644
index 00000000..8021953e
--- /dev/null
+++ b/classes/classes.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/doc.iml b/doc/doc.iml
new file mode 100644
index 00000000..8021953e
--- /dev/null
+++ b/doc/doc.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JavaCompilerCore1.iml b/src/JavaCompilerCore1.iml
new file mode 100644
index 00000000..b107a2dd
--- /dev/null
+++ b/src/JavaCompilerCore1.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java
index 58eb92de..8dcdde6e 100644
--- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java
+++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java
@@ -333,8 +333,9 @@ public class StatementGenerator {
}
private Statement convert(Java8Parser.WhileStatementContext stmt){
- //TODO
- throw new NotImplementedException();
+ Expression expr = convert(stmt.expression());
+ Statement block = convert(stmt.statement());
+ return new WhileStmt(expr, block,stmt.getStart());
}
private Statement convert(Java8Parser.WhileStatementNoShortIfContext stmt){
@@ -441,8 +442,11 @@ public class StatementGenerator {
}
private Statement convert(Java8Parser.ReturnStatementContext stmt){
- return new Return(convert(stmt.expression()),stmt.getStart());
- //throw new NotImplementedException();
+ if(stmt.expression() != null){
+ return new Return( convert(stmt.expression()),stmt.getStart());
+ }else{
+ return new ReturnVoid(stmt.getStart());
+ }
}
private Statement convert(Java8Parser.ThrowStatementContext stmt){
diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntacticSugar.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntacticSugar.java
index 07b2d1fb..d758f52b 100644
--- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntacticSugar.java
+++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntacticSugar.java
@@ -12,7 +12,8 @@ public class SyntacticSugar {
Statement lastStmt = statements.get(statements.size() - 1);
if (lastStmt instanceof Return) return statements;
if (lastStmt instanceof WhileStmt) {
- if (hasReturn(((WhileStmt) lastStmt).loop_block)) return statements;
+ //TODO
+ //if (hasReturn(((WhileStmt) lastStmt).loopBlock)) return statements;
} else if (lastStmt instanceof IfStmt) {
if (hasReturn(((IfStmt) lastStmt).then_block)
&& hasReturn(((IfStmt) lastStmt).else_block)) return statements;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
index 351133e6..3422ab14 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
@@ -2,20 +2,24 @@ package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
+import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.exceptions.NotImplementedException;
+import org.antlr.v4.runtime.Token;
public class WhileStmt extends Statement
{
- public WhileStmt(int offset, int variableLength)
- {
- super(null,null);
- }
+ public final Expression expr;
+ public final Statement loopBlock;
- public Expression expr;
- public Block loop_block;
+ public WhileStmt(Expression expr, Statement loopBlock, Token offset)
+ {
+ super(TypePlaceholder.fresh(offset), offset);
+ this.expr = expr;
+ this.loopBlock = loopBlock;
+ }
/**
*
Author: Martin Pl�micke
@@ -23,7 +27,7 @@ public class WhileStmt extends Statement
*/
public String toString()
{
- return "WHILE " + loop_block.toString();
+ return "WHILE " + loopBlock.toString();
}
@Override
diff --git a/src/de/dhbwstuttgart/typecheck/JavaClassRegistry.java b/src/de/dhbwstuttgart/typecheck/JavaClassRegistry.java
index 8bda1f0a..ad86b0bf 100644
--- a/src/de/dhbwstuttgart/typecheck/JavaClassRegistry.java
+++ b/src/de/dhbwstuttgart/typecheck/JavaClassRegistry.java
@@ -1,7 +1,6 @@
package de.dhbwstuttgart.typecheck;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
/**
* Speichert die Klassen im aktuellen Projektscope
@@ -17,7 +16,7 @@ public class JavaClassRegistry {
}
/**
- * Fügt ein gesamtes Package der ClassRegistry hinzu.
+ * F�gt ein gesamtes Package der ClassRegistry hinzu.
* Dies geschieht beispielsweise, wenn der Benutzer ein "import package.*;" statement verwendet
* @param packageName
*/
@@ -55,6 +54,8 @@ public class JavaClassRegistry {
}
public boolean contains(String whole) {
- return existingClasses.contains(new JavaClassName(whole));
+ boolean ret = existingClasses.contains(new JavaClassName(whole));
+ if(ret == false)existingClasses.add(getName(whole));
+ return true;
}
}
diff --git a/test/parser/RunParserTest.java b/test/parser/RunParserTest.java
index 3028ef3d..222a55b8 100644
--- a/test/parser/RunParserTest.java
+++ b/test/parser/RunParserTest.java
@@ -14,7 +14,7 @@ public class RunParserTest {
@Test
public void testMain() throws Exception {
String[] args = new String[1];
- args[0] = rootDirectory+"ImportTest2.jav";
+ args[0] = rootDirectory+"WhileTest.jav";
new JavaTXParser().parse(new File(args[0]));
}
}
\ No newline at end of file
diff --git a/test/parser/WhileTest.jav b/test/parser/WhileTest.jav
new file mode 100644
index 00000000..54e354ea
--- /dev/null
+++ b/test/parser/WhileTest.jav
@@ -0,0 +1,9 @@
+class WhileTest{
+ void methode(){
+ Boolean test;
+ while(test){
+ test = test;
+ }
+ return;
+ }
+}
\ No newline at end of file
diff --git a/test/test.iml b/test/test.iml
new file mode 100644
index 00000000..a6c28e92
--- /dev/null
+++ b/test/test.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tools/tools.iml b/tools/tools.iml
new file mode 100644
index 00000000..8021953e
--- /dev/null
+++ b/tools/tools.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file