From 3cee522d1f54b39a1efa654da364c6c939cbcf1f Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 1 Mar 2006 19:21:40 +0000 Subject: [PATCH] fully functional and C99 (not C90) compliant output --- Compiler.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Compiler.hs b/Compiler.hs index 2f1f31b..d971b2f 100644 --- a/Compiler.hs +++ b/Compiler.hs @@ -24,6 +24,10 @@ myLLexer = myLexer type Verbosity = Int +cHeader = "#include \nint read(){\nint n;\nscanf(\"%d\",&n);\nreturn n;\n}\nint main(void){\n" + +cFooter = "return 0;}" + putStrV :: Verbosity -> String -> IO () putStrV v s = if v > 1 then putStrLn s else return () @@ -39,7 +43,7 @@ run v p s = let ts = myLLexer s in case p ts of putStrLn s Ok (Program s) -> do runStateT (mapM typeCheckStm s) [empty] - putStr $ concat (map compileStm s) + putStr $ cHeader++concat (map compileStm s)++cFooter return () showTree :: (Show a, Print a) => Int -> a -> IO () -- 2.39.2