fix pred/succ conversion
authoralfadur
Wed, 21 Sep 2022 06:36:05 +0300
changeset 15871 9cd8d7748199
parent 15870 f550a79274fa
child 15872 c09063ea0267
fix pred/succ conversion
tools/pas2c/Pas2C.hs
--- a/tools/pas2c/Pas2C.hs	Mon Sep 12 18:56:28 2022 -0400
+++ b/tools/pas2c/Pas2C.hs	Wed Sep 21 06:36:05 2022 +0300
@@ -711,8 +711,8 @@
          a -> error $ "BuiltInFunction 'high' in initExpr: " ++ show a ++ ": " ++ show hi
 initExpr2C' (BuiltInFunction "succ" [BuiltInFunction "pred" [e]]) = initExpr2C' e
 initExpr2C' (BuiltInFunction "pred" [BuiltInFunction "succ" [e]]) = initExpr2C' e
-initExpr2C' (BuiltInFunction "succ" [e]) = liftM (<> text " + 1") $ initExpr2C' e
-initExpr2C' (BuiltInFunction "pred" [e]) = liftM (<> text " - 1") $ initExpr2C' e
+initExpr2C' (BuiltInFunction "succ" [e]) = liftM (\e' ->  text "(" <> e' <> text " + 1)") $ initExpr2C' e
+initExpr2C' (BuiltInFunction "pred" [e]) = liftM (\e' ->  text "(" <> e' <> text " - 1)") $ initExpr2C' e
 initExpr2C' b@(BuiltInFunction _ _) = error $ show b
 initExpr2C' (InitTypeCast t' i) = do
     e <- initExpr2C i