From ed32b282a7bf62ea8c66dd8f39fc1b03afbfc478 Mon Sep 17 00:00:00 2001 From: Atreya Bain Date: Tue, 27 Oct 2020 20:26:01 +0530 Subject: add newline consumption --- src/Parser.hs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index 34d90ba..cf58a2b 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -10,6 +10,7 @@ module Parser ( parseLispValue import Base (Expr (..), Function) import Control.Applicative ((<$>)) import Text.ParserCombinators.Parsec +import Text.Parsec.Char @@ -69,16 +70,22 @@ parseId = do parseComment :: Parser () parseComment = do char ';' - skipMany (noneOf ['\n']) - -- skipMany $ char '\n' + -- get internals of comment by getting it from here + manyTill anyChar (try (eol<|> eof)) return () + where eol = endOfLine >>return () -whiteSpace :: Parser () -whiteSpace = do - optionMaybe parseComment - skipMany1 ( oneOf [' ', '\n']) "whitespace or newline" - return () +-- whiteSpace :: Parser () +-- whiteSpace = do +-- optionMaybe parseComment +-- skipMany1 ( oneOf [' ', '\n']) "whitespace or endOfLine" +-- return () +whiteSpace::Parser() +whiteSpace = skipMany( parseComment <|> nl <|> spc ) + where nl = endOfLine >>return () + spc = space >> return () + optionalWhiteSpace :: Parser () optionalWhiteSpace = do -- cgit v1.2.3