[Haskell-cafe] Wanted: composoable parsers from haskell-src-exts

Josef Svenningsson josef.svenningsson at gmail.com
Fri Mar 18 18:25:24 CET 2011


On Thu, Mar 17, 2011 at 10:58 PM, Niklas Broberg
<niklas.broberg at gmail.com>wrote:

> > >  I already export a partial parser for top-of-file pragmas,
> >
> > I see. What I don't see is how such a parser would return the "rest of
> input".
>
> Hmm. I see. And I see that you are correct in not seeing it, since it
> appears it cannot be done with Happy, which I believed. It would then be
> down to the parser/lexer to pass on unconsumed input, which seems a daunting
> and disruptive task, seeing how the lexer typically would tokenize some
> input in advance before the parser discovers that it cannot consume what has
> been lexed... Hmm.
>

I think this is actually doable, although not necessarily easy, using a
technique due to Oleg. He has used delimited continuations to take ordinary
parsers and make them incremental. Dan Doel has experimented with applying
the technique to Parsec parsers with some success. I think choosing the
right parser monad in Happy can make this work.

Reference to Oleg's technique:
http://okmij.org/ftp/continuations/differentiating-parsers.html

Cheers,

Josef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110318/a0f51db3/attachment.htm>


More information about the Haskell-Cafe mailing list