]> ruin.nu Git - proglang.git/blobdiff - Compile.hs
added constructor for declaration with default value
[proglang.git] / Compile.hs
index 69edecd879be433bab4f32259f8f0f79d2af0d41..0e1cf22a1c0b0239f43af889962496e9ce2c37f7 100644 (file)
@@ -36,4 +36,8 @@ compileStm (SIf b s s') = "if("++compileExp b++")"++compileStm s++" \nelse "++co
 compileStm (SPrint e) = "printf(\"%d\\n\","++compileExp e++");\n"
 compileStm (SBlock ss) = "{\n"++concat (map (("\t"++).compileStm) ss)++"\n}\n"
 compileStm (SWhile e s) = "while("++compileExp e++")"++compileStm s
+compileStm (SDeclD t i) = compileStm (SDecl t i $ case t of
+       TInt -> EInt 0
+       TBool -> EBool False
+       )
 compileStm (SDecl t (Ident i) e) = "int "++i++"="++compileExp e++";\n"