From c850d35d2f4b392ebbf36932f4becdf95641fd94 Mon Sep 17 00:00:00 2001 From: Atreya Bain Date: Mon, 26 Oct 2020 14:52:06 +0530 Subject: Add comments into whitespace --- src/Parser.hs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index 67d302a..feb56d3 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -12,12 +12,6 @@ import Control.Applicative ((<$>)) import Text.ParserCombinators.Parsec -parseComment :: Parser () -parseComment = do - char ';' - innards <- many (noneOf ['\n']) - return () - -- backslash double quote escapes a quote inside strings quotedChar = noneOf ['\"'] <|> try (string "\\\"" >> return '"') @@ -71,15 +65,25 @@ parseId = do "#f" -> BoolLiteral False _ -> Id atom +-- atmosphere +parseComment :: Parser () +parseComment = do + char ';' + skipMany (noneOf ['\n']) + -- skipMany $ char '\n' + return () + + whiteSpace :: Parser () -whiteSpace = - skipMany1 ( oneOf [' ', '\n']) - <|> parseComment +whiteSpace = do + optionMaybe parseComment + skipMany1 ( oneOf [' ', '\n']) "whitespace or newline" + return () optionalWhiteSpace :: Parser () -optionalWhiteSpace = - skipMany ( oneOf [' ', '\n']) - <|> parseComment +optionalWhiteSpace = do + optionMaybe $ whiteSpace + return () type Alias = String parseModifier :: String -> Alias -> Parser Expr -- cgit v1.2.3