aboutsummaryrefslogtreecommitdiff
path: root/bin/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/Main.hs')
-rw-r--r--bin/Main.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/Main.hs b/bin/Main.hs
new file mode 100644
index 0000000..2942566
--- /dev/null
+++ b/bin/Main.hs
@@ -0,0 +1,26 @@
1module Main where
2
3import Evaluator (eval)
4import Parser (Expr (..), parseLispValue)
5import System.Console.Readline
6import Text.ParserCombinators.Parsec
7
8readExpr :: String -> Expr
9readExpr inp =
10 case parse parseLispValue "(unknown)" inp of
11 Left err -> StringLiteral $ show err
12 Right val -> val
13
14repl :: IO ()
15repl = do
16 inp <- readline "(lisk)> "
17 case inp of
18 Nothing -> return ()
19 Just ",q" -> return ()
20 Just line -> do
21 addHistory line
22 print . eval . readExpr $ line
23 repl
24
25main :: IO ()
26main = repl