[Haskell-cafe] Parsers (Parsec and Iteratee-based Parsers)

John Lato jwlato at gmail.com
Mon Jan 11 17:48:55 EST 2010


2010/1/11 Jason Dagit <dagit at codersbase.com>:
>
>
> 2010/1/11 Günther Schmidt <gue.schmidt at web.de>
>>
>> Hi,
>>
>> are there any examples how to build parsers using the library in Oleg's
>> iteratee package?
>>
>> I've been using parsec for almost all my parsing needs, in fact it was
>> parsec that got me started with Haskell.
>
> I think you should be in contact with John Lato.  Last time we had
> correspondence he mentioned a hybrid between iteratees and parsec.
>

I don't know if I'd call it a hybrid, however there is a way to embed
Parsec parsers (v.3 only) in iteratee.  The necessary code is
available at:

http://inmachina.net/~jwlato/haskell/ParsecIteratee.hs

It's intended to be used for embedding relatively small parsers in
iteratees.  It does concatenate chunks, so if it looks too far into
the stream it can be inefficient.  Chunks of up to 2000 characters
shouldn't require more than 1 concat (depending on what other
functions you're using).

This code is available as Public Domain.

Thanks to Erik de Castro Lopo for suggesting integrating iteratee and
parsec in some manner.  It's still pretty new, so suggestions are
welcome.

If you want to build parsers directly with iteratee, there currently
aren't any published tutorials although I can provide some working
code if you like.  The interface is much lower-level than Parsec.

John


More information about the Haskell-Cafe mailing list