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

Jeff Zaroyko jeffzaroyko at gmail.com
Mon Jan 11 22:46:07 EST 2010

2010/1/12 Günther Schmidt <gue.schmidt at web.de>:
> Hi John,
> thanks for responding. As I said I've been using Parsec quite a lot, but
> wonder if there is a different approach possible/feasible to parsing. Parsec
> (2x) isn't an "online" parser, ie, it doesn't produce a result before the
> whole parse is completed.

This appears to be a common source of confusion.

You can produce a result by not trying to parse the entire input in
one go, instead parse as much as you want to consume, then return the
rest of the input with the tokens that you have collected.  For
example, in Parsec 2 a regular approach I use is something like:

get1 = do token <- parse1token
          remaining <- getInput
          return (remaining,token)


More information about the Haskell-Cafe mailing list