Overriding "Internal Happy Error" - notHappyAtAll
Asked Answered
H

1

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.

Hydrometallurgy answered 14/12, 2011 at 13:31 Comment(5)
Maybe the happy docs help? Disclaimer: maybe they don't.Batsheva
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.Unpractical
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.Unpractical
Yep I've defined a parseError - this isn't being caught by my parse error for some reason, and instead calling notHappyAtAll :/Hydrometallurgy
This question must look really odd to non-Haskellers ;) notHappyAtAll is a brilliant name for a function.Barger
A
1

This problem appears to have been fixed in Happy 1.18.7.

Amosamount answered 28/3, 2012 at 15:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.