Compare commits

...

9 Commits

Author SHA1 Message Date
FelixKrespach
998c146f4b Final 2017-10-02 17:11:55 +02:00
FelixKrespach
88c78342d5 Final 2017-10-01 09:58:56 +02:00
FelixKrespach
86b2118770 Refactoring 2017-09-25 08:24:08 +02:00
FelixKrespach
03080c43cb Refactoring 2017-09-25 08:17:36 +02:00
FelixKrespach
df1c19e60d Tests added 2017-09-23 18:33:48 +02:00
FelixKrespach
07303ffa71 Implemented Continue, Catches, Break visit ... 2017-09-22 18:19:34 +02:00
FelixKrespach
881830235a Break Class + Test 2017-09-22 14:49:43 +02:00
FelixKrespach
b88b9e2534 methods in statementgenerator implemented
Tests + visit
2017-09-21 22:36:13 +02:00
FelixKrespach
8e1c1765ff Many methods in statementgenerator implemented 2017-09-20 17:36:16 +02:00
26 changed files with 344 additions and 68 deletions

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.parser.SyntaxTreeGenerator; package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
import com.sun.javafx.fxml.expression.UnaryExpression;
import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.parser.antlr.Java8Parser;
@ -266,25 +267,21 @@ public class StatementGenerator {
//TODO //TODO
throw new NotImplementedException(); throw new NotImplementedException();
} }
//TODO Felix_K
private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) { private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) {
//TODO return new PreIncExpr(convert(stmt.unaryExpression()),stmt.getStart());
throw new NotImplementedException();
} }
//TODO Felix_K
private Statement convert(Java8Parser.PreDecrementExpressionContext stmt) { private Statement convert(Java8Parser.PreDecrementExpressionContext stmt) {
//TODO return new PreDecExpr(convert(stmt.unaryExpression()),stmt.getStart());
throw new NotImplementedException();
} }
//TODO Felix_K
private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) { private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) {
//TODO return new PostIncExpr(convert(stmt.postfixExpression()));
throw new NotImplementedException();
} }
//TODO Felix_K
private Statement convert(Java8Parser.PostDecrementExpressionContext stmt) { private Statement convert(Java8Parser.PostDecrementExpressionContext stmt) {
//TODO return new PostDecExpr(convert(stmt.postfixExpression()));
throw new NotImplementedException();
} }
private Statement convert(Java8Parser.AssignmentContext stmt) { private Statement convert(Java8Parser.AssignmentContext stmt) {
@ -298,35 +295,50 @@ public class StatementGenerator {
else if (leftSide instanceof LocalVar)return new AssignToLocal((LocalVar) leftSide); else if (leftSide instanceof LocalVar)return new AssignToLocal((LocalVar) leftSide);
else throw new NotImplementedException(); else throw new NotImplementedException();
} }
//TODO Felix_K
private Statement convert(Java8Parser.IfThenStatementContext stmt){ private Statement convert(Java8Parser.IfThenStatementContext stmt){
//TODO Expression expr = convert(stmt.expression());
throw new NotImplementedException(); 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){ private Statement convert(Java8Parser.IfThenElseStatementContext stmt){
//TODO Expression expr = convert(stmt.expression());
throw new NotImplementedException(); 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){ private Statement convert(Java8Parser.IfThenElseStatementNoShortIfContext stmt){
//TODO Expression expr = convert(stmt.expression());
throw new NotImplementedException(); 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());
} }
//TODO Felix_K
private Statement convert(Java8Parser.AssertStatementContext stmt){ private Statement convert(Java8Parser.AssertStatementContext stmt)
//TODO {
throw new NotImplementedException(); 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){ private Statement convert(Java8Parser.SwitchStatementContext stmt){
//TODO Expression expr = convert(stmt.expression());
throw new NotImplementedException(); 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){ private Statement convert(Java8Parser.SwitchBlockContext stmt){
//TODO //TODO
throw new NotImplementedException(); throw new NotImplementedException();
} }
private Statement convert(Java8Parser.SwitchBlockStatementGroupContext stmt){ private Statement convert(Java8Parser.SwitchBlockStatementGroupContext stmt){
@ -339,12 +351,13 @@ public class StatementGenerator {
Statement block = convert(stmt.statement()); Statement block = convert(stmt.statement());
return new WhileStmt(expr, block,stmt.getStart()); return new WhileStmt(expr, block,stmt.getStart());
} }
//TODO Felix_K
private Statement convert(Java8Parser.WhileStatementNoShortIfContext stmt){ private Statement convert(Java8Parser.WhileStatementNoShortIfContext stmt){
//TODO Expression expr = convert(stmt.expression());
throw new NotImplementedException(); Statement block = convert(stmt.statementNoShortIf());
return new WhileStmt(expr, block, stmt.getStart());
} }
//TODO Felix_K
private Statement convert(Java8Parser.DoStatementContext stmt){ private Statement convert(Java8Parser.DoStatementContext stmt){
Statement block = convert(stmt.statement()); Statement block = convert(stmt.statement());
Expression expr = convert(stmt.expression()); Expression expr = convert(stmt.expression());
@ -366,15 +379,43 @@ public class StatementGenerator {
return convert(stmt.enhancedForStatementNoShortIf()); return convert(stmt.enhancedForStatementNoShortIf());
}else throw new NotImplementedException(); }else throw new NotImplementedException();
} }
//TODO Felix_K
private Statement convert(Java8Parser.BasicForStatementContext stmt){ private Statement convert(Java8Parser.BasicForStatementContext stmt){
//TODO List<Statement> stateList = new ArrayList<>();
throw new NotImplementedException(); 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){ private Statement convert(Java8Parser.BasicForStatementNoShortIfContext stmt){
//TODO List<Statement> stateList = new ArrayList<>();
throw new NotImplementedException(); 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){ private List<Statement> convert(Java8Parser.ForInitContext stmt){
@ -384,7 +425,7 @@ public class StatementGenerator {
return convert(stmt.localVariableDeclaration()); return convert(stmt.localVariableDeclaration());
}else throw new NotImplementedException(); }else throw new NotImplementedException();
} }
//TODO Felix_K
private List<Statement> convert(Java8Parser.LocalVariableDeclarationContext declaration) { private List<Statement> convert(Java8Parser.LocalVariableDeclarationContext declaration) {
List<Statement> ret = new ArrayList<>(); List<Statement> ret = new ArrayList<>();
if(declaration.variableModifier() != null && declaration.variableModifier().size() > 0){ if(declaration.variableModifier() != null && declaration.variableModifier().size() > 0){
@ -454,15 +495,22 @@ public class StatementGenerator {
//TODO //TODO
throw new NotImplementedException(); throw new NotImplementedException();
} }
//TODO Felix_K
private Statement convert(Java8Parser.BreakStatementContext stmt){ private Statement convert(Java8Parser.BreakStatementContext stmt){
//TODO if (stmt.Identifier()==null)
throw new NotImplementedException(); {
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){ private Statement convert(Java8Parser.ContinueStatementContext stmt){
//TODO if (stmt.Identifier()==null){
throw new NotImplementedException(); 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){ private Statement convert(Java8Parser.ReturnStatementContext stmt){
@ -488,7 +536,8 @@ public class StatementGenerator {
throw new NotImplementedException(); throw new NotImplementedException();
} }
private Statement convert(Java8Parser.CatchesContext stmt){ private Statement convert(Java8Parser.CatchesContext stmt)
{
//TODO //TODO
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -15,8 +15,8 @@ public class SyntacticSugar {
//TODO //TODO
//if (hasReturn(((WhileStmt) lastStmt).loopBlock)) return statements; //if (hasReturn(((WhileStmt) lastStmt).loopBlock)) return statements;
} else if (lastStmt instanceof IfStmt) { } else if (lastStmt instanceof IfStmt) {
if (hasReturn(((IfStmt) lastStmt).then_block) //if (hasReturn(((IfStmt) lastStmt).then_block)
&& hasReturn(((IfStmt) lastStmt).else_block)) return statements; //&& hasReturn(((IfStmt) lastStmt).else_block)) return statements;
} else if (lastStmt instanceof ForStmt) { } else if (lastStmt instanceof ForStmt) {
if (hasReturn(((ForStmt) lastStmt).body_Loop_block)) return statements; if (hasReturn(((ForStmt) lastStmt).body_Loop_block)) return statements;
} else { } else {

View File

@ -35,4 +35,6 @@ public interface ASTVisitor extends StatementVisitor{
void visit(ExtendsWildcardType extendsWildcardType); void visit(ExtendsWildcardType extendsWildcardType);
void visit(GenericRefType genericRefType); void visit(GenericRefType genericRefType);
void visit(BreakStmt breakStmt);
} }

View File

@ -268,4 +268,8 @@ public abstract class AbstractASTWalker implements ASTVisitor{
public void visit(SuperCall superCall) { public void visit(SuperCall superCall) {
this.visit((MethodCall)superCall); this.visit((MethodCall)superCall);
} }
@Override
public void visit(BreakStmt breakStmt) {
}
} }

View File

@ -18,6 +18,8 @@ public interface StatementVisitor {
void visit(Block block); void visit(Block block);
void visit(BreakStmt breakStmt);
void visit(CastExpr castExpr); void visit(CastExpr castExpr);
void visit(EmptyStmt emptyStmt); void visit(EmptyStmt emptyStmt);

View 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) {
}
}

View 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);
}
}

View File

@ -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;
}
}

View 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);
}
}

View File

@ -11,11 +11,11 @@ import org.antlr.v4.runtime.Token;
public class IfStmt extends Statement public class IfStmt extends Statement
{ {
public final Expression expr; public final Expression expr;
public final Block then_block; public final Statement then_block;
public final Block else_block; public final Statement else_block;
public IfStmt(RefTypeOrTPHOrWildcardOrGeneric type, public IfStmt(RefTypeOrTPHOrWildcardOrGeneric type,
Expression expr, Block thenBlock, Block elseBlock, Token offset) Expression expr, Statement thenBlock, Statement elseBlock, Token offset)
{ {
super(type,offset); super(type,offset);
this.expr = expr; this.expr = expr;
@ -23,6 +23,7 @@ public class IfStmt extends Statement
this.else_block = elseBlock; this.else_block = elseBlock;
} }
@Override @Override
public void accept(StatementVisitor visitor) { public void accept(StatementVisitor visitor) {
visitor.visit(this); visitor.visit(this);

View File

@ -3,6 +3,7 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.parser.antlr.Java8Parser;
import org.antlr.v4.runtime.Token;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList; import org.apache.bcel.generic.InstructionList;

View File

@ -4,12 +4,15 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceBlockInformation;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.exceptions.NotImplementedException;
import org.antlr.v4.runtime.Token;
public class PostIncExpr extends UnaryExpr public class PostIncExpr extends UnaryExpr
{ {
final Expression expr;
public PostIncExpr(Expression expr) { public PostIncExpr(Expression expr) {
super(null); super(null);
this.expr=expr;
} }
} }

View File

@ -12,8 +12,10 @@ import org.apache.bcel.generic.InstructionList;
public class PreDecExpr extends UnaryExpr public class PreDecExpr extends UnaryExpr
{ {
public PreDecExpr(Token offset) Expression expr;
public PreDecExpr(Expression expr, Token offset)
{ {
super(offset); super(offset);
this.expr=expr;
} }
} }

View File

@ -5,8 +5,10 @@ import org.antlr.v4.runtime.Token;
public class PreIncExpr extends UnaryExpr public class PreIncExpr extends UnaryExpr
{ {
public PreIncExpr(Token offset) final Expression expr;
public PreIncExpr(Expression expr,Token offset)
{ {
super(offset); super(offset);
this.expr=expr;
} }
} }

View 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) {
}
}

View File

@ -209,6 +209,12 @@ public class OutputGenerator implements ASTVisitor {
out.append("}"); out.append("}");
} }
@Override
public void visit(BreakStmt breakStmt)
{
out.append("break"+ " " + breakStmt.indentifier);
}
@Override @Override
public void visit(CastExpr castExpr) { public void visit(CastExpr castExpr) {
@ -232,7 +238,15 @@ public class OutputGenerator implements ASTVisitor {
@Override @Override
public void visit(IfStmt ifStmt) { 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 @Override

View File

@ -1,6 +1,8 @@
package de.dhbwstuttgart.typedeployment; package de.dhbwstuttgart.typedeployment;
import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.*; import de.dhbwstuttgart.syntaxtree.*;
import de.dhbwstuttgart.syntaxtree.statement.BreakStmt;
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression; import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.result.ResultSet; import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -70,4 +72,5 @@ class TypeInsertPlacerClass extends AbstractASTWalker{
public void visit(LambdaExpression lambdaExpression) { public void visit(LambdaExpression lambdaExpression) {
//Lambda-Ausdrücke brauchen keine Typeinsetzungen //Lambda-Ausdrücke brauchen keine Typeinsetzungen
} }
} }

View File

@ -87,6 +87,8 @@ public class TYPEStmt implements StatementVisitor{
stmt.accept(this); stmt.accept(this);
} }
} }
@Override
public void visit(BreakStmt breakStmt){throw new NotImplementedException();}
@Override @Override
public void visit(CastExpr castExpr) { public void visit(CastExpr castExpr) {

View File

@ -0,0 +1,7 @@
class AssertTest
{
void assertMethod()
{
assert true;
}
}

View File

@ -0,0 +1,7 @@
class BreakTest
{
void methode()
{
break BREAKTEST;
}
}

24
test/parser/IfTest.jav Normal file
View File

@ -0,0 +1,24 @@
class IfTest
{
public void IfStatementTest();
public void ifThenNoShortIfTest()
{
if(y)
{
}
}
public void ifThenElseTest()
{
if(z)
{
}
else
{
}
}
}

View File

@ -0,0 +1,10 @@
class TestClass
{
void testMethod()
{
//++i;
//i++;
//--i;
//i--;
}
}

View File

@ -0,0 +1,11 @@
public class SwitchTest
{
void testMethod()
{
switch(i)
{
case i:
break;
}
}
}

View File

@ -0,0 +1,14 @@
class TryCatchTest
{
public void TryTest()
{
try
{
}
catch()
{
}
}
}

View File

@ -1,14 +1,16 @@
class WhileTest{ class WhileTest
void methode(){ {
Boolean test; void methode()
do{ {
test=test; Boolean boolVar=true;
}while(test); do
{
}while(boolVar);
while(test){ while(boolVar)
test = test; {
} test = test;
return; }
} }
} }

View File

@ -2,7 +2,9 @@ package typeinference;
import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
import de.dhbwstuttgart.typedeployment.TypeInsert; import de.dhbwstuttgart.typedeployment.TypeInsert;
import de.dhbwstuttgart.typedeployment.TypeInsertFactory; import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
import de.dhbwstuttgart.typeinference.result.ResultSet; import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -20,14 +22,14 @@ import java.util.Set;
public class JavaTXCompilerTest extends JavaTXCompiler { 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<>(); private static final List<File> filesToTest = new ArrayList<>();
@Test @Test
public void test() throws IOException, java.lang.ClassNotFoundException { public void test() throws IOException, java.lang.ClassNotFoundException {
//filesToTest.add(new File(rootDirectory+"Faculty.jav")); //filesToTest.add(new File(rootDirectory+"Faculty.jav"));
//filesToTest.add(new File(rootDirectory+"mathStruc.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+"Lambda.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda2.jav")); //filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda3.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+"MethodsEasy.jav"));
//filesToTest.add(new File(rootDirectory+"Matrix.jav")); //filesToTest.add(new File(rootDirectory+"Matrix.jav"));
//filesToTest.add(new File(rootDirectory+"Import.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){ for(File f : filesToTest){
SourceFile sf = this.parse(f); 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()){ for(ResultSet resultSet : this.typeInference()){
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet); Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);
String content = readFile(f.getPath(), StandardCharsets.UTF_8); String content = readFile(f.getPath(), StandardCharsets.UTF_8);
@ -46,6 +59,7 @@ public class JavaTXCompilerTest extends JavaTXCompiler {
System.out.println(tip.insert(content)); System.out.println(tip.insert(content));
} }
} }
*/
} }
} }