[Haskell-cafe] parsing machine-generated natural text
u.stenzel at web.de
Sun May 21 13:06:56 EDT 2006
Jason Dagit wrote:
> > reserved "units." <|> reserved "unit."
> I always struggle with when I need to use 'try' with parsec.
> My understanding is that if 'unit.' appears in the input the first
> parser will parse up to the '.' and then fail and consume the input up
> to that point, leaving the alternative with only the period as input
> so it will also fail.
> So I'm wondering if someone could explain to me what is wrong with my
> understanding of parsec
Nothing at all. 'reserved' actually contains the necessary 'try', a
'notFollowedBy' in order not to swallow parts of longer identifiers and
a useful error message. I tend to forget 'try', too, or add it in odd
places. Actually, if ReadP hat better error reporting, I'd recommend
that over Parsec.
Time is an illusion. Lunchtime doubly so. -- Douglas Adams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060521/6081e47b/attachment.bin
More information about the Haskell-Cafe