improved slightly

master
parent f47c3f0280
commit 18ddac1e30
Signed by: yogsototh
GPG Key ID: 7B19A4C650D59646

@ -0,0 +1 @@
eval "$(lorri direnv)"

@ -7,19 +7,13 @@ This project is an experimental LISP flavoured Shell
## Build
Install [`stack`](http://haskellstack.org)
Install [`nix`](https://nixos.org/nix)
And then
~~~
git clone https://github.com/yogsototh/lish.git
cd lish
stack setup && stack build
stack exec -- lish-exe
nix-shell
cabal run lish
~~~
## To note
This Haskell project use the stack template `tasty-travis`.
Please read file `tutorial.md` for first steps in using the template.

@ -22,6 +22,8 @@ parseTests =
, testCase "_foo" (simpleCommand "_foo")
, testCase "multiline"
(parseCmd "(fn [x]\n (+ x 1))" @?= Right incExpr)
, testCase "multiline 2"
(parseCmd "(fn\n [x]\n (+ x 1))" @?= Right incExpr)
-- TODO: or not? support line comment
-- , testCase "multiline command with comment"
-- (parseCmd "(fn [x] ; comment \n (+ x 1))" @?= Right incExpr)

@ -23,21 +23,19 @@ parseExpr = parseLambda
<|> parseString
parseNumber :: Parser Expr
parseNumber = (Fix . Num . fromMaybe 0 . readMaybe) <$> many1 digit
parseNumber = Fix . Num . fromMaybe 0 . readMaybe <$> many1 digit
parseAtom :: Parser Expr
parseAtom = do
frst <- noneOf " \t()[]\""
rest <- many (noneOf " \t()[]")
frst <- noneOf " \t\n()[]{}\""
rest <- many (noneOf " \t\n()[]{}")
case frst:rest of
"true" -> return . Fix $ Bool True
"false" -> return . Fix $ Bool False
x -> return . Fix $ Atom (toS x)
parseString :: Parser Expr
parseString = (Fix . Str . toS) <$> between (char '"')
(char '"')
(many (noneOf "\""))
parseString = Fix . Str . toS <$> between (char '"') (char '"') (many (noneOf "\""))
parseExprs :: Parser [Expr]
parseExprs = sepEndBy parseExpr spaces

Loading…
Cancel
Save