From 06533ad580c1afee4ee9b71fa956d2b8586c118a Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 14 Jul 2017 22:59:19 +0200 Subject: Fixes and improvements --- main.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'main.hs') diff --git a/main.hs b/main.hs index 7d82362..9c33f83 100644 --- a/main.hs +++ b/main.hs @@ -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.exe]" + $ die "Usage: bfcomphs " 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"] -- cgit v1.2.3-54-g00ecf