11

I am using Happy to generate a parser.

I have found that when I give it tokens which match part of the grammar at a lower level than the top level (such as giving it an expression on it's own, that isn't part of a statement), I get an "Internal Happy Error" rather than a parse error.

Is there a way to override notHappyAtAll so that I can print a better error message than "Internal Happy Error"? Obviously other than changing the auto-generated parser file as I'd have to do it every time I updated the grammar.

Jack
  • 2,153
  • 5
  • 28
  • 43
  • 1
    Maybe [the happy docs](http://haskell.org/happy/doc/html/sec-monads.html#sec-exception) help? Disclaimer: maybe they don't. – Daniel Fischer Dec 14 '11 at 14:21
  • If you want to match "fragments" rather than always the top-level of your grammar, you'll need multiple start symbols - see section 2.7 of the Happy manual. – stephen tetley Dec 14 '11 at 14:59
  • Have you defined a error directive at the top of your grammar? This should be of the form `%error { parseError }` - `parseError` is some user defined function. See Chapter2 of the manual. – stephen tetley Dec 14 '11 at 16:38
  • Yep I've defined a parseError - this isn't being caught by my parse error for some reason, and instead calling `notHappyAtAll` :/ – Jack Dec 14 '11 at 17:07
  • 6
    This question must look really odd to non-Haskellers ;) `notHappyAtAll` is a brilliant name for a function. – Tikhon Jelvis Dec 14 '11 at 22:46

1 Answers1

1

This problem appears to have been fixed in Happy 1.18.7.