myLLexer = myLexer
-
-cHeader = "#include <stdio.h>\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 ()
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] <file>"
+ putStrLn "-c : compile <file> to C99-compatible file"