CSc 453 Recitation — 15 minute compiler in Haskell
This recitation has been adapted from a recitation where
we used to create a compiler in 15 minutes by using code generation
tools. However, since the lexer and parser for the example
compiler are now written by hand, the "15 minutes" does not
hold anymore. Therefore, 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:
- Download Main15min.hs,
Lexer15min.hs,
infile,
and
README.
- Build and run the compiler on the example infile.
- Play with the triangle so that it becomes a hat for Mickey
by editing Main15min.hs.
- Modify the grammar of the little language so that the
Triangle can be parameterized however you would like.
- Add a "Rectangle" statement to the grammar that results in a rectangle being drawn in
postscript. You will have to lookup how rectangles are represented in postscript.
Rectangle can be parameterized however you would like.
- (Optional challenge problem) Note the repetition of code in parseProgram and parseStmts.
Can you figure out a more succinct way to write this in Haskell?
mstrout@cs.arizona.edu
.... September 22, 2016