
Am 29.09.2010 09:54, schrieb Christian Maeder:
Am 29.09.2010 05:35, schrieb Peter Schmitz: [...]
Error parsing file: "...\sampleTaggedContent.txt" (line 4, column 1): unexpected end of input expecting "<"
The input was: [...]
-- Parsers: taggedContent = do optionalWhiteSpace aTag many tagOrContent aTag
"many tagOrContent" will consume all tags, so that no tag for the following "aTag" will be left.
if you want to match a final tag, you could try: manyTill tagOrContent (try (aTag >> eof))
Cheers Christian
eof return "Parse complete."
tagOrContent = aTag <|> someContent > "tagOrContent"
aTag = do tagBegin xs <- many (noneOf [tagEndChar])
this also looks like "manyTill anyChar tagEnd" C.
tagEnd optionalWhiteSpace return ()
someContent = do manyTill anyChar tagBegin return ()
optionalWhiteSpace = spaces -- i.e., any of " \v\f\t\r\n" tagBegin = char tagBeginChar tagEnd = char tagEndChar
-- Etc: tagBeginChar = '<' tagEndChar = '>'
--------