CS 453 Recitation — 15 minute compiler in Haskell using Happy

This recitation has been adapted from a recitation where we used to create a compiler in 15 minutes by using code generation tools like Bison. The example now uses Happy to do parser generation for Haskell. You will be downloading the completed lexer and parser for the 15 minute compiler example and playing around with it in various ways.

For this recitation, do the following:

  1. Download Main15min.hs, Parser15min.y, Lexer15min.hs, infile, and README.
  2. Build and run the compiler on the example infile. First look in Parser15min.y to see how to build Parser15min.hs.
  3. Check the build instructions with the following command:
    head Main15min.hs
  4. Skim some of the documentation at the Happy website.
  5. Look at the grammar in the Parser15min.y file. Modify the $2 in the circle statement to $1, recreate the parser with happy, recompile, and see how the output changes.
  6. Create the parser with the following command:
    happy Parser15min.y -i -a -d
    Now rebuild and rerun everything and observe what happens.
  7. (Optional) Modify the grammar of the little language so that the Triangle can be parameterized however you would like.

mstrout@cs.colostate.edu .... March 5, 2015