From eb03afe3431d1e3d0cb7a3a6fc4fcdb913f73d42 Mon Sep 17 00:00:00 2001 From: Laborratte5 Date: Sat, 20 Jul 2024 08:26:20 +0200 Subject: [PATCH] Represent negative constants as negative values instead of -1 * positiveValue --- app/AbstractSyntaxTree.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/app/AbstractSyntaxTree.hs b/app/AbstractSyntaxTree.hs index 009ccdc..648636c 100644 --- a/app/AbstractSyntaxTree.hs +++ b/app/AbstractSyntaxTree.hs @@ -33,4 +33,5 @@ simplifyFactor :: Parser.Factor -> Node simplifyFactor factor = case factor of Parser.Integer i -> Scalar i Parser.Parantheses expr -> simplifyExpr expr + Parser.NegFactor (Parser.Integer i) -> Scalar (-i) -- Shortcut to avoid storing -x as -1 * x Parser.NegFactor factor2 -> Operation Mult (Scalar (-1)) (simplifyFactor factor2)