diff options
author | Atreya Bain <[email protected]> | 2020-10-26 09:22:06 +0000 |
---|---|---|
committer | Atreya Bain <[email protected]> | 2020-10-26 09:22:06 +0000 |
commit | c850d35d2f4b392ebbf36932f4becdf95641fd94 (patch) | |
tree | bd881c217c128f2999520f304226ad2018886c69 | |
parent | 61eb6abb4eea4ef2c8f03b33976ebf723011ed56 (diff) |
Add comments into whitespace
-rw-r--r-- | src/Parser.hs | 28 |
1 files 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 ((<$>)) | |||
12 | import Text.ParserCombinators.Parsec | 12 | import Text.ParserCombinators.Parsec |
13 | 13 | ||
14 | 14 | ||
15 | parseComment :: Parser () | ||
16 | parseComment = do | ||
17 | char ';' | ||
18 | innards <- many (noneOf ['\n']) | ||
19 | return () | ||
20 | |||
21 | 15 | ||
22 | -- backslash double quote escapes a quote inside strings | 16 | -- backslash double quote escapes a quote inside strings |
23 | quotedChar = noneOf ['\"'] <|> try (string "\\\"" >> return '"') | 17 | quotedChar = noneOf ['\"'] <|> try (string "\\\"" >> return '"') |
@@ -71,15 +65,25 @@ parseId = do | |||
71 | "#f" -> BoolLiteral False | 65 | "#f" -> BoolLiteral False |
72 | _ -> Id atom | 66 | _ -> Id atom |
73 | 67 | ||
68 | -- atmosphere | ||
69 | parseComment :: Parser () | ||
70 | parseComment = do | ||
71 | char ';' | ||
72 | skipMany (noneOf ['\n']) | ||
73 | -- skipMany $ char '\n' | ||
74 | return () | ||
75 | |||
76 | |||
74 | whiteSpace :: Parser () | 77 | whiteSpace :: Parser () |
75 | whiteSpace = | 78 | whiteSpace = do |
76 | skipMany1 ( oneOf [' ', '\n']) | 79 | optionMaybe parseComment |
77 | <|> parseComment | 80 | skipMany1 ( oneOf [' ', '\n']) <?> "whitespace or newline" |
81 | return () | ||
78 | 82 | ||
79 | optionalWhiteSpace :: Parser () | 83 | optionalWhiteSpace :: Parser () |
80 | optionalWhiteSpace = | 84 | optionalWhiteSpace = do |
81 | skipMany ( oneOf [' ', '\n']) | 85 | optionMaybe $ whiteSpace |
82 | <|> parseComment | 86 | return () |
83 | 87 | ||
84 | type Alias = String | 88 | type Alias = String |
85 | parseModifier :: String -> Alias -> Parser Expr | 89 | parseModifier :: String -> Alias -> Parser Expr |