]> ruin.nu Git - proglang.git/blobdiff - Compile.hs
merged changes to function branch
[proglang.git] / Compile.hs
index 0e1cf22a1c0b0239f43af889962496e9ce2c37f7..eb70d0c8223e9e71ec356cce274f850ad454239b 100644 (file)
@@ -1,8 +1,15 @@
-module Compile (compileExp, compileStm) where
+module Compile (compile,compileExp, compileStm) where
 
 import Abssyntax
 import Prelude hiding (lookup)
 
+cHeader = "#include <stdio.h>\nint read(){\nint n;\nscanf(\"%d\",&n);\nreturn n;\n}\nint main(void){\n"
+
+cFooter = "return 0;}"
+
+compile :: [Func] -> [Stm] -> String
+compile f s = cHeader++concat (map compileStm s)++cFooter
+
 compileExp :: Exp -> String
 compileExp (EBool True) = "1";
 compileExp (EBool False) = "0";