diff --git a/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 b/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 index a23f17f8..d68619cf 100644 --- a/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 +++ b/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 @@ -165,7 +165,7 @@ methodBody ; refType - : typeType # reftype + : typeType # refType2 | VOID # refvoid ; @@ -603,7 +603,7 @@ methodCall ; expression - : primary #primaryexpression + : primary #primaryExpression2 | expression bop='.' ( identifier @@ -634,8 +634,8 @@ expression | expression bop=('=' | '+=' | '-=' | '*=' | '/=' | '&=' | '|=' | '^=' | '>>=' | '>>>=' | '<<=' | '%=') expression #assignexpression - | lambdaExpression #lambdaexpression // Java8 - | switchExpression #switchexpression // Java17 + | lambdaExpression #lambdaExpression2 // Java8 + | switchExpression #switchExpression2 // Java17 // Java 8 methodReference | expression '::' typeArguments? identifier #methodreferenceexpression diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index 862ecc17..4ee5121d 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -44,7 +44,7 @@ import de.dhbwstuttgart.parser.antlr.Java17Parser.LabeledRuleExprListContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.LabeledRulePatternContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.LabeledstmtContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.LambdaLVTIParameterContext; -import de.dhbwstuttgart.parser.antlr.Java17Parser.LambdaexpressionContext; +import de.dhbwstuttgart.parser.antlr.Java17Parser.LambdaExpression2Context; import de.dhbwstuttgart.parser.antlr.Java17Parser.MathaddsubexpressionContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.MathmuldivmodexpressionContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.MethodCallContext; @@ -63,7 +63,7 @@ import de.dhbwstuttgart.parser.antlr.Java17Parser.PrimaryLiteralContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.PrimaryPatternContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.PrimarySuperContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.PrimaryThisContext; -import de.dhbwstuttgart.parser.antlr.Java17Parser.PrimaryexpressionContext; +import de.dhbwstuttgart.parser.antlr.Java17Parser.PrimaryExpression2Context; import de.dhbwstuttgart.parser.antlr.Java17Parser.RPatternContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.RecordPatternContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.RelationalexpressionContext; @@ -79,7 +79,7 @@ import de.dhbwstuttgart.parser.antlr.Java17Parser.SwitchLabelDefaultContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.SwitchLabelPatternContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.SwitchLabeledRuleContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.SwitchRuleOutcomeContext; -import de.dhbwstuttgart.parser.antlr.Java17Parser.SwitchexpressionContext; +import de.dhbwstuttgart.parser.antlr.Java17Parser.SwitchExpression2Context; import de.dhbwstuttgart.parser.antlr.Java17Parser.SwitchstmtContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.SynchronizedstmtContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.TPatternContext; @@ -272,7 +272,7 @@ public class StatementGenerator { ret = convert(prefix); ret.setStatement(); return ret; - case SwitchexpressionContext switchexpr: + case SwitchExpression2Context switchexpr: ret = convert(switchexpr); ret.setStatement(); return ret; @@ -359,7 +359,7 @@ public class StatementGenerator { } // Um switchExpressions als Statement zu behandeln - private Statement convert(Java17Parser.SwitchexpressionContext switchexpression) { + private Statement convert(Java17Parser.SwitchExpression2Context switchexpression) { Expression switchExpr = convert(switchexpression.switchExpression()); if (switchExpr instanceof Switch s) { s.setStatement(); @@ -624,7 +624,7 @@ public class StatementGenerator { private Expression convert(Java17Parser.ExpressionContext expression) { switch (expression) { - case PrimaryexpressionContext primary: + case PrimaryExpression2Context primary: return convert(primary.primary()); case DottedexpressionContext dotted: return convert(dotted, expression.getStart()); @@ -646,13 +646,13 @@ public class StatementGenerator { return convert(comparison); case InstanceofexpressionContext instanceOf: return convert(instanceOf); - case SwitchexpressionContext switchexpression: + case SwitchExpression2Context switchexpression: return convert(switchexpression.switchExpression()); case EqualityexpressionContext equal: return convert(equal); case AssignexpressionContext assignment: return convert(assignment); - case LambdaexpressionContext lambdaexpr: + case LambdaExpression2Context lambdaexpr: return convert(lambdaexpr.lambdaExpression()); case ArrayaccessexpressionContext arrayaccess: return convert(arrayaccess); @@ -725,7 +725,7 @@ public class StatementGenerator { public Receiver getReceiver(ExpressionContext expr) { Expression expression = convert(expr); /* - * if (expr instanceof PrimaryexpressionContext pc) { expression = convert(pc.primary()); } else { expression = generateLocalOrFieldVarOrClassName(expr.getText(), expr.getStart()); } + * if (expr instanceof PrimaryExpression2Context pc) { expression = convert(pc.primary()); } else { expression = generateLocalOrFieldVarOrClassName(expr.getText(), expr.getStart()); } */ return getReceiver(expression); } diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java index 810a8b73..e4f031a9 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java @@ -54,7 +54,7 @@ import de.dhbwstuttgart.parser.antlr.Java17Parser.ModifierContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.NoclassorinterfaceContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.RecordComponentContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.RecordDeclarationContext; -import de.dhbwstuttgart.parser.antlr.Java17Parser.ReftypeContext; +import de.dhbwstuttgart.parser.antlr.Java17Parser.RefType2Context; import de.dhbwstuttgart.parser.antlr.Java17Parser.SrcfileContext; import de.dhbwstuttgart.parser.antlr.Java17Parser.TypeArgumentsContext; import de.dhbwstuttgart.parser.scope.GatherNames; @@ -419,7 +419,7 @@ public class SyntaxTreeGenerator { if (Objects.isNull(bodydeclaration.refType())) { retType = TypePlaceholder.fresh(bodydeclaration.getStart()); } else { - if (bodydeclaration.refType() instanceof ReftypeContext reftype) { + if (bodydeclaration.refType() instanceof RefType2Context reftype) { retType = TypeGenerator.convert(reftype.typeType(), reg, generics); } else { retType = new Void(bodydeclaration.refType().getStart()); @@ -512,7 +512,7 @@ public class SyntaxTreeGenerator { if (Objects.isNull(header.refType())) { retType = TypePlaceholder.fresh(header.getStart()); } else { - if (header.refType() instanceof ReftypeContext reftype) { + if (header.refType() instanceof RefType2Context reftype) { retType = TypeGenerator.convert(reftype.typeType(), reg, generics); } else { retType = new Void(header.refType().getStart());