diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..be81fed --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +eval "$(lorri direnv)" \ No newline at end of file diff --git a/README.md b/README.md index af1c40c..0aa8ffa 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src-test/Lish/Test/Parser.hs b/src-test/Lish/Test/Parser.hs index 19686d0..18d59fb 100644 --- a/src-test/Lish/Test/Parser.hs +++ b/src-test/Lish/Test/Parser.hs @@ -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) diff --git a/src/Lish/Parser.hs b/src/Lish/Parser.hs index f76d5a7..d00277d 100644 --- a/src/Lish/Parser.hs +++ b/src/Lish/Parser.hs @@ -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