diff options
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index 94de680..6247843 100644 --- a/src/Parser.hs +++ b/src/Parser.hs | |||
@@ -2,11 +2,12 @@ module Parser ( parseLispValue | |||
2 | , parseString | 2 | , parseString |
3 | , parseInt | 3 | , parseInt |
4 | , parseFloat | 4 | , parseFloat |
5 | , parseComment | ||
5 | , parseId | 6 | , parseId |
6 | , parseQuote | 7 | , parseQuote |
7 | ) where | 8 | ) where |
8 | 9 | ||
9 | import Base (Expr (..), Function) | 10 | import Base (Expr (..)) |
10 | import Control.Applicative ((<$>)) | 11 | import Control.Applicative ((<$>)) |
11 | import Text.ParserCombinators.Parsec | 12 | import Text.ParserCombinators.Parsec |
12 | 13 | ||
@@ -62,11 +63,14 @@ parseId = do | |||
62 | "#f" -> BoolLiteral False | 63 | "#f" -> BoolLiteral False |
63 | _ -> Id atom | 64 | _ -> Id atom |
64 | 65 | ||
66 | parseComment :: Parser () | ||
67 | parseComment = char ';' >> manyTill anyChar (char '\n') >> return () | ||
68 | |||
65 | whiteSpace :: Parser () | 69 | whiteSpace :: Parser () |
66 | whiteSpace = skipMany1 $ oneOf [' ', '\n'] | 70 | whiteSpace = parseComment <|> (skipMany1 $ oneOf [' ', '\n']) |
67 | 71 | ||
68 | optionalWhiteSpace :: Parser () | 72 | optionalWhiteSpace :: Parser () |
69 | optionalWhiteSpace = skipMany $ oneOf [' ', '\n'] | 73 | optionalWhiteSpace = parseComment <|> (skipMany $ oneOf [' ', '\n']) |
70 | 74 | ||
71 | type Alias = String | 75 | type Alias = String |
72 | parseModifier :: String -> Alias -> Parser Expr | 76 | parseModifier :: String -> Alias -> Parser Expr |