module CatchMain where import Language.Haskell.Pretty import Target import Expr import Parser import RecCompiler import TranslateHS primitives = commonPrimitivesPlus test useDo prog = prettyPrint $ translateToHs useDo $ removeSugar False $ simplify $ instOnce primitives $ deBruijn $ comp $ myParse prog testDecls useDo prog = concat $ map (\ str -> str ++ "\n") $ map prettyPrint $ translateToHsDecls useDo $ removeSugarDecls False $ simplifyDecls $ instOnceDecls' primitives $ deBruijnDecls' $ compDecls' $ myParseDecls prog where compDecls' (is, ds) = (is, compDecls ds) deBruijnDecls' (is, ds) = (is, deBruijnDecls ds) instOnceDecls' prims (is, ds) = instOnceDecls (prims ++ is) ds utilTry = "try 1 / 0 catch 99999" utilAmb = "(amb 1 or 2) * (amb 3 or 4)" utilFactDecl = "fact = \\ n -> if n <= 1 then 1 else n * fact(amb n - 1 or n - 2)" utilFact = "let " ++ utilFactDecl ++ " in fact 9" -- for example, -- putStrLn $ test False utilTry -- putStrLn $ test False utilAmb -- putStrLn $ test False utilFact