summaryrefslogtreecommitdiff
path: root/main.hs
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-04-15 00:12:01 +0200
committerTom Smeding <tom.smeding@gmail.com>2018-04-15 00:12:01 +0200
commit873c294497c74e85eae5310cbf19269807c75e6d (patch)
treebc8558a62559b449ff702593cdc40314359ae2db /main.hs
parent6489f93d146d7b6a381fc2815158240d26b5febc (diff)
Build with stack
Diffstat (limited to 'main.hs')
-rw-r--r--main.hs44
1 files changed, 0 insertions, 44 deletions
diff --git a/main.hs b/main.hs
deleted file mode 100644
index 9c33f83..0000000
--- a/main.hs
+++ /dev/null
@@ -1,44 +0,0 @@
-module Main where
-
-import Control.Monad
-import Data.Char
-import System.Environment
-import System.Exit
-import System.Process
-
-import AST
-import Compiler
-import Interpreter
-import Parser
-import Optimiser
-
-
-data ExecutionMode = EMInterpret | EMCompile
-
-executionMode :: ExecutionMode
-executionMode = EMCompile
-
-
-main :: IO ()
-main = do
- args <- getArgs
- when (length args == 0 || length args > 2)
- $ die "Usage: bfcomphs <source.bf>"
- let fname = head args
-
- prog <- readFile fname >>= either die return . parseProgram
-
- -- putStrLn $ astSuccinct prog
- -- print prog
- let opt = optimise prog
- writeFile (fname ++ ".succinct") $ astSuccinct opt
- writeFile (fname ++ ".ast") $ show opt
-
- case executionMode of
- EMInterpret -> do
- input <- getContents
- interpret opt (map (fromIntegral . ord) input) >>= (putStr . map (chr . fromIntegral))
- EMCompile -> do
- writeFile (fname ++ ".asm") $ compile opt
- callProcess "yasm" ["-f", "macho64", fname ++ ".asm", "-o", fname ++ ".o"]
- callProcess "gcc" [fname ++ ".o", "-o", fname ++ ".exe"]