From f943fc17e5f80f92d20c86de5ea499bbfbe0cd75 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 13 Oct 2020 18:07:29 +0530 Subject: allow multiline expressions --- lisk.cabal | 3 ++- src/Parser.hs | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lisk.cabal b/lisk.cabal index bea3414..9578a85 100644 --- a/lisk.cabal +++ b/lisk.cabal @@ -27,7 +27,8 @@ library Parser, Evaluator, Operators, - Error + Error.Base + Error.Pretty executable lisk default-language: Haskell2010 diff --git a/src/Parser.hs b/src/Parser.hs index 1242645..dc754d3 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -69,7 +69,10 @@ parseId = do _ -> Id atom whiteSpace :: Parser () -whiteSpace = skipMany1 space +whiteSpace = skipMany1 $ oneOf [' ', '\n'] + +optionalWhiteSpace :: Parser () +optionalWhiteSpace = skipMany $ oneOf [' ', '\n'] type Alias = String parseModifier :: Char -> Alias -> Parser Expr @@ -98,7 +101,7 @@ parseLispValue = x <- sepEndBy parseLispValue whiteSpace spaces t <- optionMaybe $ char '.' >> space >> parseLispValue - spaces >> char ')' + optionalWhiteSpace >> char ')' return $ maybe (List x) (DottedList x) t "lisp value" -- cgit v1.2.3