tools/pas2c.hs
changeset 6979 cd28fe36170a
parent 6967 1224c6fb36c3
child 6980 07a710e22846
equal deleted inserted replaced
6978:1dc33050149d 6979:cd28fe36170a
   368         _ -> type2C t
   368         _ -> type2C t
   369     return [text "typedef" <+> tp i]
   369     return [text "typedef" <+> tp i]
   370     
   370     
   371 tvar2C _ (VarDeclaration isConst (ids, t) mInitExpr) = do
   371 tvar2C _ (VarDeclaration isConst (ids, t) mInitExpr) = do
   372     t' <- liftM (((if isConst then text "const" else empty) <+>) . ) $ type2C t
   372     t' <- liftM (((if isConst then text "const" else empty) <+>) . ) $ type2C t
       
   373     lt <- gets lastType
   373     ie <- initExpr mInitExpr
   374     ie <- initExpr mInitExpr
   374     liftM (map(\i -> t' i <+> ie)) $ mapM (id2CTyped t) ids
   375     case (isConst, lt, ids, mInitExpr) of
       
   376          (True, BTInt, [i], Just _) -> do
       
   377              i' <- id2CTyped t i
       
   378              return [text "enum" <> braces (i' <+> ie)]
       
   379          _ -> liftM (map(\i -> t' i <+> ie)) $ mapM (id2CTyped t) ids
   375     where
   380     where
   376     initExpr Nothing = return $ empty
   381     initExpr Nothing = return $ empty
   377     initExpr (Just e) = liftM (text "=" <+>) (initExpr2C e)
   382     initExpr (Just e) = liftM (text "=" <+>) (initExpr2C e)
   378     
   383     
   379 tvar2C f (OperatorDeclaration op (Identifier i _) ret params body) = do
   384 tvar2C f (OperatorDeclaration op (Identifier i _) ret params body) = do