[Haskell-cafe] Newbie: Is it possible to catch _|_ ?
matthew at alledora.co.uk
Wed Apr 7 16:41:36 EDT 2004
Isn't Happy  a bottom-up parser generator in the style of yacc?
As for parsing yacc's input files, if you can come up with an EBNF
grammar for it that avoids some of the nasty recursion possibilities 
then I can't see why you couldn't parse it with Parsec or some other
parsing library. Or even with a parser written using Happy.
Parsec's not that bad really, but the HuttonMeijerWallace one is easier
if you start off with those and move to Parsec if you need a more
powerful solution. But I may be biased as I'm a former student of Graham
With all the choices available though there's not much point writing
your own unless you've got very unusual requirements, something new to
bring to the table, or you like the challenge.
So I would definitely recommend HuttonMeijerWallace or Parsec if you're
wanting to parse something. It's possible Happy-generated parsers run
faster, but I don't really know and I was quite content with Parsec's
speed when I used it in my final-year project. Not that it was parsing
anything particularly huge at the time.
 the proper terms for which I can't remember, but I seem to recall
that left recusion is one of the nasty ones
Graham Klyne wrote:
> I'm not familiar with yacc, but I understand that it's a bottom-up
> parser generator. I've not come across any bottom-up parser generators
> written in Haskell.
> I have seen (at least) three examples of top-down parser generators
> coded in Haskell:
> (1) in Simon Thompson's book, the Craft of Functional Programming. I
> have done an implementation based on these ideas , which I have since
> discarded in favour of Parsec...
> (2) the Parsec parser library , which is a very full-functioned and
> easy-to-use library, but which might be not-so-easy for a Haskell
> newcomer to figure out its internal workings because it is heavily based
> on Monads.
> (3) the HuttonMeijerWallace parser combinator library , which is also
> based on a Monad but, being less complex, is easier to follow its
>  http://www.cs.uu.nl/~daan/parsec.html
> (also in the Haskell hierarchical libraries, under 'text'.
>  API Documentation:
> Source in CVS:
> Being part of HaXml:
>  http://www.ninebynine.org/Software/HaskellUtils/Withdrawn/Parse.hs
> (And related code in same directory. This was just about the first real
> program I write in Haskell, so don't look to this for an example of how
> one *should* program using Haskell!)
More information about the Haskell-Cafe