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-e* – this copies an abstract syntax tree and evaluates expressions where possible 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 edit.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-r – a script to run your optimiser-r program.(don’t touch this one)optimiser-e – a script to run your optimiser-e 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. 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. Your programs must be written in C++ and they will be compiled using the Makefile and precompiled components in the lib directory. They will be tested using Jack language programs that may or may not be syntactically correct. A wide range of tests will be run, including some secret tests. Note: you will get no feedback on the secret tests, even if you ask! 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 the construction of 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 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 approaches used in the workshops. Resources The relevant reading for this project is Chapters 10 and 11. However, you should follow the program structure used in earlier workshops rather than the proposed structure in Chapters 10 and 11. You must write your programs in C++. The startup files include test files and test scripts you can use to check your work on this assignment. A set of precompiled classes similar to those used in the workshops and the previous assignment are also provided. Testing and IO We have a provided a description of the specific requirements for each component program on its own page. However before starting work on any of the component programs you should review the pages on Testing and IO Controls. Testing Details of the test data including the how to review the results of each test are described on the Assignment 3 | testing page. IO Controls Each component program has specific requirements for what it should or should not output when it is working correctly and what to do when an error occurs. Unless specified otherwise, the default error handling process for each component program is to terminate the program with an exit status of 0 and to have not produced any output. Unfortunately, this can make it difficult to trace the execution of your programs and get meaningful error messages from them during development. To allow you to achieve both, a number of output buffering and error reporting functions have been provided and are described on the Assignment 3 | io controls page. Component Programs parser The parser program uses the provided tokeniser to parse a Jack program and construct an equivalent abstract syntax tree. The specific requirements for this component program are described on the Assignment 3 | parser page. codegen The codegen program traverses an abstract syntax tree to generate virtual machine code. The specific requirements for this component program are described on the Assignment 3 | codegen page. pretty The pretty program traverses an abstract syntax tree and prints a Jack program formatted to a specific coding standard. The specific requirements for this component program are described on the Assignment 3 | pretty page. optimiser-e* The optimiser-e program traverses an abstract syntax tree and generates a new abstract syntax tree with all expressions pre-evaluated if possible. The specific requirements for this component program are described on the Assignment 3 | optimiser_e page.