Happy and Macros (was Re: ANNOUNCE: Happy 1.10 released)
Manuel M. T. Chakravarty
Fri, 11 May 2001 17:09:44 +1000
"Simon Marlow" <email@example.com> wrote,
> S. Alexander Jacobson writes:
> > I am not a parsing expert, but given the recent discussion on
> > macros, I
> > have to ask: why use happy rather than monadic parsing?
> > Monadic parsing
> > allows you to avoid a whole additional language/compilation
> > step and work
> > in Hugs (where you don't have a makefile). What does Happy
> > buy you here?
> It buys you (a) speed, (b) confidence that your grammar is
> non-ambiguous, and (c) familiar BNF notation. On the down side, as you
> point out, you lose Haskell's abstraction facilities.
> I'd be willing to sacrifice (c) in order to write parsers in Haskell,
> but I don't think there's a combinator library that matches Happy in
> terms of speed (disclaimer: I haven't exhaustively tested them all, but
> given the tricks Happy does I'd be surprised). AFAIK none of the
> combinator libraries gives you (b).
I don't think, the point is the test for non-ambiguity. At
least, Doitse's and my self-optimising parser combinator
library will detect that a grammar is ambigious when you
parse a sentence involving the ambiguous productions. So,
you can check that by parsing a file involving all grammar
constructs of the language.
The point is much more the level of help that you get if
your grammar happens to be ambiguous. My combinators at the
moment just tell you that the grammar is ambiguous, but
provide no help as to where and why. I think, this is
similar for Doitse's combinators. Happy helps you much more
in this situation.