X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=Compile.hs;fp=Compile.hs;h=2252fc539064b6666fead76092317d1a16f31593;hp=0e1cf22a1c0b0239f43af889962496e9ce2c37f7;hb=9625a8a7eb7aebeb161ca15cf66cff5699f89103;hpb=97719af3b544b9fae80e886bf6a49c51b4a320a9 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";