[Haskell-cafe] Lazy Parsing
schlepptop at henning-thielemann.de
Wed May 27 11:23:47 EDT 2009
Günther Schmidt schrieb:
> Hi all,
> is it possible to do lazy parsing with Parsec? I understand that one can
> do that with polyparse, don't know about uulib, but I happen to be
> already somewhat familiar with Parsec, so before I do switch to
> polyparse I rather make sure I actually have to.
> The files it has to parse is anywhere from 500 MB to 5 GB.
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.
If parser failure is denoted by a Left constructor in (Either Reason
Result) then the whole parsing process must be finished, before the
parser knows whether the answer is Left or Right.
I also used polyparse for lazy parsing, but I found it unintuitive how
to make a parser lazy. I tried to do better in tagchup, where I make
explicit in the type, whether a parser can fail or not. In the first
case in cannot be lazy, in the second case it can. I also did lazy
parsing in 'midi' package and in 'spreadsheet'. I liked to factor out a
lazy parser library from them, but I failed to unify all these
applications. At least I have factored out handling of lazy failure (aka
asnychronous exceptions) in explicit-exception package.
Btw. a good place to discuss such issues is our local Haskell meeting
that takes place on 2009-06-12:
More information about the Haskell-Cafe