diff options
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 21 |
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 | |||
10 | import Base (Expr (..), Function) | 10 | import Base (Expr (..), Function) |
11 | import Control.Applicative ((<$>)) | 11 | import Control.Applicative ((<$>)) |
12 | import Text.ParserCombinators.Parsec | 12 | import Text.ParserCombinators.Parsec |
13 | import Text.Parsec.Char | ||
13 | 14 | ||
14 | 15 | ||
15 | 16 | ||
@@ -69,16 +70,22 @@ parseId = do | |||
69 | parseComment :: Parser () | 70 | parseComment :: Parser () |
70 | parseComment = do | 71 | parseComment = 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 | ||
77 | whiteSpace :: Parser () | 79 | -- whiteSpace :: Parser () |
78 | whiteSpace = 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 () |
84 | whiteSpace::Parser() | ||
85 | whiteSpace = skipMany( parseComment <|> nl <|> spc ) | ||
86 | where nl = endOfLine >>return () | ||
87 | spc = space >> return () | ||
88 | |||
82 | 89 | ||
83 | optionalWhiteSpace :: Parser () | 90 | optionalWhiteSpace :: Parser () |
84 | optionalWhiteSpace = do | 91 | optionalWhiteSpace = do |