summaryrefslogtreecommitdiff
path: root/main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'main.hs')
-rw-r--r--main.hs11
1 files changed, 4 insertions, 7 deletions
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> [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"]