diff options
| author | aarne <aarne@cs.chalmers.se> | 2007-03-27 16:32:44 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2007-03-27 16:32:44 +0000 |
| commit | 1c1acf1b971d13a496a92b9d8d6b14fde85e28f3 (patch) | |
| tree | 7fc40594193cbf6435feb5425ee2e4feb2652d32 /devel/compiler/PrEnv.hs | |
| parent | 273dc7120f9ce0b469dc081d6a3382f096a4f97b (diff) | |
top-level toy compiler - far from complete
Diffstat (limited to 'devel/compiler/PrEnv.hs')
| -rw-r--r-- | devel/compiler/PrEnv.hs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/devel/compiler/PrEnv.hs b/devel/compiler/PrEnv.hs new file mode 100644 index 000000000..d669e131d --- /dev/null +++ b/devel/compiler/PrEnv.hs @@ -0,0 +1,47 @@ +module PrEnv where + +import Env + +import AbsSrc +import AbsTgt + +import qualified PrintSrc as S +import qualified PrintTgt as T + +import qualified Data.Map as M + +prEnv :: Env -> IO () +prEnv env = do + putStrLn "--# values" + mapM_ putStrLn + [prs c ++ " = " ++ prt val | (c,val) <- M.toList $ values env] + putStrLn "--# types" + mapM_ putStrLn + [prs c ++ " : " ++ prs val | (c,val) <- M.toList $ types env] + putStrLn "--# typedefs" + mapM_ putStrLn + [prs c ++ " = " ++ prs val | (c,val) <- M.toList $ typedefs env] + putStrLn "--# partypes" + mapM_ putStrLn + [prs c ++ " = " ++ unwords (map prs val) | (c,val) <- M.toList $ partypes env] + putStrLn "--# parvals" + mapM_ putStrLn + [prs c ++ " = " ++ prt val | (c,val) <- M.toList $ parvals env] + +prs :: (S.Print a) => a -> String +prs = S.printTree + +prt :: (T.Print a) => a -> String +prt = T.printTree + +{- +data Env = Env { + values :: M.Map Ident Val, + types :: M.Map Ident Type, + opers :: M.Map Ident Exp, + typedefs :: M.Map Ident Type, + partypes :: M.Map Type [Exp], + parvals :: M.Map Exp Val, + vars :: M.Map Ident Val + } +-} |
