aboutsummaryrefslogtreecommitdiffhomepage
path: root/arith/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'arith/Main.hs')
-rw-r--r--arith/Main.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/arith/Main.hs b/arith/Main.hs
new file mode 100644
index 0000000..45b10eb
--- /dev/null
+++ b/arith/Main.hs
@@ -0,0 +1,23 @@
+module Main where
+
+import System.IO (hFlush, stdout)
+import Text.Parsec (parse)
+
+import Core
+import Parser
+
+repl :: IO ()
+repl = do
+ putStr "arith> "
+ hFlush stdout
+ line <- getLine
+ if line == ":q"
+ then putStrLn "Bye!"
+ else do
+ case parse parseProgram "<stdin>" line of
+ Left err -> print err
+ Right term -> print (eval term)
+ repl
+
+main :: IO ()
+main = repl