Represent negative constants as negative values instead of -1 * positiveValue

This commit is contained in:
Laborratte 5 2024-07-20 08:26:20 +02:00
parent 62528a6d75
commit eb03afe343
Signed by: Laborratte5
GPG key ID: 3A30072E35202C02

View file

@ -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)