From 60958538d82d085fb4ae1cce272597adda0981ca Mon Sep 17 00:00:00 2001 From: StefanZ3 Date: Thu, 27 Jun 2024 08:11:04 +0200 Subject: [PATCH] change UnaryExpression --- .../java/abstractSyntaxTree/Expression/UnaryExpression.java | 4 ++-- src/main/java/astGenerator/ASTGenerator.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java b/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java index 4a2243c..21b130d 100644 --- a/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java +++ b/src/main/java/abstractSyntaxTree/Expression/UnaryExpression.java @@ -15,8 +15,8 @@ import java.util.Objects; public class UnaryExpression extends AbstractType implements IExpression{ public String operator; - public IDatatype operand; - public UnaryExpression(String operator, IDatatype operand){ + public IExpression operand; + public UnaryExpression(String operator, IExpression operand){ this.operator = operator; this.operand = operand; } diff --git a/src/main/java/astGenerator/ASTGenerator.java b/src/main/java/astGenerator/ASTGenerator.java index 3d7d34e..980fc01 100644 --- a/src/main/java/astGenerator/ASTGenerator.java +++ b/src/main/java/astGenerator/ASTGenerator.java @@ -271,7 +271,8 @@ public class ASTGenerator extends DecafBaseVisitor { } else if (ctx.value() != null) { return visitValue(ctx.value()); } else if (ctx.binaryExpr() != null) { - //todo + IExpression expression = (IExpression) visit(ctx.binaryExpr()); + return new UnaryExpression("!", expression); } return null; }