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) {
|
private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) {
|
||||||
//TODO
|
return new PreIncExpr(convert(stmt.unaryExpression()),stmt.getStart());
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Statement convert(Java8Parser.PreDecrementExpressionContext stmt) {
|
private Statement convert(Java8Parser.PreDecrementExpressionContext stmt) {
|
||||||
//TODO
|
return new PreDecExpr(convert(stmt.unaryExpression()),stmt.getStart());
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) {
|
private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) {
|
||||||
Expression expr = convert(stmt.postfixExpression());
|
return new PostIncExpr(convert(stmt.postfixExpression()));
|
||||||
//TODO
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@ -341,7 +336,7 @@ public class StatementGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Statement convert(Java8Parser.SwitchStatementContext stmt){
|
private Statement convert(Java8Parser.SwitchStatementContext stmt){
|
||||||
//TODO
|
//TODO Felix K
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,16 +501,20 @@ public class StatementGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Statement convert(Java8Parser.BreakStatementContext stmt){
|
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){
|
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){
|
||||||
@ -541,7 +540,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();
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -11,14 +11,15 @@ import org.antlr.v4.runtime.tree.TerminalNode;
|
|||||||
*/
|
*/
|
||||||
public class BreakStmt extends Statement
|
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);
|
super(type, offset);
|
||||||
this.indentifier=Indentifier;
|
this.indentifier=Indentifier;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void accept(StatementVisitor visitor) {
|
public void accept(StatementVisitor visitor) {
|
||||||
|
visitor.visit(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.statement;
|
package de.dhbwstuttgart.syntaxtree.statement;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Felix_K on 21.09.2017.
|
* Created by Felix_K on 21.09.2017.
|
||||||
*/
|
*/
|
||||||
public class CatchesStatement
|
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 class PreDecExpr extends UnaryExpr
|
||||||
{
|
{
|
||||||
public PreDecExpr(Token offset)
|
Expression expr;
|
||||||
|
public PreDecExpr(Expression expr, Token offset)
|
||||||
{
|
{
|
||||||
super(offset);
|
super(offset);
|
||||||
|
this.expr=expr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
|
||||||
@ -235,7 +241,7 @@ public class OutputGenerator implements ASTVisitor {
|
|||||||
out.append("if");
|
out.append("if");
|
||||||
ifStmt.expr.accept(this);
|
ifStmt.expr.accept(this);
|
||||||
ifStmt.then_block.accept(this);
|
ifStmt.then_block.accept(this);
|
||||||
out.append("\nelse");
|
out.append("else");
|
||||||
ifStmt.else_block.accept(this);
|
ifStmt.else_block.accept(this);
|
||||||
|
|
||||||
//TODO Felix_K
|
//TODO Felix_K
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
@ -2,8 +2,6 @@ class BreakTest
|
|||||||
{
|
{
|
||||||
void methode()
|
void methode()
|
||||||
{
|
{
|
||||||
|
break BREAKTEST;
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,11 +2,10 @@ class WhileTest
|
|||||||
{
|
{
|
||||||
void methode()
|
void methode()
|
||||||
{
|
{
|
||||||
Boolean test;
|
Boolean BoolTrue=true;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
test=test;
|
}while(testTrue);
|
||||||
}while(test);
|
|
||||||
|
|
||||||
|
|
||||||
while(test)
|
while(test)
|
||||||
|
@ -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;
|
||||||
@ -36,12 +38,12 @@ 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+"BreakTest.jav"));
|
||||||
filesToTest.add(new File(rootDirectory+"WhileTest.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){
|
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(ASTPrinter.print(this.sourceFiles.get(sourceFiles.size()-1)));
|
||||||
System.out.println("-----------------------------------------------------------------------------------");
|
System.out.println("-----------------------------------------------------------------------------------");
|
||||||
/*
|
/*
|
||||||
for(ResultSet resultSet : this.typeInference()){
|
for(ResultSet resultSet : this.typeInference()){
|
||||||
|
Loading…
Reference in New Issue
Block a user