Are there any tutorials on building a simple interpreter using Alex + Happy?

 ̄綄美尐妖づ 提交于 2019-12-03 04:30:39

问题


I'm working on a school project where I have to build an interpreter for a simple language using Alex + Happy in Haskell.

After looking through the documentation I understand most of it, but would like to see a full blown example on using the tools.


回答1:


Not on building interpreters, but on building lexers and parsers, yes. See the example for a lexical analyzer in Alex, here, combined with an intro to Happy here. I found the haskell.x and haskell.y files distributed in the darcs repos for Alex and Happy useful. You can find those here and here.




回答2:


I wrote a series of posts at bjbell.wordpress.com on using Alex+Happy+LLVM to write a compiler for a simple Java like language.

The source-code is on GitHub at https://github.com/bjwbell/NewL-Compiler (I haven't touched it in a couple years).




回答3:


Haddock has an Alex/Happy parser for documentation, the sources are here in the files Lex.x and Parse.y.




回答4:


I wrote a post about solving a problem that you described: http://eax.me/simple-interpreter/ (in Russian). Source code is here: https://bitbucket.org/afiskon/hs-interpreter/



来源:https://stackoverflow.com/questions/3113197/are-there-any-tutorials-on-building-a-simple-interpreter-using-alex-happy

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