fix pred/succ conversion 1.0.0
authoralfadur
Wed, 21 Sep 2022 06:36:05 +0300
branch1.0.0
changeset 15873 f8a3f204242d
parent 15869 ccce86a05f31
child 15874 fac577eb8756
fix pred/succ conversion
tools/pas2c/Pas2C.hs
--- a/tools/pas2c/Pas2C.hs	Mon Sep 12 18:37:04 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