From d4edcd19883929b6969c8d881680a21bcd55ddfe Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 3 Jan 2026 14:16:31 +0900 Subject: section 4. arith --- arith/Main.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 arith/Main.hs (limited to 'arith/Main.hs') 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 "" line of + Left err -> print err + Right term -> print (eval term) + repl + +main :: IO () +main = repl -- cgit v1.3.1