zenspider wrote
Still using 2.5.x on osx, I found the following:
// -*- c -*-
class ParserBug2 {
function void init() {
var int n;
let n = 32767;
let n = -32768;
return;
}
}
// In ParserBug2.jack (line 8): In subroutine init: Integer constant too big
This isn't a bug. It is an inconvenient feature of the language.
The Jack language defines "integerConstant: A decimal number in the range 0..32767."
"-32768" is treated as the expression "-(32768)" which is indeed outside the range for integerConstant.
[There are lots of compromises like this in Jack so that it is easier to write the compiler.]
--Mark