スタック・オーバーフローに参加する
681万人以上のプログラマーが集まるスタック・オーバーフローに参加しませんか?
簡単な登録後、すぐにご利用いただけます。
登録

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.

share|improve this question
up vote 8 down vote accepted

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.

share|improve this answer
    
Note that the link to simple.x points to an old version (which does not compile), the current version is on github: github.com/simonmar/alex/blob/master/tests/simple.x – user905686 Feb 4 at 15:53

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).

share|improve this answer

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

share|improve this answer

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/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.