mirror of
https://github.com/zoriya/HAL.git
synced 2025-12-06 06:36:09 +00:00
Adding a REPL
This commit is contained in:
15
app/Main.hs
15
app/Main.hs
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user