aboutsummaryrefslogtreecommitdiffhomepage
path: root/arith/Main.hs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-01-03 14:16:31 +0900
committernsfisis <nsfisis@gmail.com>2026-01-03 14:16:31 +0900
commitd4edcd19883929b6969c8d881680a21bcd55ddfe (patch)
tree2599d74a5c8ae86a26220917177b6fc3b7bb20e1 /arith/Main.hs
parentc5d7583bd9febdbb70322c08fc4cacdf2c7d11e5 (diff)
downloadTaPL-impls-d4edcd19883929b6969c8d881680a21bcd55ddfe.tar.gz
TaPL-impls-d4edcd19883929b6969c8d881680a21bcd55ddfe.tar.zst
TaPL-impls-d4edcd19883929b6969c8d881680a21bcd55ddfe.zip
section 4. arithHEADmain
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