Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81248 / brainfsck / app / Main.hs
diff options
context:
space:
mode:
1 files changed, 21 insertions, 0 deletions
-rw-r--r--homework/81248/brainfsck/app/Main.hs21
diff --git a/homework/81248/brainfsck/app/Main.hs b/homework/81248/brainfsck/app/Main.hs
new file mode 100644
index 0000000..de56a4f
--- /dev/null
+++ b/homework/81248/brainfsck/app/Main.hs
@@ -0,0 +1,21 @@
+module Main
+ ( main
+ ) where
+
+import qualified Data.ByteString as BS
+
+import System.Environment
+
+import Brainfsck.Eval (eval)
+import Brainfsck.Parse (parse)
+
+main :: IO ()
+main = do
+ xs <- getArgs
+ if length xs /= 1
+ then putStrLn usage
+ else either fail eval . parse =<< BS.readFile (head xs)
+
+usage :: String
+usage = "Usage: Start brainfsck with one argument - the path to a brainfuck script.\n\
+ \> stack run brainfsck -- asdf.bf"