[Haskell-cafe] Need help with learning Parsec
C K Kashyap
ckkashyap at gmail.com
Mon Jul 23 12:09:00 CEST 2012
Thank you so much Christian for your feedback ... I shall incorporate them.
On Mon, Jul 23, 2012 at 3:17 PM, Christian Maeder
<Christian.Maeder at dfki.de>wrote:
> Am 22.07.2012 17:21, schrieb C K Kashyap:
> I've updated the parser here -
>> The whole thing is less than 100 lines and it can handle comments as well.
> This code is still not nice: Duplicate code in openTag and
> The "toplevel-try" in
> try withoutExplictCloseTag <|> withExplicitCloseTag
> should be avoided by factoring out the common prefix.
> Again, I would avoid notFollowedBy by using many1.
> tag <- try(char '<' >> many1 (letter <|> digit))
> In quotedChar you do not only want to escape the quote but at least the
> backslash, too. You could allow to escape any character by a backslash
> quotedChar c =
> try (char '\\' >> anyChar) <|> noneOf [c, '\\']
> Writing a separate parser stripLeadingSpaces is overkill. Just use
> "spaces >> parseXML"
> (or apply "dropWhile isSpace" to the input string)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe