Assignments 11 and 12
Assignment 11 Due Date: 2015-4-12, 11:59pm
Assignment 12 Due Date: 2015-4-19, 11:59pm
The goal of these assignments is to be able to translate any arbitrary Jack program into a valid VM program. These projects build off of your Assignment 10 code, and should generate the VM program from your syntax tree. To guide your translation, you are provided with 11 test programs, which should be completed in order.
- Empty - Smallest valid program. Requires translation of
- subroutineDec with void type
- returnStmt with no expression
- FortyTwo Prints the number 42. Requires translation of
- expression (partially)
- term / integerConstant
- Seven Prints seven with a couple different complex expressions. Requires translation of
- expression with multiple terms/ops
- term / ( expression )
- term / - term
- term / ~ term
- Static Test some static variables. Requires translation of
- term / identifier
- term / true false null
- Quadratic Modified version of Quadratic from A10. Requires translation of
- subroutineDec (with type)
- term / subroutineCall
- returnStmt with actual return value
- ConvertToBin Converts numbers to binary. Requires translation of
- HelloWorld Requires translation of
- Square Our old friend the Square game. Requires translation of
- subroutineCall with this
- subroutineCall with instance of a class
- Average Compute the average of input numbers. Requires translation of
- letStmt with brackets
- term / identifier with brackets
- WackyArrays A bunch of harder tests with array brackets. If all previous parts were implemented correctly, should not require additional functionality.
- Pong If all previous parts were implemented correctly, should not require additional functionality.
Programs 1-5 should be completed by the Project 11 deadline. Programs 6-11 should be completed by the Project 12 deadline. Your final code should match either the code generated by the provided JackCompiler or the supplied vm.alt files. The alternate files have a different set of label names.
This assignment requires you to write code.
Stubs for Java and Python are provided in your repos.
Your code will be run with one of the following commands:
- Java - java JackCompiler Something.jack
- Python - python jack_compiler.py Something.jack
- C/C++ - ./jack_compiler Something.jack
Please turn in all the files needed to run your compiler, including those from A10 and files that you have not modified. There is no need to create a separate folder for A12; just complete the code in the 11 folder.
The repos also contain a Jack parser that reads the XML files in the Data1112 folder. You can use it or your own parser.
- Note that the grammar for this class and the "official" grammar in the book differ slightly.
- When processing subroutineDeclarations, until Quadratic, you can assume that there are 0 locals, and the type is void.
- There is a test file for 6_ConvertToBin for you to test logic. You can create additional test files for the other tests.
- The code originally had a typo in both the Java and Python versions. In the JackCompiler/jack_compiler constructor, it called the compile_class method of the parser. It should have said parse_class. The zip file has been updated.
- The simpler way to handle let a[i] = statements has been integrated into test programs 9 and A, with new/altered vm.alt files.