How to get nice syntax error messages with Happy?

£可爱£侵袭症+ 提交于 2019-12-04 04:18:53

问题


I am currently playing with the happy parser generator.

Other parser generators can give nice messages like "unexpected endline, expected 'then'". With happy I just get the current Tokens and the position of the error.

Can you give me an example of how to get error messages like above?


回答1:


There is a Happy feature that I have authored for this purpose.

See my blog post: Toward better GHC syntax errors

It was merged in this pull request RFC: On parse error - show the next possible tokens.




回答2:


Generally, from what I've heard, if you want nice parser errors, use Parsec instead of Happy.



来源:https://stackoverflow.com/questions/5430700/how-to-get-nice-syntax-error-messages-with-happy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!