[Haskell-cafe] Lazy Parsing

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu May 28 05:41:25 EDT 2009

Henning Thielemann <schlepptop at henning-thielemann.de> wrote:

> I don't think that it is in general possible to use the same parser
> for lazy and strict parsing, just because of the handling of parser
> failure.

Polyparse demonstrates that you can mix-and-match lazy parsers with
strict parsers in the different parts of a grammar (by choosing whether
to use applicative or monadic style).  You can also switch between lazy
or strict interpretations of the applicative parts of your grammar (by
changing the import that decides which version of the parser primitives
is in scope).

> I also used polyparse for lazy parsing, but I found it unintuitive how
> to make a parser lazy.

It can certainly be tricky, and requires a certain amount of
experimentation.  I think the difficulties are mainly due to the mix of
lazy (applicative) and strict (monadic) styles in different
non-terminals.  A parser that you intend to be lazy, may turn out to be
stricter than you hope, because of the strictness of another parser that
it depends upon.


More information about the Haskell-Cafe mailing list