-
Notifications
You must be signed in to change notification settings - Fork 1
/
barc.hs
36 lines (31 loc) · 987 Bytes
/
barc.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Main (main) where
import Barc.Runner (runFromFile, runFromFileBit, runFromFileFuthark)
import System.Environment (getArgs)
import System.IO (hPutStrLn, stderr)
import System.Exit (exitFailure, exitSuccess)
import qualified Data.Text.IO as T
showHelp :: IO ()
showHelp = do
putStrLn "barc: compile board descriptions"
putStrLn ""
putStrLn "Usage:"
putStrLn " ./barc [OPTION] FILE.barc"
putStrLn ""
putStrLn "Options:"
putStrLn " --gotta-go-fast Compile to Futhark instead of C"
putStrLn " --fernando Compile to NAND-only C instead of C (very, very slow)"
main :: IO ()
main = do
args <- getArgs
result <-
case args of
["--help"] -> showHelp >> exitSuccess
["--gotta-go-fast", path] -> runFromFileFuthark path
["--fernando", path] -> runFromFileBit path
[path] -> runFromFile path
_ -> showHelp >> exitFailure
case result of
Left err -> do
hPutStrLn stderr err
exitFailure
Right s -> T.putStr s