In this assignment you will complete a variation of projects 10 and 11 in the nand2tetris course, reworked descriptions of Nand2Tetris Projects 10 and 11 are shown below. In particular, you will write the following programs that are used to implement different components of an optimising Jack compiler that compiles a Jack class into Hack Virtual Machine (VM) code:
- parser– this parses a Jack program and constructs an abstract syntax tree.
- codegen– this takes an abstract syntax tree and outputs equivalent VM code.
- pretty– this takes an abstract syntax tree and produces a carefully formatted Jack program.
- optimiser-r^– this copies an abstract syntax tree and removes redundant code where possible.
- optimiser-e*– this copies an abstract syntax tree and evaluates expressions where possible.
- ^Only for students enrolled in the undergraduate offering, COMP SCI 2000.
- *Only for students enrolled in the postgraduate offering, COMP SCI 7081.
Note: this assignment assumes that you have already created directories for every assignment, workshop, project and exam in your svn repository, as described on the Startup Files for Workshops and Assignments page.
- If required, checkout a working copy of the assignment3 directory from your svn repository.
- Change directory to the working copy of the assignment3 directory.
- Copy the latest startup files from the “View Feedback” tab of the “Assignment 3 – Submit Here” assignment into the updates sub-directory. Do not unzip the file.
- Run the following command to place the assignment’s startup files in the correct locations, this will automatically add them to svn and then commit them to your repository:
% make install
- Goto the Web Submission System and make a submission to the “Assignment 3 – Submit Here” assignment.
Assignment 3 Files and Directories
In addition to the generic Makefile and updates sub-directory, the assignment3 directory should now contain the following files and directories:
- *.cppC++ source files, you must edit these files to complete the assignment.
- includes– this directory contains .h files for precompiled classes.
- lib– this directory contains precompiled programs and components.
- originals– this directory contains the original versions of the *.cpp files you are required to edit.
- tests– this directory contains a test script and test data.
- parser– a script to run your parser
- codegen– a script to run your codegen
- pretty– a script to run your pretty
- optimiser-r– a script to run your optimiser-r
- optimiser-e– a script to run your optimiser-e
Note: you need to edit the *.cpp files to complete this assignment. All the other files are automatically regenerated every time you run make, they must not be changed or added to svn.
Note: if a newer version of the startup files is made available, it must be placed in the updates sub-directory and added to svn. The next time make is run, all of the files will be updated except for the *.cpp files.