X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=blobdiff_plain;f=Compile.hs;h=eb70d0c8223e9e71ec356cce274f850ad454239b;hp=0e1cf22a1c0b0239f43af889962496e9ce2c37f7;hb=04f0a9566794cf761b7bcf83190051a400ec3653;hpb=8687a7c6790e959242228d64c8c513771565f8c1 diff --git a/Compile.hs b/Compile.hs index 0e1cf22..eb70d0c 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 :: [Func] -> [Stm] -> String +compile f s = cHeader++concat (map compileStm s)++cFooter + compileExp :: Exp -> String compileExp (EBool True) = "1"; compileExp (EBool False) = "0";