CS 453 Homework Assignment #4 — AST Design and Programming
In class this past week we covered Abstract Syntax Trees and
worked with some examples. For HW4, you will be doing the following:
- Designing and implementing an AST for the PA2 (yes PA2) MeggyJava grammar.
Design this AST on your own.
- Implement a code generation function that works for Meggy.setPixel
calls and the expressions in the PA2 MeggyJava grammar. (HINT: this should
involve some copy and pasting from your PA2).
- Reflect on your design and implementation. How might you want to
add to the design or modify it for the PA3 grammar? What about the PA4 and PA5
MeggyJava grammars? For this <1/2 page paragraph, you should talk with other
people in the class and compare designs.
Groups for HW4
There should be NO groups for HW4. Resist the urge to collaborate
until you have a design and implementation for the PA2 MeggyJava
grammar AST and codegen. Prove to yourself that you can do it.
You can create a github repository for HW4
by going to the HW4 assignment in the
github classroom for cs453.
Submitting the Assignment
For this assignment, you are going to create a text file called HW4.txt
where you introduce and present your AST data structure and the
code generation function. To present your AST data structure, include the actual
Haskell code that declares that data structure "data AST = ... deriving(Show)"
in HW4.txt.
The code generation function should generate code from the AST. Therefore,
its Haskell type might be:
avrCodeGen :: AST -> String
Show the input and output for an example
Meggy.setPixel command. You will also have a paragraph that compares
your design and implementation with others in the class. Specify
who you compared your design with.
The text file should be about 2 pages. Use full sentences and work
on making the two pages easy to read.
Submit your HW4.txt file using turnin on lectura.
turnin cs453HW4 HW4.txt
Grading
The grade will be based on whether your writeup includes all requested
pieces and the readability.
Late Policy
Late assignments will be accepted up
to 24 hours past the due date for a 20%
deduction. The assignment will not be accepted past this period.
Late means anything after 11:59pm
on the day the assignment is due, including 12 midnight and 11:59pm and one second.
mstrout@cs.arizona.edu, 9/26/16