[Haskell-cafe] Re: Parsec question (new user): unexpected end of
input
Christian Maeder
Christian.Maeder at dfki.de
Wed Sep 29 03:54:55 EDT 2010
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.
Cheers Christian
>> eof
>> return "Parse complete."
>>
>> tagOrContent = aTag <|> someContent <?> "tagOrContent"
>>
>> aTag = do
>> tagBegin
>> xs <- many (noneOf [tagEndChar])
>> 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 = '>'
>
> --------
More information about the Haskell-Cafe
mailing list