forked from JavaTX/JavaCompilerCore
Implemented Continue, Catches, Break visit ...
This commit is contained in:
parent
881830235a
commit
07303ffa71
@ -269,24 +269,19 @@ public class StatementGenerator {
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PreIncExpr(convert(stmt.unaryExpression()),stmt.getStart());
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.PreDecrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PreDecExpr(convert(stmt.unaryExpression()),stmt.getStart());
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) {
|
||||
Expression expr = convert(stmt.postfixExpression());
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PostIncExpr(convert(stmt.postfixExpression()));
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.PostDecrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
return new PostDecExpr(convert(stmt.postfixExpression()));
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.AssignmentContext stmt) {
|
||||
@ -341,7 +336,7 @@ public class StatementGenerator {
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.SwitchStatementContext stmt){
|
||||
//TODO
|
||||
//TODO Felix K
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@ -506,16 +501,20 @@ public class StatementGenerator {
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.BreakStatementContext stmt){
|
||||
if (stmt.Identifier()!=null)
|
||||
if (stmt.Identifier()==null)
|
||||
{
|
||||
new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),stmt.Identifier(),stmt.getStart());
|
||||
String indentifier = "";
|
||||
return new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),indentifier,stmt.getStart());
|
||||
}
|
||||
return new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),stmt.Identifier(),stmt.getStart());
|
||||
return new BreakStmt(TypePlaceholder.fresh(stmt.getStart()),stmt.Identifier().getText(),stmt.getStart());
|
||||
}
|
||||
|
||||
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){
|
||||
@ -541,7 +540,8 @@ public class StatementGenerator {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.CatchesContext stmt){
|
||||
private Statement convert(Java8Parser.CatchesContext stmt)
|
||||
{
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -11,14 +11,15 @@ import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
*/
|
||||
public class BreakStmt extends Statement
|
||||
{
|
||||
public final TerminalNode indentifier;
|
||||
public final String indentifier;
|
||||
|
||||
public BreakStmt(RefTypeOrTPHOrWildcardOrGeneric type, TerminalNode Indentifier, Token offset)
|
||||
public BreakStmt(RefTypeOrTPHOrWildcardOrGeneric type, String Indentifier, Token offset)
|
||||
{
|
||||
super(type, offset);
|
||||
this.indentifier=Indentifier;
|
||||
}
|
||||
@Override
|
||||
public void accept(StatementVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
||||
@ -235,7 +241,7 @@ public class OutputGenerator implements ASTVisitor {
|
||||
out.append("if");
|
||||
ifStmt.expr.accept(this);
|
||||
ifStmt.then_block.accept(this);
|
||||
out.append("\nelse");
|
||||
out.append("else");
|
||||
ifStmt.else_block.accept(this);
|
||||
|
||||
//TODO Felix_K
|
||||
|
@ -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) {
|
||||
|
@ -2,8 +2,6 @@ class BreakTest
|
||||
{
|
||||
void methode()
|
||||
{
|
||||
|
||||
break;
|
||||
|
||||
break BREAKTEST;
|
||||
}
|
||||
}
|
@ -2,11 +2,10 @@ class WhileTest
|
||||
{
|
||||
void methode()
|
||||
{
|
||||
Boolean test;
|
||||
Boolean BoolTrue=true;
|
||||
do
|
||||
{
|
||||
test=test;
|
||||
}while(test);
|
||||
}while(testTrue);
|
||||
|
||||
|
||||
while(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;
|
||||
@ -36,12 +38,12 @@ 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+"BreakTest.jav"));
|
||||
filesToTest.add(new File(rootDirectory+"WhileTest.jav"));
|
||||
filesToTest.add(new File(rootDirectory+"IfTest.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"IfTest.jav"));
|
||||
for(File f : filesToTest){
|
||||
SourceFile sf = this.parse(f);
|
||||
System.out.println(ASTTypePrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
||||
System.out.println(ASTPrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
||||
System.out.println("-----------------------------------------------------------------------------------");
|
||||
/*
|
||||
for(ResultSet resultSet : this.typeInference()){
|
||||
|
Loading…
Reference in New Issue
Block a user