Writing a Compiler in C#: C Code Generation, Part 2

February 9, 2011

We’re ready to deal with control statements and top-level program structure. Let’s tackle these one after the other. The let statement has already been handled as part of the Assignment method in the previous installment. The while statement in Jack requires evaluating an expression and deciding whether to continue or to jump to the end of the loop. At the end of the while statement block, there should be an unconditional jump to the beginning of the loop. Something along the following lines: BEGINWHILE_0: evaluate condition expression ...