Website Summary Files Commits Branches @commit @diff @stats
path: root / homework / 81333 / brainfsck / app
diff options
context:
space:
mode:
1 files changed, 22 insertions, 0 deletions
-rw-r--r--homework/81333/brainfsck/app/Main.hs22
diff --git a/homework/81333/brainfsck/app/Main.hs b/homework/81333/brainfsck/app/Main.hs
new file mode 100644
index 0000000..a45882e
--- /dev/null
+++ b/homework/81333/brainfsck/app/Main.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Main where
+
+import System.Environment (getArgs)
+
+import qualified Data.ByteString.Char8 as B
+
+import Lib (blocks)
+
+import Text.Brainfsck.Parser (parseText)
+import Text.Brainfsck.Types
+
+main :: IO ()
+main = do
+ args <- getArgs
+ case args of
+ [] -> putStrLn "Usage: stack exec brainfsck-exe <file_with_code>"
+ _ -> do
+ code <- B.readFile $ args !! 0
+ result <- blocks newBlocks $ parseText code
+ B.putStrLn $ r result