JM wrote
So I think I realized what the problem was. I had lines like this in a couple of places in my code:
if(var = a or var = b) {
....code.....
}
Just as a warning to others working through this project, remember to read the documentation carefully! Jack does not recognize "or" as a boolean operator. I believe the correct syntax is if(var = a | var = b) { .... }
Also, and perhaps more importantly, the compiler will not always throw you an error when there's something wrong with your code. It might just get hung up somewhere.
Yes, like any language it expects you to constrain yourself to the defined operators. But you have some other issues.
First, 'var' is a keyword, so don't use it as a variable name.
Second, even after you "fix" the code you have an operator precedence issue.
The authors are very careful to point out (See Section 9.2.5) that operator precedence and order of evaluation is NOT defined beyond evaluating expressions within parentheses first.
So the code
if (varName1 = varName2 | varName1 = varName3)
could be evaluate in any one of six possible ways. The most likely is simply from left to right (with right to left being second most likely):
if (((varName1 = varName2) | varName1) = varName3)
This will not do what you want. You need to be extremely careful with Jack to put in sufficient parens in order to FORCE the compiler to evaluate expressions in the manner you want.
So you really, really, really need to write this as:
if ( (varName1 = varName2) | (varName1 = varName3) )