X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Compile.hs;h=2252fc539064b6666fead76092317d1a16f31593;hb=cfe5796efb06251047f77bf9d2295d7093910292;hp=0e1cf22a1c0b0239f43af889962496e9ce2c37f7;hpb=fd3bc0ef4542783846af4e2c4f986e94f96c74ff;p=proglang.git diff --git a/Compile.hs b/Compile.hs index 0e1cf22..2252fc5 100644 --- a/Compile.hs +++ b/Compile.hs @@ -1,8 +1,15 @@ -module Compile (compileExp, compileStm) where +module Compile (compile,compileExp, compileStm) where import Abssyntax import Prelude hiding (lookup) +cHeader = "#include \nint read(){\nint n;\nscanf(\"%d\",&n);\nreturn n;\n}\nint main(void){\n" + +cFooter = "return 0;}" + +compile :: [Stm] -> String +compile s = cHeader++concat (map compileStm s)++cFooter + compileExp :: Exp -> String compileExp (EBool True) = "1"; compileExp (EBool False) = "0";