diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-07-14 22:59:19 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-07-14 22:59:19 +0200 |
commit | 06533ad580c1afee4ee9b71fa956d2b8586c118a (patch) | |
tree | 96b8de3b8d8046fb7015045ae895a001ea410307 /main.hs | |
parent | e65072b6efe6692c90919410c54cf2d14d20f3d5 (diff) |
Fixes and improvements
Diffstat (limited to 'main.hs')
-rw-r--r-- | main.hs | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -1,6 +1,5 @@ module Main where -import Control.DeepSeq import Control.Monad import Data.Char import System.Environment @@ -24,18 +23,16 @@ main :: IO () main = do args <- getArgs when (length args == 0 || length args > 2) - $ die "Usage: bfcomphs <source.bf> [source.bf.exe]" + $ die "Usage: bfcomphs <source.bf>" let fname = head args - destfname = if length args == 2 then args !! 1 else fname ++ ".exe" prog <- readFile fname >>= either die return . parseProgram -- putStrLn $ astSuccinct prog -- print prog let opt = optimise prog - showopt = force $ show opt - when True $ putStrLn $ astSuccinct opt - when False $ putStrLn showopt + writeFile (fname ++ ".succinct") $ astSuccinct opt + writeFile (fname ++ ".ast") $ show opt case executionMode of EMInterpret -> do @@ -44,4 +41,4 @@ main = do EMCompile -> do writeFile (fname ++ ".asm") $ compile opt callProcess "yasm" ["-f", "macho64", fname ++ ".asm", "-o", fname ++ ".o"] - callProcess "gcc" [fname ++ ".o", "-o", destfname] + callProcess "gcc" [fname ++ ".o", "-o", fname ++ ".exe"] |