Reference no: EM132314035
Assignment - Jack Compiler
Project Description
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.
SVN Repository
You must create a directory in your svn repository named: <year>/<semester>/cs/assignment3. This directory must only contain the following files and directories - the web submission system will check this:
Makefile - this file is used by make to compile your submission - do not modify this file.
.cpp C++ source files - naming as specified in the component program requirements.
.h C++ include files - naming as specified in the component program requirements.
lib - this directory contains precompiled programs and components - do not modify this directory. includes - this directory contains .h files for precompiled classes - do not modify this directory. tests - this directory contains a test script and test data, you can add your own tests too.
Your programs must be written in C++ and will be tested using Jack language programs that that may or may not be syntactically correct and previously generated abstract syntax trees. Although a wide range of tests may be run, including some secret tests, marks will only be recorded for those tests that require a working parser program. Your programs will be compiled using the Makefile and precompiled components in the lib directory. Note: you will get no feedback on the secret tests, even if you ask!
Automatic Marking
The automatic marking will compile and test both of your tokenisers in exactly the same way as for the milestone submission. The difference is that marks will be recorded for all of the tests including the secret tests. Note: if your programs fail any of these secret tests you will not receive any feedback about these secret tests, even if you ask!
The marks from the automatic tests for each component program will be weighted as follows:
parser - 30%
codegen - 40%
pretty - 10%
optimiser-r - 20%
The test scripts are able to test each component program independently but, we strongly suggest that you attempt the component programs in the order above so that you get the most return on your effort.
You should gain the most significant learning benefit from completing both the
parser and codegen programs.
Nand2Tetris Projects 10 & 11: Compiler I & II
Background
Modern compilers, like those of Java and C#, are multi-tiered: the compiler's front-end translates from the high-level language to an intermediate VM language; the compiler's back-end translates further from the VM language to the native code of the host platform. In an earlier workshop we started building the back- end tier of the Jack Compiler (we called it the VM Translator); we now turn to construct the compiler's front-end. This construction will span two parts: syntax analysis and code generation.
Objective
In this project we build a Syntax Analyser that parses Jack programs according to the Jack grammar, producing an abstract syntax tree that captures the program's structure. We then have a choice, we can morph the logic that generates the abstract syntax tree into logic that generates VM code or we can write separate logic that can apply any number of transformations to our abstract syntax tree. The transformations may include pretty printing the original program, applying specific optimisations to the abstract syntax tree or generating VM code. This mirrors the alternative approaches used in the workshops.
Attachment:- Computer Systems.rar