CS 453 Programming Assignment #3 — MeggyJava CheckButton Compiler (Control Flow, Parser Generators, and ASTs)

In this assignment you will be writing a program that parses, type checkes, and generates code for the PA3 subset of the MeggyJava language that includes the detection of button presses (Meggy.checkButton), the use of the delay function (Meggy.delay), the function for reading the screen pixel values (Meggy.getPixel), the while statement, the if statement, byte casts, plus, minus, and times, and boolean expressions. Notice the dangling else syntax, and the unary minus syntax.

Java, and therefore MeggyJava allows int, byte mixed type expressions for addition, subtraction, comparison, and negation. This is relevant for type checking as well as code generation. Note that the MeggyJava grammer allows only byte type operands to be used by the multiplication operator.

The Assignment

You will

Example ASTs

The reference compiler creates an AST and has a function that converts the AST to a dot file.

Example ASTs of some test cases are here:

The reference compiler AST design is no great shakes. It can definitely be improved upon, and I look forward to seeing better designs coming from the class.

Groups for PA3

Groups can be of size 1 to 5 for PA3.

You can create a github repository for PA3 by going to the PA3 assignment in the github classroom for cs453.

Grading Details

Compiling and using your compiler will proceed as follows:
    stack build MJCPA3
    stack exec MJCPA3 TestCase.java
    java -jar MJSIM.jar -b -f TestCase.java.s > t1
    
    // Executing the Java-only version with the meggy/ package.
    javac TestCase.java
    java TestCase > t2
    diff t1 t2
   

The input files can be any PA3 MeggyJava program. The InputFile.java.s file must be such that we can run it through the AVR simulator, MJSIM.jar.

If you need additional Haskell libraries, you need to post a message on Piazza indicating you would like to use the external library. We will reply with a .cabal file that will be used to grade ALL projects. This means everyone will then be able to use that same external library.

We highly recommend you use the regression script regress.sh. Read the comments in the file header to see how it works. Create multiple test cases, put them in the WorkingTestCases/ subdirectory and test your mjc compiler against the Java-only output.

For this assignment, there will be no lexer errors, but there will be examples with type errors. Your compiler should catch the first type error and print out a reasonable message. We will be manually comparing your messages to those generated by by the Java compiler, javac. They do not need to be identical, but you do need to catch the errors. The MeggyJava compiler requires the additional error that integer multiplication is not allowed.

You will need to submit a video of your MeggyJr with a MeggyJava program that only demonstrates the features in the PA2 and PA3 grammars. The picture should be named demoPA3.something, where something is .mov or whatever video format you used for PA1. You can talk during the demo.

Submitting the Assignment

Grading

PA3 Peer Review Criteria

The following will be the recommended peer evaluation criteria: Additionally the PA3 peer review will include rating the group's PA3 demo.

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. If your assignment is late, it will not be included in the peer review process.


mstrout@cs.colostate.edu, 3/2/15
mstrout@cs.colostate.edu, 3/23/15, updated Grading percentages to include type errors
kushagra.tiwary@colostate.edu, 4/3/15, added note about multiplication operator
mstrout@cs.arizona.edu, 9/26/16, modified for turnin procedure at UA
mstrout@cs.arizona.edu, 10/8/16, included the peer evaluation criteria