-
+{-# OPTIONS -cpp #-}
------------------------------------------------------------------
-- A primop-table mangling program --
------------------------------------------------------------------
module Main where
+#if __GLASGOW_HASKELL__ >= 504
+import Text.ParserCombinators.Parsec
+#else
import Parsec
+#endif
+
import Monad
import Char
import List
++ listify (map ppType argTys) ++ " "
++ "(" ++ ppType resTy ++ ")"
-sl_name i = "SLIT(\"" ++ name i ++ "\") "
+sl_name i = "FSLIT(\"" ++ name i ++ "\") "
ppTyVar "a" = "alphaTyVar"
ppTyVar "b" = "betaTyVar"
ppType (TyApp "ThreadId#" []) = "threadIdPrimTy"
ppType (TyApp "ForeignObj#" []) = "foreignObjPrimTy"
ppType (TyApp "BCO#" []) = "bcoPrimTy"
-ppType (TyApp "Unit" []) = "unitTy" -- dodgy
+ppType (TyApp "()" []) = "unitTy" -- unitTy is TysWiredIn's name for ()
ppType (TyVar "a") = "alphaTy"
]
pTyvar = sat (`notElem` ["section","primop","with"]) pName
-pTycon = pConstructor
+pTycon = alts [pConstructor, lexeme (string "()")]
pName = lexeme (then2 (:) lower (many isIdChar))
pConstructor = lexeme (then2 (:) upper (many isIdChar))