mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 16:48:03 +00:00
Ids are gotten explicitly from the IDENTIFIER
This commit is contained in:
parent
dbca4ac327
commit
bbfdbd51dc
@ -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) {
|
||||
|
@ -97,7 +97,7 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
||||
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<Expression> {
|
||||
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<Expression> args = new ArrayList<>();
|
||||
@ -127,7 +127,7 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
||||
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();
|
||||
|
@ -75,7 +75,7 @@ public class StatementGenerator extends DecafBaseVisitor<Statement> {
|
||||
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<Statement> {
|
||||
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
|
||||
|
@ -11,6 +11,6 @@ public class VariableGenerator extends DecafBaseVisitor<Declaration> {
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user