The parseProperties
parser is executed many times in your example until
eof
is encountered. The problem is that parseProperties
does not consume
the trailing whitespace in your example, so after parsing the last tag, the
remaining string is "\n\n"
, which will not trigger your termination
condition, since it is not the end of input. This causes the parseProperties
to be attempted again, which consumes the whitespace but fails when trying to
eat a '>'
.
Try modifying your parseTest
to the following
test = "\n> <CdId>\n1\n\n> <Mol Weight>\n270.2369\n\n> <Formula>\nC15H10O5\n\n> <LOG_ER_RBA>\n-0.36\n\n> <ACTIVITY>\n1\n\n"
parseTest (manyTill parseProperties $ try (skipMany newline >> eof)) test
This trys stripping the preceding whitespace before checking if it is at an end of input.