aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtreya Bain <[email protected]>2020-10-27 14:56:01 +0000
committerAtreya Bain <[email protected]>2020-10-27 14:56:01 +0000
commited32b282a7bf62ea8c66dd8f39fc1b03afbfc478 (patch)
tree9433bbdd7f8df33af3efd0a945f3d42cd869499d
parent1de9cdfcb7fc8c30bd05e017929dae862d847c95 (diff)
add newline consumption
-rw-r--r--src/Parser.hs21
1 files 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
10import Base (Expr (..), Function) 10import Base (Expr (..), Function)
11import Control.Applicative ((<$>)) 11import Control.Applicative ((<$>))
12import Text.ParserCombinators.Parsec 12import Text.ParserCombinators.Parsec
13import Text.Parsec.Char
13 14
14 15
15 16
@@ -69,16 +70,22 @@ parseId = do
69parseComment :: Parser () 70parseComment :: Parser ()
70parseComment = do 71parseComment = do
71 char ';' 72 char ';'
72 skipMany (noneOf ['\n']) 73 -- get internals of comment by getting it from here
73 -- skipMany $ char '\n' 74 manyTill anyChar (try (eol<|> eof))
74 return () 75 return ()
76 where eol = endOfLine >>return ()
75 77
76 78
77whiteSpace :: Parser () 79-- whiteSpace :: Parser ()
78whiteSpace = do 80-- whiteSpace = do
79 optionMaybe parseComment 81-- optionMaybe parseComment
80 skipMany1 ( oneOf [' ', '\n']) <?> "whitespace or newline" 82-- skipMany1 ( oneOf [' ', '\n']) <?> "whitespace or endOfLine"
81 return () 83-- return ()
84whiteSpace::Parser()
85whiteSpace = skipMany( parseComment <|> nl <|> spc )
86 where nl = endOfLine >>return ()
87 spc = space >> return ()
88
82 89
83optionalWhiteSpace :: Parser () 90optionalWhiteSpace :: Parser ()
84optionalWhiteSpace = do 91optionalWhiteSpace = do