SyntaxtreeGenerator um einige Regeln zur Erstellung von Statements erweitert
This commit is contained in:
parent
d328faeee2
commit
32d262341a
@ -209,48 +209,17 @@ public class SyntaxTreeGenerator{
|
||||
throw new NotImplementedException();
|
||||
}else{
|
||||
Java8Parser.StatementContext stmt = statementContext.statement();
|
||||
if(stmt.statementWithoutTrailingSubstatement() != null){
|
||||
if(stmt.statementWithoutTrailingSubstatement().returnStatement() != null){
|
||||
Java8Parser.ReturnStatementContext returnStatementContext = stmt.statementWithoutTrailingSubstatement().returnStatement();
|
||||
Statement retExpr = convert(returnStatementContext.expression());
|
||||
ret.add(new Return(retExpr,returnStatementContext.getStart()));
|
||||
}else if(stmt.statementWithoutTrailingSubstatement().expressionStatement().statementExpression().methodInvocation() != null){
|
||||
Java8Parser.MethodInvocationContext methodInvocationContext = stmt.statementWithoutTrailingSubstatement().expressionStatement().statementExpression().methodInvocation();
|
||||
ret.add(convert(methodInvocationContext));
|
||||
}else throw new NotImplementedException();
|
||||
|
||||
}else if(stmt.whileStatement() != null){
|
||||
throw new NotImplementedException();
|
||||
|
||||
}else throw new NotImplementedException();
|
||||
ret.add(SyntaxTreeStatementGenerator.convert(stmt));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.MethodInvocationContext methodInvocationContext) {
|
||||
String name = methodInvocationContext.methodName().Identifier().getText();
|
||||
Expr receiver;
|
||||
if(methodInvocationContext.typeName() == null){
|
||||
receiver = new This(methodInvocationContext.getStart());
|
||||
}else{
|
||||
receiver = convert(methodInvocationContext.typeName());
|
||||
}
|
||||
|
||||
ArgumentList argumentList = null;
|
||||
return new MethodCall(new Receiver(receiver), name, argumentList, methodInvocationContext.getStart());
|
||||
}
|
||||
|
||||
private Expr convert(Java8Parser.TypeNameContext typeNameContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Statement convert(Java8Parser.ExpressionContext expression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ParameterList convert(Java8Parser.FormalParameterListContext formalParameterListContext) {
|
||||
List<FormalParameter> ret = new ArrayList<>();
|
||||
List<Java8Parser.FormalParameterContext> fps = new ArrayList<>();
|
||||
if(formalParameterListContext == null || formalParameterListContext.lastFormalParameter() == null)
|
||||
return new ParameterList(ret); //Dann ist die Parameterliste leer
|
||||
|
||||
if(formalParameterListContext.lastFormalParameter().formalParameter() == null)throw new NotImplementedException();
|
||||
|
||||
if(formalParameterListContext != null && formalParameterListContext.formalParameters() != null
|
||||
|
308
src/de/dhbwstuttgart/parser/SyntaxTreeStatementGenerator.java
Normal file
308
src/de/dhbwstuttgart/parser/SyntaxTreeStatementGenerator.java
Normal file
@ -0,0 +1,308 @@
|
||||
package de.dhbwstuttgart.parser;
|
||||
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.*;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.fieldModifier.*;
|
||||
import de.dhbwstuttgart.syntaxtree.modifier.methodModifier.MethodModifier;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassName;
|
||||
import de.dhbwstuttgart.typecheck.JavaClassRegistry;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SyntaxTreeStatementGenerator {
|
||||
|
||||
public static StatementReturn convert(Java8Parser.StatementContext stmt) {
|
||||
if (stmt.statementWithoutTrailingSubstatement() != null) {
|
||||
return convert(stmt.statementWithoutTrailingSubstatement());
|
||||
} else if (stmt.whileStatement() != null) {
|
||||
return convert(stmt.whileStatement());
|
||||
} else if (stmt.forStatement() != null) {
|
||||
return convert(stmt.forStatement());
|
||||
} else if (stmt.ifThenElseStatement() != null) {
|
||||
return convert(stmt.ifThenElseStatement());
|
||||
} else if (stmt.ifThenStatement() != null) {
|
||||
return convert(stmt.ifThenStatement());
|
||||
} else if (stmt.labeledStatement() != null) {
|
||||
return convert(stmt.labeledStatement() );
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.StatementNoShortIfContext stmt){
|
||||
if(stmt.statementWithoutTrailingSubstatement() != null){
|
||||
return convert(stmt.statementWithoutTrailingSubstatement());
|
||||
}else if(stmt.labeledStatementNoShortIf() != null){
|
||||
return convert(stmt.labeledStatementNoShortIf());
|
||||
}else if(stmt.ifThenElseStatementNoShortIf() != null){
|
||||
return convert(stmt.ifThenElseStatementNoShortIf());
|
||||
}else if(stmt.whileStatementNoShortIf() != null){
|
||||
return convert(stmt.whileStatementNoShortIf());
|
||||
}else if(stmt.forStatementNoShortIf() != null){
|
||||
return convert(stmt.forStatementNoShortIf());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.StatementWithoutTrailingSubstatementContext stmt) {
|
||||
if(stmt.block() != null){
|
||||
return convert(stmt.block());
|
||||
}else if(stmt.emptyStatement() != null){
|
||||
return new StatementReturn(new EmptyStmt());
|
||||
}else if(stmt.expressionStatement() != null){
|
||||
return convert(stmt.expressionStatement());
|
||||
}else if(stmt.assertStatement() != null){
|
||||
return convert(stmt.assertStatement());
|
||||
}else if(stmt.switchStatement() != null){
|
||||
return convert(stmt.switchStatement());
|
||||
}else if(stmt.doStatement() != null){
|
||||
return convert(stmt.doStatement());
|
||||
}else if(stmt.breakStatement() != null){
|
||||
return convert(stmt.breakStatement());
|
||||
}else if(stmt.continueStatement() != null){
|
||||
return convert(stmt.continueStatement());
|
||||
}else if(stmt.returnStatement() != null){
|
||||
return convert(stmt.returnStatement());
|
||||
}else if(stmt.synchronizedStatement() != null){
|
||||
return convert(stmt.synchronizedStatement());
|
||||
}else if(stmt.throwStatement() != null){
|
||||
return convert(stmt.throwStatement());
|
||||
}else if(stmt.tryStatement() != null){
|
||||
return convert(stmt.tryStatement());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.LabeledStatementContext labeledStatementContext) {
|
||||
throw new NotImplementedException();
|
||||
//return convert(labeledStatementContext.statement());
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.LabeledStatementNoShortIfContext stmt){
|
||||
throw new NotImplementedException();
|
||||
//return convert(stmt.statementNoShortIf());
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ExpressionStatementContext stmt){
|
||||
return convert(stmt.statementExpression());
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.StatementExpressionContext stmt) {
|
||||
if(stmt.assignment() != null){
|
||||
return convert(stmt.assignment());
|
||||
}else if(stmt.preIncrementExpression() != null){
|
||||
return convert(stmt.preIncrementExpression());
|
||||
}else if(stmt.preDecrementExpression() != null){
|
||||
return convert(stmt.preDecrementExpression());
|
||||
}else if(stmt.postIncrementExpression() != null){
|
||||
return convert(stmt.postIncrementExpression());
|
||||
}else if(stmt.postDecrementExpression() != null){
|
||||
return convert(stmt.postDecrementExpression());
|
||||
}else if(stmt.methodInvocation() != null){
|
||||
return convert(stmt.methodInvocation());
|
||||
}else if(stmt.classInstanceCreationExpression() != null){
|
||||
return convert(stmt.classInstanceCreationExpression());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private StatementReturn convert(Java8Parser.MethodInvocationContext methodInvocationContext) {
|
||||
String name = methodInvocationContext.methodName().Identifier().getText();
|
||||
Expr receiver;
|
||||
if(methodInvocationContext.typeName() == null){
|
||||
receiver = new This(methodInvocationContext.getStart());
|
||||
}else{
|
||||
receiver = convert(methodInvocationContext.typeName());
|
||||
}
|
||||
|
||||
ArgumentList argumentList = null;
|
||||
MethodCall ret = new MethodCall(new Receiver(receiver), name, argumentList, methodInvocationContext.getStart());
|
||||
return new StatementReturn(ret);
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ClassInstanceCreationExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.PreIncrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.PreDecrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.PostIncrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.PostDecrementExpressionContext stmt) {
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.AssignmentContext stmt) {
|
||||
//TODO
|
||||
//return new StatementReturn(new Assign())
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.IfThenStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.IfThenElseStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.IfThenElseStatementNoShortIfContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.AssertStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.SwitchStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.SwitchBlockContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.SwitchBlockStatementGroupContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.WhileStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.WhileStatementNoShortIfContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.DoStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ForStatementContext stmt){
|
||||
if(stmt.basicForStatement() != null){
|
||||
return convert(stmt.basicForStatement());
|
||||
}else if(stmt.enhancedForStatement() != null){
|
||||
return convert(stmt.enhancedForStatement());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ForStatementNoShortIfContext stmt){
|
||||
if(stmt.basicForStatementNoShortIf() != null){
|
||||
return convert(stmt.basicForStatementNoShortIf());
|
||||
}else if(stmt.enhancedForStatementNoShortIf() != null){
|
||||
return convert(stmt.enhancedForStatementNoShortIf());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.BasicForStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.BasicForStatementNoShortIfContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ForInitContext stmt){
|
||||
if(stmt.statementExpressionList() != null){
|
||||
return convert(stmt.statementExpressionList());
|
||||
}else if(stmt.localVariableDeclaration() != null){
|
||||
return convert(stmt.localVariableDeclaration());
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ForUpdateContext stmt){
|
||||
return convert(stmt.statementExpressionList());
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.StatementExpressionListContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.EnhancedForStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.EnhancedForStatementNoShortIfContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.BreakStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ContinueStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ReturnStatementContext stmt){
|
||||
return new StatementReturn(new Return(convert(stmt.expression()),stmt.getStart()));
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.ThrowStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.SynchronizedStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.TryStatementContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.CatchesContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static StatementReturn convert(Java8Parser.CatchClauseContext stmt){
|
||||
//TODO
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
class StatementReturn{
|
||||
public StatementReturn(Statement statement){
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user