From bbfdbd51dc5f014141f56aa1e9995db1c28cf24e Mon Sep 17 00:00:00 2001 From: laurenz Date: Wed, 8 May 2024 23:57:44 +0200 Subject: [PATCH] Ids are gotten explicitly from the IDENTIFIER --- src/main/java/de/maishai/ASTGenerator.java | 8 ++++---- src/main/java/de/maishai/ExpressionGenerator.java | 6 +++--- src/main/java/de/maishai/StatementGenerator.java | 4 ++-- src/main/java/de/maishai/VariableGenerator.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/maishai/ASTGenerator.java b/src/main/java/de/maishai/ASTGenerator.java index 1192347..8e0dfd8 100644 --- a/src/main/java/de/maishai/ASTGenerator.java +++ b/src/main/java/de/maishai/ASTGenerator.java @@ -24,16 +24,16 @@ public class ASTGenerator { if (ctx.meth() != null) { meths = ctx.meth().stream().map(ASTGenerator::generateMethod).toList(); } - return new Class(ctx.id().getText(), declarations, meths, constructors); + return new Class(ctx.id().IDENTIFIER().getText(), declarations, meths, constructors); } public static Declaration generateFieldVariable(DecafParser.FieldContext ctx) { Type type = ASTGenerator.getType(ctx.type()); - return new Declaration(ctx.id().getText(), type); + return new Declaration(ctx.id().IDENTIFIER().getText(), type); } public static Parameter generateParameter(DecafParser.ParamContext ctx) { - return new Parameter(ctx.id().getText(), getType(ctx.type())); + return new Parameter(ctx.id().IDENTIFIER().getText(), getType(ctx.type())); } public static Method generateMethod(DecafParser.MethContext ctx) { @@ -42,7 +42,7 @@ public class ASTGenerator { params = ctx.params().param().stream().map(ASTGenerator::generateParameter).toList(); } Block block = new BlockGenerator().visit(ctx.block()); - return new Method(getType(ctx.returntype()), ctx.id().getText(), params, block); + return new Method(getType(ctx.returntype()), ctx.id().IDENTIFIER().getText(), params, block); } public static Constructor generateConstructor(DecafParser.ConstructorContext ctx) { diff --git a/src/main/java/de/maishai/ExpressionGenerator.java b/src/main/java/de/maishai/ExpressionGenerator.java index d118cb1..71bb4d9 100644 --- a/src/main/java/de/maishai/ExpressionGenerator.java +++ b/src/main/java/de/maishai/ExpressionGenerator.java @@ -97,7 +97,7 @@ public class ExpressionGenerator extends DecafBaseVisitor { Expression astExpr = expr.accept(this); args.add(astExpr); } - return new MethodCall(new FieldVarAccess(isField, recursiveOwnerChain, ctx.methCall().methName().id().getText()), args); + return new MethodCall(new FieldVarAccess(isField, recursiveOwnerChain, ctx.methCall().methName().id().IDENTIFIER().getText()), args); } @Override @@ -118,7 +118,7 @@ public class ExpressionGenerator extends DecafBaseVisitor { DecafParser.RecipientContext ctx = ctxList.get(0); ctxList.remove(0); if (ctx.id() != null) { - return new FieldVarAccess(false, generateRecursiveOwnerChain(ctxList, recipient), ctx.id().getText()); + return new FieldVarAccess(false, generateRecursiveOwnerChain(ctxList, recipient), ctx.id().IDENTIFIER().getText()); } if (ctx.methName() != null) { List args = new ArrayList<>(); @@ -127,7 +127,7 @@ public class ExpressionGenerator extends DecafBaseVisitor { Expression astExpr = expr.accept(new ExpressionGenerator()); args.add(astExpr); } - return new MethodCall(new FieldVarAccess(false, generateRecursiveOwnerChain(ctxList, recipient), ctx.methName().id().getText()), args); + return new MethodCall(new FieldVarAccess(false, generateRecursiveOwnerChain(ctxList, recipient), ctx.methName().id().IDENTIFIER().getText()), args); } throw new RuntimeException(); diff --git a/src/main/java/de/maishai/StatementGenerator.java b/src/main/java/de/maishai/StatementGenerator.java index db0d143..1da2be2 100644 --- a/src/main/java/de/maishai/StatementGenerator.java +++ b/src/main/java/de/maishai/StatementGenerator.java @@ -75,7 +75,7 @@ public class StatementGenerator extends DecafBaseVisitor { private FieldVarAccess generateField(DecafParser.FieldVarAccessContext fieldIdContext) { return new FieldVarAccess(fieldIdContext.THIS() != null, ExpressionGenerator.generateRecursiveOwnerChain(fieldIdContext.recipient(), - null), fieldIdContext.id().getText()); + null), fieldIdContext.id().IDENTIFIER().getText()); } //StatementExpression @@ -92,7 +92,7 @@ public class StatementGenerator extends DecafBaseVisitor { Expression astExpr = expr.accept(new ExpressionGenerator()); args.add(astExpr); } - return new MethodCall(new FieldVarAccess(isField, recursiveOwnerChain, ctx.methCall().methName().id().getText()), args); + return new MethodCall(new FieldVarAccess(isField, recursiveOwnerChain, ctx.methCall().methName().id().IDENTIFIER().getText()), args); } @Override diff --git a/src/main/java/de/maishai/VariableGenerator.java b/src/main/java/de/maishai/VariableGenerator.java index 99808cc..0333cef 100644 --- a/src/main/java/de/maishai/VariableGenerator.java +++ b/src/main/java/de/maishai/VariableGenerator.java @@ -11,6 +11,6 @@ public class VariableGenerator extends DecafBaseVisitor { @Override public Declaration visitLocalVar(DecafParser.LocalVarContext ctx) { Type type = ASTGenerator.getType(ctx.type()); - return new Declaration(ctx.id().getText(), type); + return new Declaration(ctx.id().IDENTIFIER().getText(), type); } }