forked from JavaTX/JavaCompilerCore
Compare commits
9 Commits
targetByte
...
antlr2
Author | SHA1 | Date | |
---|---|---|---|
|
998c146f4b | ||
|
88c78342d5 | ||
|
86b2118770 | ||
|
03080c43cb | ||
|
df1c19e60d | ||
|
07303ffa71 | ||
|
881830235a | ||
|
b88b9e2534 | ||
|
8e1c1765ff |
@ -1,5 +1,6 @@
|
||||
package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
|
||||
|
||||
import com.sun.javafx.fxml.expression.UnaryExpression;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||
@ -266,25 +267,21 @@ public class StatementGenerator {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PreIncExpr(convert(stmt.unaryExpression()),stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.PreDecrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PreDecExpr(convert(stmt.unaryExpression()),stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PostIncExpr(convert(stmt.postfixExpression()));
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.PostDecrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PostDecExpr(convert(stmt.postfixExpression()));
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.AssignmentContext stmt) {
|
||||
@ -298,35 +295,50 @@ public class StatementGenerator {
|
||||
else if (leftSide instanceof LocalVar)return new AssignToLocal((LocalVar) leftSide);
|
||||
else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.IfThenStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
Expression expr = convert(stmt.expression());
|
||||
Statement thenBlock = convert(stmt.statement());
|
||||
Statement elseBlock = new EmptyStmt(stmt.getStart());
|
||||
return new IfStmt(TypePlaceholder.fresh(stmt.getStart()),expr,thenBlock,elseBlock,stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.IfThenElseStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
Expression expr = convert(stmt.expression());
|
||||
Statement thenBlock = convert(stmt.statementNoShortIf());
|
||||
Statement elseBlock = convert(stmt.statement());
|
||||
return new IfStmt(TypePlaceholder.fresh(stmt.getStart()),expr,thenBlock,elseBlock,stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.IfThenElseStatementNoShortIfContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
Expression expr = convert(stmt.expression());
|
||||
Statement thenBlock = convert(stmt.statementNoShortIf().get(0));
|
||||
Statement elseBlock = convert(stmt.statementNoShortIf().get(1));
|
||||
return new IfStmt(TypePlaceholder.fresh(stmt.getStart()),expr,thenBlock,elseBlock,stmt.getStart());
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.AssertStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.AssertStatementContext stmt)
|
||||
{
|
||||
List<Expression> exprList= new ArrayList<Expression>();
|
||||
for (int i =0; i<stmt.expression().size();i++){
|
||||
exprList.add(convert(stmt.expression(i)));
|
||||
}
|
||||
return new AssertStmt(TypePlaceholder.fresh(stmt.getStart()),exprList,stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.SwitchStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
Expression expr = convert(stmt.expression());
|
||||
List<Statement> statementList = new ArrayList<Statement>();
|
||||
statementList.add( convert(stmt.switchBlock()));
|
||||
statementList.add(new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),"",stmt.getStart()));
|
||||
Block block = new Block(statementList, stmt.getStart());
|
||||
return new SwitchStmt(TypePlaceholder.fresh(stmt.getStart()),expr,block,stmt.getStart());
|
||||
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.SwitchBlockContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.SwitchBlockStatementGroupContext stmt){
|
||||
@ -339,12 +351,13 @@ public class StatementGenerator {
|
||||
Statement block = convert(stmt.statement());
|
||||
return new WhileStmt(expr, block,stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.WhileStatementNoShortIfContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
Expression expr = convert(stmt.expression());
|
||||
Statement block = convert(stmt.statementNoShortIf());
|
||||
return new WhileStmt(expr, block, stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.DoStatementContext stmt){
|
||||
Statement block = convert(stmt.statement());
|
||||
Expression expr = convert(stmt.expression());
|
||||
@ -366,15 +379,43 @@ public class StatementGenerator {
|
||||
return convert(stmt.enhancedForStatementNoShortIf());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.BasicForStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
List<Statement> stateList = new ArrayList<>();
|
||||
List<Statement> whileList = new ArrayList<>();
|
||||
if (stmt.forInit().localVariableDeclaration()==null)
|
||||
{
|
||||
whileList.addAll(convert(stmt.forInit().localVariableDeclaration()));
|
||||
}
|
||||
else
|
||||
{
|
||||
whileList.add(convert(stmt.forInit().statementExpressionList()));
|
||||
}
|
||||
Expression expr = convert(stmt.expression());
|
||||
stateList.add(convert(stmt.statement()));
|
||||
stateList.add(convert(stmt.forUpdate()));
|
||||
Block forBlock = new Block(stateList,stmt.getStart());
|
||||
whileList.add(new WhileStmt(expr,forBlock,stmt.getStart()));
|
||||
return new Block(whileList,stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.BasicForStatementNoShortIfContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
List<Statement> stateList = new ArrayList<>();
|
||||
List<Statement> whileList = new ArrayList<>();
|
||||
if (stmt.forInit().localVariableDeclaration()==null)
|
||||
{
|
||||
whileList.addAll(convert(stmt.forInit().localVariableDeclaration()));
|
||||
}
|
||||
else
|
||||
{
|
||||
whileList.add(convert(stmt.forInit().statementExpressionList()));
|
||||
}
|
||||
Expression expr = convert(stmt.expression());
|
||||
stateList.add(convert(stmt.statementNoShortIf()));
|
||||
stateList.add(convert(stmt.forUpdate()));
|
||||
Block forBlock = new Block(stateList,stmt.getStart());
|
||||
whileList.add(new WhileStmt(expr,forBlock,stmt.getStart()));
|
||||
return new Block(whileList,stmt.getStart());
|
||||
}
|
||||
|
||||
private List<Statement> convert(Java8Parser.ForInitContext stmt){
|
||||
@ -384,7 +425,7 @@ public class StatementGenerator {
|
||||
return convert(stmt.localVariableDeclaration());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private List<Statement> convert(Java8Parser.LocalVariableDeclarationContext declaration) {
|
||||
List<Statement> ret = new ArrayList<>();
|
||||
if(declaration.variableModifier() != null && declaration.variableModifier().size() > 0){
|
||||
@ -454,15 +495,22 @@ public class StatementGenerator {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.BreakStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
if (stmt.Identifier()==null)
|
||||
{
|
||||
String indentifier = "";
|
||||
return new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),indentifier,stmt.getStart());
|
||||
}
|
||||
return new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),stmt.Identifier().getText(),stmt.getStart());
|
||||
}
|
||||
|
||||
//TODO Felix_K
|
||||
private Statement convert(Java8Parser.ContinueStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
if (stmt.Identifier()==null){
|
||||
String indentifier = "";
|
||||
return new ContinueStmt(TypePlaceholder.fresh(stmt.getStart()),indentifier, stmt.getStart());
|
||||
}
|
||||
return new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),stmt.Identifier().getText(),stmt.getStart());
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.ReturnStatementContext stmt){
|
||||
@ -488,7 +536,8 @@ public class StatementGenerator {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.CatchesContext stmt){
|
||||
private Statement convert(Java8Parser.CatchesContext stmt)
|
||||
{
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ public class SyntacticSugar {
|
||||
//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;
|
||||
//if (hasReturn(((IfStmt) lastStmt).then_block)
|
||||
//&& hasReturn(((IfStmt) lastStmt).else_block)) return statements;
|
||||
} else if (lastStmt instanceof ForStmt) {
|
||||
if (hasReturn(((ForStmt) lastStmt).body_Loop_block)) return statements;
|
||||
} else {
|
||||
|
@ -35,4 +35,6 @@ public interface ASTVisitor extends StatementVisitor{
|
||||
void visit(ExtendsWildcardType extendsWildcardType);
|
||||
|
||||
void visit(GenericRefType genericRefType);
|
||||
|
||||
void visit(BreakStmt breakStmt);
|
||||
}
|
||||
|
@ -268,4 +268,8 @@ public abstract class AbstractASTWalker implements ASTVisitor{
|
||||
public void visit(SuperCall superCall) {
|
||||
this.visit((MethodCall)superCall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BreakStmt breakStmt) {
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ public interface StatementVisitor {
|
||||
|
||||
void visit(Block block);
|
||||
|
||||
void visit(BreakStmt breakStmt);
|
||||
|
||||
void visit(CastExpr castExpr);
|
||||
|
||||
void visit(EmptyStmt emptyStmt);
|
||||
|
24
src/de/dhbwstuttgart/syntaxtree/statement/AssertStmt.java
Normal file
24
src/de/dhbwstuttgart/syntaxtree/statement/AssertStmt.java
Normal file
@ -0,0 +1,24 @@
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Felix_K on 21.09.2017.
|
||||
*/
|
||||
public class AssertStmt extends Statement
|
||||
{
|
||||
public final List<Expression> expr;
|
||||
public AssertStmt(RefTypeOrTPHOrWildcardOrGeneric type, List<Expression> expr, Token offset){
|
||||
super(type, offset);
|
||||
this.expr=expr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(StatementVisitor visitor) {
|
||||
|
||||
}
|
||||
}
|
25
src/de/dhbwstuttgart/syntaxtree/statement/BreakStmt.java
Normal file
25
src/de/dhbwstuttgart/syntaxtree/statement/BreakStmt.java
Normal file
@ -0,0 +1,25 @@
|
||||
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 String indentifier;
|
||||
|
||||
public BreakStmt(RefTypeOrTPHOrWildcardOrGeneric type, String Indentifier, Token offset)
|
||||
{
|
||||
super(type, offset);
|
||||
this.indentifier=Indentifier;
|
||||
}
|
||||
@Override
|
||||
public void accept(StatementVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Felix_K on 21.09.2017.
|
||||
*/
|
||||
public class CatchesStatement
|
||||
{
|
||||
final List<Statement> catchClauses;
|
||||
public CatchesStatement(List<Statement> catches)
|
||||
{
|
||||
catchClauses = catches;
|
||||
}
|
||||
}
|
14
src/de/dhbwstuttgart/syntaxtree/statement/ContinueStmt.java
Normal file
14
src/de/dhbwstuttgart/syntaxtree/statement/ContinueStmt.java
Normal file
@ -0,0 +1,14 @@
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
/**
|
||||
* Created by Felix_K on 22.09.2017.
|
||||
*/
|
||||
public class ContinueStmt extends BreakStmt {
|
||||
public ContinueStmt(RefTypeOrTPHOrWildcardOrGeneric type, String indent, Token offset){
|
||||
super(type, indent, offset);
|
||||
}
|
||||
}
|
@ -11,11 +11,11 @@ import org.antlr.v4.runtime.Token;
|
||||
public class IfStmt extends Statement
|
||||
{
|
||||
public final Expression expr;
|
||||
public final Block then_block;
|
||||
public final Block else_block;
|
||||
public final Statement then_block;
|
||||
public final Statement else_block;
|
||||
|
||||
public IfStmt(RefTypeOrTPHOrWildcardOrGeneric type,
|
||||
Expression expr, Block thenBlock, Block elseBlock, Token offset)
|
||||
public IfStmt(RefTypeOrTPHOrWildcardOrGeneric type,
|
||||
Expression expr, Statement thenBlock, Statement elseBlock, Token offset)
|
||||
{
|
||||
super(type,offset);
|
||||
this.expr = expr;
|
||||
@ -23,6 +23,7 @@ public class IfStmt extends Statement
|
||||
this.else_block = elseBlock;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void accept(StatementVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
|
@ -3,6 +3,7 @@ import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.apache.bcel.generic.ClassGen;
|
||||
import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
|
@ -4,12 +4,15 @@ 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 PostIncExpr extends UnaryExpr
|
||||
{
|
||||
final Expression expr;
|
||||
public PostIncExpr(Expression expr) {
|
||||
super(null);
|
||||
this.expr=expr;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,10 @@ import org.apache.bcel.generic.InstructionList;
|
||||
|
||||
public class PreDecExpr extends UnaryExpr
|
||||
{
|
||||
public PreDecExpr(Token offset)
|
||||
Expression expr;
|
||||
public PreDecExpr(Expression expr, Token offset)
|
||||
{
|
||||
super(offset);
|
||||
this.expr=expr;
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,10 @@ import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class PreIncExpr extends UnaryExpr
|
||||
{
|
||||
public PreIncExpr(Token offset)
|
||||
final Expression expr;
|
||||
public PreIncExpr(Expression expr,Token offset)
|
||||
{
|
||||
super(offset);
|
||||
this.expr=expr;
|
||||
}
|
||||
}
|
||||
|
24
src/de/dhbwstuttgart/syntaxtree/statement/SwitchStmt.java
Normal file
24
src/de/dhbwstuttgart/syntaxtree/statement/SwitchStmt.java
Normal file
@ -0,0 +1,24 @@
|
||||
package de.dhbwstuttgart.syntaxtree.statement;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
/**
|
||||
* Created by Felix_K on 23.09.2017.
|
||||
*/
|
||||
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;
|
||||
this.switchBlock=block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(StatementVisitor visitor) {
|
||||
}
|
||||
}
|
@ -209,6 +209,12 @@ public class OutputGenerator implements ASTVisitor {
|
||||
out.append("}");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BreakStmt breakStmt)
|
||||
{
|
||||
out.append("break"+ " " + breakStmt.indentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
|
||||
@ -232,7 +238,15 @@ public class OutputGenerator implements ASTVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
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);
|
||||
|
||||
//TODO Felix_K
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,8 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.BreakStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
@ -70,4 +72,5 @@ class TypeInsertPlacerClass extends AbstractASTWalker{
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
//Lambda-Ausdrücke brauchen keine Typeinsetzungen
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,6 +87,8 @@ public class TYPEStmt implements StatementVisitor{
|
||||
stmt.accept(this);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void visit(BreakStmt breakStmt){throw new NotImplementedException();}
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
|
7
test/parser/AssertTest.jav
Normal file
7
test/parser/AssertTest.jav
Normal file
@ -0,0 +1,7 @@
|
||||
class AssertTest
|
||||
{
|
||||
void assertMethod()
|
||||
{
|
||||
assert true;
|
||||
}
|
||||
}
|
7
test/parser/BreakTest.jav
Normal file
7
test/parser/BreakTest.jav
Normal file
@ -0,0 +1,7 @@
|
||||
class BreakTest
|
||||
{
|
||||
void methode()
|
||||
{
|
||||
break BREAKTEST;
|
||||
}
|
||||
}
|
24
test/parser/IfTest.jav
Normal file
24
test/parser/IfTest.jav
Normal file
@ -0,0 +1,24 @@
|
||||
class IfTest
|
||||
{
|
||||
|
||||
public void IfStatementTest();
|
||||
|
||||
public void ifThenNoShortIfTest()
|
||||
{
|
||||
if(y)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void ifThenElseTest()
|
||||
{
|
||||
if(z)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
10
test/parser/PrePostOperationTest.jav
Normal file
10
test/parser/PrePostOperationTest.jav
Normal file
@ -0,0 +1,10 @@
|
||||
class TestClass
|
||||
{
|
||||
void testMethod()
|
||||
{
|
||||
//++i;
|
||||
//i++;
|
||||
//--i;
|
||||
//i--;
|
||||
}
|
||||
}
|
11
test/parser/SwitchTest.jav
Normal file
11
test/parser/SwitchTest.jav
Normal file
@ -0,0 +1,11 @@
|
||||
public class SwitchTest
|
||||
{
|
||||
void testMethod()
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case i:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
14
test/parser/TryCatchTest.jav
Normal file
14
test/parser/TryCatchTest.jav
Normal file
@ -0,0 +1,14 @@
|
||||
class TryCatchTest
|
||||
{
|
||||
public void TryTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
}
|
||||
catch()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,16 @@
|
||||
class WhileTest{
|
||||
void methode(){
|
||||
Boolean test;
|
||||
do{
|
||||
test=test;
|
||||
}while(test);
|
||||
class WhileTest
|
||||
{
|
||||
void methode()
|
||||
{
|
||||
Boolean boolVar=true;
|
||||
do
|
||||
{
|
||||
}while(boolVar);
|
||||
|
||||
|
||||
while(test){
|
||||
test = test;
|
||||
}
|
||||
return;
|
||||
while(boolVar)
|
||||
{
|
||||
test = test;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,9 @@ package typeinference;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
@ -20,14 +22,14 @@ import java.util.Set;
|
||||
|
||||
public class JavaTXCompilerTest extends JavaTXCompiler {
|
||||
|
||||
private static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
|
||||
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
|
||||
private static final List<File> filesToTest = new ArrayList<>();
|
||||
|
||||
@Test
|
||||
public void test() throws IOException, java.lang.ClassNotFoundException {
|
||||
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
||||
filesToTest.add(new File(rootDirectory+"test.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"test.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
|
||||
@ -36,9 +38,20 @@ public class JavaTXCompilerTest extends JavaTXCompiler {
|
||||
//filesToTest.add(new File(rootDirectory+"MethodsEasy.jav"));
|
||||
//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+"AssertTest.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"PrePostOperationTest.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"SwitchTest.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"WhileTest.jav"));
|
||||
for(File f : filesToTest){
|
||||
SourceFile sf = this.parse(f);
|
||||
System.out.println(ASTTypePrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
||||
System.out.println("-------------------------------------|"+f.getName()+"|----------------------------------------------");
|
||||
System.out.println(ASTPrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
||||
|
||||
/*
|
||||
for(ResultSet resultSet : this.typeInference()){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
@ -46,6 +59,7 @@ public class JavaTXCompilerTest extends JavaTXCompiler {
|
||||
System.out.println(tip.insert(content));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user