Mark P Jones <[EMAIL PROTECTED]> writes:
> I used to get almost exactly these kinds of problems when I was first
> working on Gofer, and used bison rather than yacc to build the parser.
> I believe the problems are caused by incompatabilities in the treatment
> of error recovery, but I never managed to track these down to any
> formally stated differences in user documentation. Error recovery is
> important at the point you have found because it is needed to force the
> layout rule to be invoked (as you have verified by changing the layout
> by hand). The Hugs parser expects error recovery to work in a
> particular way, and if that doesn't happen, then the parser won't
> work. (BTW: Since my first encounter with this problem, I've come
> across versions of bison that produce working parsers, and versions of
> yacc that don't. And I've never found a hint in the user documentation
> for any of these parser generators to suggest why the differences might
> occur.)
I've recently added error recovery to Happy in order to parse the
Haskell layout rule, and came across exactly these problems. The
semantics of error recovery in a shift-reduce parser doesn't seem to
be documented anywhere, so I had to experiment a little to get it
right.
The current version of bison has at least one bug in this area: we
recently tracked down a mis-parse in the GHC parser to a bug in
bison's error recovery. Of course, depending on the required
semantics, it could be a feature :-)
If anyone's interested in the intricacies of shift-reduce error
recovery, feel free to drop me a note!
Cheers,
Simon
--
Simon Marlow [EMAIL PROTECTED]
University of Glasgow http://www.dcs.gla.ac.uk/~simonm/
finger for PGP public key