[Haskell-cafe] Re: Parsec question

Toby Hutton toby.hutton at gmail.com
Tue Dec 23 18:26:09 EST 2008


On Wed, Dec 24, 2008 at 9:22 AM, Erik de Castro Lopo
<mle+cl at mega-nerd.com> wrote:
>
> My next problem is matching things like:
>
>   identifier  ('.' identifier)*   ('.' '*')?
>
> I've had a look at lookAhead from Text.ParserCombinators.Parsec.Combinator
> but I can't get it to work.

* is analogous to the 'many' combinator, and ? can be implemented with
the 'option' combinator.  Parsec is all about composing bigger parsers
out of smaller ones using combinators like these.

One of the tricks I found early on is to understand where to use 'try'
(since by default input is consumed even if a parser fails) but apart
from that just read Daan's page, even though it's out of date, and
look at how all these cool combinators work.

http://legacy.cs.uu.nl/daan/download/parsec/parsec.html


More information about the Haskell-Cafe mailing list