@@ -94,23 +94,28 @@ parseString = parseQuoted <|> unqualName
9494unqualName :: Parser Text
9595unqualName = takeWhile1 (not . (\ c -> isSpace c || c == ' ,' ))
9696
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-
11197-- | Comma or space separated list, with optional new lines.
11298parseList :: 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
114119
115120pathMain :: Indent -> [Text ] -> Text -> [Text ] -> [Text ] -> Parser [Text ]
116121pathMain i p m o a =
@@ -153,7 +158,7 @@ skipBlockLine :: Indent -> Parser ()
153158skipBlockLine i = (indent i >> skipToNextLine) <|> emptyOrComLine
154159
155160emptyOrComLine :: Parser ()
156- emptyOrComLine = skipMany tabOrSpace >> endOfLine <|> comment
161+ emptyOrComLine = ( skipMany tabOrSpace >> endOfLine) <|> comment
157162
158163tabOrSpace :: Parser Char
159164tabOrSpace = char ' ' <|> char ' \t '
@@ -171,9 +176,9 @@ field i f p =
171176 do
172177 i' <- indent i
173178 _ <- asciiCI f
174- skipSpace
179+ skipMany tabOrSpace
175180 _ <- char ' :'
176- skipSpace
181+ skipMany tabOrSpace
177182 p' <- p $ i' + 1
178183 skipToNextLine
179184 pure p'
0 commit comments