@@ -94,23 +94,28 @@ parseString = parseQuoted <|> unqualName
94
94
unqualName :: Parser Text
95
95
unqualName = takeWhile1 (not . (\ c -> isSpace c || c == ' ,' ))
96
96
97
- -- | Skip spaces and if end of line is reached, skip it as well and require that
98
- -- next one starts with indent.
99
- --
100
- -- Used for parsing fields.
101
- optSkipToNextLine :: Indent -> Parser ()
102
- optSkipToNextLine i = do
103
- skipMany $ satisfy (\ c -> isSpace c && not (isEndOfLine c))
104
- skipMany $ skipSpace >> " --" >> takeTill isEndOfLine
105
- peekChar >>= \ case
106
- Just c
107
- | isEndOfLine c ->
108
- endOfLine >> indent i $> ()
109
- _ -> pure ()
110
-
111
97
-- | Comma or space separated list, with optional new lines.
112
98
parseList :: Indent -> Parser [Text ]
113
- parseList i = sepBy parseString (optSkipToNextLine i >> skipMany (char ' ,' ) >> optSkipToNextLine i) <|> pure []
99
+ parseList i = many (nl <|> sl)
100
+ where
101
+ sep = skipMany (char ' ,' <|> tabOrSpace)
102
+ com = skipMany tabOrSpace >> " --" >> skipWhile (not . isEndOfLine)
103
+ sl = do
104
+ sep
105
+ x <- parseString
106
+ sep
107
+ skipMany com
108
+ pure x
109
+
110
+ nl = do
111
+ skipMany emptyOrComLine <|> endOfLine
112
+ _ <- indent i
113
+ sep
114
+ skipMany com
115
+ x <- parseString
116
+ sep
117
+ skipMany com
118
+ pure x
114
119
115
120
pathMain :: Indent -> [Text ] -> Text -> [Text ] -> [Text ] -> Parser [Text ]
116
121
pathMain i p m o a =
@@ -153,7 +158,7 @@ skipBlockLine :: Indent -> Parser ()
153
158
skipBlockLine i = (indent i >> skipToNextLine) <|> emptyOrComLine
154
159
155
160
emptyOrComLine :: Parser ()
156
- emptyOrComLine = skipMany tabOrSpace >> endOfLine <|> comment
161
+ emptyOrComLine = ( skipMany tabOrSpace >> endOfLine) <|> comment
157
162
158
163
tabOrSpace :: Parser Char
159
164
tabOrSpace = char ' ' <|> char ' \t '
@@ -171,9 +176,9 @@ field i f p =
171
176
do
172
177
i' <- indent i
173
178
_ <- asciiCI f
174
- skipSpace
179
+ skipMany tabOrSpace
175
180
_ <- char ' :'
176
- skipSpace
181
+ skipMany tabOrSpace
177
182
p' <- p $ i' + 1
178
183
skipToNextLine
179
184
pure p'
0 commit comments