logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

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.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

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: //cs/assignment3. This directory must only contain the following files and directories - the web submission system (https://cs.adelaide.edu.au/services/websubmission) 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..

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.

Logbook Marking

Important: the logbook must have entries for all work in this assignment, including your milestone submissions. See "Assessment - Logbook Review (https://myuni.adelaide.edu.au/courses/44935/pages/assessment-logbook-review) " for details of how your logbook will be assessed.

Code Review Marking

For each of your programming assignments you are expected to submit well written code. See "Assessment - Code Review (https://myuni.adelaide.edu.au/courses/44935/pages/assessment-code- review) " for details of how your code will be assessed.

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.

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++. You should use the Linux command diff to compare your program outputs to the example output files supplied by us. A set of precompiled classes similar to those used in the workshops and the previous assignment are in the zip file attached below. All the test files and test    scripts necessary for this project are available in the zip file attached below.

Component Functions

We have a provided a description of the requirements for each component program on its own page. This includes instructions on how to compile, run and test each component program.

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 jack_parser (https://myuni.adelaide.edu.au/courses/44935/pages/assignment-3-jack-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 jack_codegen (https://myuni.adelaide.edu.au/courses/44935/pages/assignment-3-jack-codegen) page.

pretty

The pretty program traverses an abstract syntax tree produced and prints a Jack program formatted to a specific coding standard. The specific requirements for this component program are described on the jack_pretty (https://myuni.adelaide.edu.au/courses/44935/pages/assignment-3-jack-pretty) page.

optimiser-r

The optimiser-r program traverses an abstract syntax tree produced and generates a new abstract syntax tree with redundant program elements removed. The specific requirements for this component program are described on the jack_optimiser_r (https://myuni.adelaide.edu.au/courses/44935/pages/assignment-3-jack-optimiser-r) page.

Testing

The test data including the convention used to name expected outputs for each test are described on the

Testing (https://myuni.adelaide.edu.au/courses/44935/pages/assignment-3-testing) page.

 

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

764 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

797 Answers

Hire Me
expert
Husnain SaeedComputer science

690 Answers

Hire Me
expert
Atharva PatilComputer science

781 Answers

Hire Me

Get Free Quote!

267 Experts Online