Assignment 3 – Jack Compiler
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-e^ – this copies an abstract syntax tree and evaluates expressions where possible.
lint* – this takes an abstract syntax tree and annotates it with warning and / or error
^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 (https://myuni.adelaide.edu.au/courses/64316/pages/startup-files-
1. If required, checkout a working copy of the assignment3 directory from your svn repository.
2. Change directory to the working copy of the assignment3 directory.
3. 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.
4. Run the following command to place the assignment’s startup files in the correct locations, this
will automatically add them to svn:
% make install
5. Commit the changes to your svn repository:
% svn commit -m “Assignment 3 Startup Files”
6. Goto the Web Submission System and make a submission to the “Assignment 3 – Submit
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:
*.cpp C++ 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
tests – this directory contains a test script and test data.
parser – a script to run your parser program.
codegen – a script to run your codegen program.
pretty – a script to run your pretty program.
optimiser-e – a script to run your optimiser-e program.
lint – a script to run your lint program.
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.