CS 453 Programming Assignment #3 — MeggyJava for Pictures
Due Wednesday March 2nd (by 11:59pm)
This assignment is to be done with your CS 453 programming partner.
In this assignment you will be writing a program that parses the
PA3 subset of the MeggyJava language
that enables any number of
pixels to be set with Meggy.setPixel() and can include constant expressions
using addition, subtract, multiplication, and byte casts as
parameters to the Meggy.setPixel() function calls.
- build a lexer that can handle tokens for the PA3 MeggyJava and both kinds of comments
- build the parser with JavaCUP,
- perform syntax-directed evaluation of constant integer and byte expressions,
- perform syntax directed code generation to AVR assembly code for
- and set up a regression testing framework.
You should create a jar file, MJPA3.jar, that can be executed as follows:
java -jar MJPA3_groupname.jar InputFile.java
The input files can be any PA3 MeggyJava program. The PA3Picture.java example
you wrote for PA2 is a possible test case for MJPA3_groupname.jar.
The output file named InputFile.java.s
should be an AVR assembly program that using
the provided build process will run on the MeggyJr device.
Additionally, the InputFile.java.s file must be such that we can run
it through the AVR simulator MJSIM.jar. See
the Meggy Sim instructions for usage notes.
The set of instructions you will need include those already provided in the
avrH.rtl.s and avrF.rtl.s
files and the following:
# Examples of each statement type are provided.
# Register numbers, constant values, and labels can change.
For more details about the instructions see
the 08-MeggyJrSimple-n-AVR.txt notes.
Notice that avrF.rtl.s already has an infinite
loop at the end of main so that the program will always remain
running on the Meggy Jr device even if there is no while loop in
the MeggyJava program.
For this assignment, no error handling is necessary. In other words,
you can assume the input is correct.
Create the following directory structure and organize the provided
as shown. The java_cup subdirectory is needed for the way
we are building the MJPA3.jar file in the Makefile. You can
create a java_cup subdirectory
by doing a "jar xf java-cup-11a-runtime.jar" command.
For the mj.lex and mj.cup files, start with the 15min.lex and
15min.cup examples and then attend recitation to hear about
some modifications that are necessary if you want to create the
lexer from a driver other than the parser.
The MJPA3Driver.java will be provided in recitation.
The Makefile will create a .jar file
provided you use the suggested directory structure. You can use any directory
structure and any build process
as long as your MJPA3_groupname.jar file works as required.
Remember that we suggest you
start from example .lex and .cup files that already work. We also recommend
that you start out with a small driver that builds into a jar file and does something right away. Incrementally add functionality and test along the way.
Submitting the Assignment
Make sure you test your implementation thoroughly.
Only turnin one assignment per group.
- Create the MJPA3_groupname.jar file that contains all the source code, the .class files, your .cup and .lex files, a README file, and a subversion.txt file. We should be able to use the jar file to run your PA3 MeggyJava compiler.
You do NOT have to include MJSIM.jar or the meggy package into your jar file.
You will probably have to add filenames to the provided Makefile in the command that creates the jar file.
Submit assignment using checkin utility.
~cs453/bin/checkin PA3 MJPA3_groupname.jar
Sanity Check (procedure TA will use to grade your assignment):
java -jar MJPA3_groupname.jar TestCase.java
java -jar MJSIM.jar TestCase.java.s > t1
java TestCase > t2
diff t1 t2
jar xf MJPA3_groupname.jar // to get the README and other files like subversion.txt
// Will read README and other files.
Late assignments will be accepted up to 48 hours past the due date for a 10%
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.
.... March 2, 2011