To complete Projects 10/11 B,C,D you will finish the compiler in stages. At each stage, only implement parsing and code generation for the productions sufficient for completing the given test case. For a complete list of grammar productions, see the table of “The Jack grammar” in your textbook (in the 2nd edition, Figure 10.5 on page 201).
Some of these test cases are included in the nand2tetris distribution. Others are custom test cases we provide; the titles of custom test cases include hyperlinks to the ZIP files containing their source code in Jack.
To compile Three, you need to generate code for the following symbols:
class
subroutineDec
parameterList
subroutineBody
statements
doStatement
returnStatement
subroutineCall
expressionList
expression
term
integerConstant
To compile Seven, you need to generate code for the following additional symbols:
op
+
*
To compile AlphaWhere, you need to generate code for the following additional symbols:
varDec
letStatement
ifStatement
true
false
varName
-
<
Note: You will need to create a symbol table data structure to keep track of your local variables.
To compile AlphaShow, you need to generate code for the following additional symbols:
whileStatement
~
>
To compile Factorial, you need to generate code for the following additional symbols:
paramaterList
stringConstant
=
NOTE: The provided ConvertToBin is difficult to use. We recommend using this modified version (Main.jack), which uses keyboard input and prints to the screen, rather than relying on RAM hacking. Note that it prints its binary result with the least significant bit on the left (reversed in comparison to how you would typically write a binary number).
To compile ConvertToBin, you need to generate code for the following additional symbols:
&
To compile Average, you need to generate code for the following additional symbols:
To compile ComplexArray, you will additionally need to generate code for:
null
In theory, other than that, ComplexArray should compile if Average compiles. It is a much tougher test case, though. Make sure that the destination of the expression in a let statement does not have THAT inadvertently overwritten; your book has a detailed discussion of this problem with a suggestion of how to do it correctly.
THAT
To compile Square, the compiler should be completely finished, except for static variables. Pay particular attention to the following:
classVarDec
this
To compile Pong, the compiler should handle static class variables, unary -, and binary |.
|