Adding a REPL

This commit is contained in:
Zoe Roux
2021-11-03 10:54:45 +01:00
parent 88481dd285
commit 7e2b003c20
4 changed files with 19 additions and 2 deletions

View File

@@ -1,6 +1,19 @@
module Main where
import Lib
import System.Console.Haskeline
( defaultSettings, getInputLine, outputStrLn, runInputT, InputT )
import BasicParser
import LispParser
main :: IO ()
main = someFunc
main = runInputT defaultSettings loop
where
loop :: InputT IO ()
loop = do
minput <- getInputLine " > "
case minput of
Nothing -> return ()
Just "exit" -> return ()
Just "quit" -> return ()
Just input -> (outputStrLn . show $ parse pLisp input) >> loop

View File

@@ -35,6 +35,7 @@ library
src
build-depends:
base >=4.7 && <5
, haskeline
default-language: Haskell2010
executable hal-exe
@@ -47,6 +48,7 @@ executable hal-exe
build-depends:
base >=4.7 && <5
, hal
, haskeline
default-language: Haskell2010
test-suite hal-test
@@ -61,4 +63,5 @@ test-suite hal-test
HUnit
, base >=4.7 && <5
, hal
, haskeline
default-language: Haskell2010

View File

@@ -21,6 +21,7 @@ description: Please see the README on GitHub at <https://github.com/Anon
dependencies:
- base >= 4.7 && < 5
- haskeline
library:
source-dirs: src

View File

@@ -16,4 +16,4 @@ pSExpr :: Parser SExpr
pSExpr = pCharIf (== '(') *> (SExpr <$> some (tokenify pAtom)) <* pCharIf (== ')')
pLisp :: Parser [SExpr]
pLisp = some $ tokenify pSExpr
pLisp = some $ tokenify pSExpr