[Haskell-beginners] Simple lookahead with Parsec

Isaac Dupree ml at isaac.cedarswampstudios.org
Fri Mar 19 15:20:23 EDT 2010

On 03/19/10 14:24, Derek Thurn wrote:
> Ah, I see. The problem is that the primitiveType parser succeeds. Is
> there then no generic way to use lookahead in Parsec to make choices
> of this nature? I appreciate that it might be possible to refactor my
> grammar to never require examining the next token to make a parsing
> decision about the current token, but I've already got an LALR(1)
> grammar that I'm pretty happy with...

Well, you could learn to make something in Parsec that matches your 
grammar, or you could use a LALR(1) parsing library.  Like "Happy". 
(Well, Happy is actually a sort of preprocessor for Haskell. But still, 
doesn't using the most-fitting tool for the job seem to make sense?)


More information about the Beginners mailing list