X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=CompInt.hs;h=3b28c00c2d3c9c856b924200f0742343f19f7219;hb=b127b854d31e2936f86d4aabdcebe9cb298b23e9;hp=1188466da980b4d1886b4d3deff9d5e199fa08fc;hpb=cfe5796efb06251047f77bf9d2295d7093910292;p=proglang.git diff --git a/CompInt.hs b/CompInt.hs index 1188466..3b28c00 100644 --- a/CompInt.hs +++ b/CompInt.hs @@ -22,11 +22,6 @@ type ParseFun a = [Token] -> Err a myLLexer = myLexer - -cHeader = "#include \nint read(){\nint n;\nscanf(\"%d\",&n);\nreturn n;\n}\nint main(void){\n" - -cFooter = "return 0;}" - putStrV :: Int -> String -> IO () putStrV v s = if v > 1 then putStrLn s else return () @@ -49,6 +44,10 @@ main = do args <- getArgs case args of [] -> hGetContents stdin >>= run interpret pStms - "-c":f:[] -> runFile (writeFile (f++".c") . compile) pStms f + "-c":f:[] -> let file = (f++".c") in do + putStrLn $ "Compiling "++f++" to the C99-compatible file:"++file + runFile (writeFile file . compile) pStms f f:[] -> runFile interpret pStms f - _ -> print "Too many arguments" + _ -> do + putStrLn "Usage: ./CompInt [-c] " + putStrLn "-c : compile to C99-compatible file"