sakumar wrote
If x is a variable name, parsing the <term> non-terminal requires 2 read ahead in the following example:
<term> could begin with:
x // just the variable
x[2] // Array reference
x.y // subroutine call
By the time the parser realizes that it is case 3 (subroutine call) it has already consumed the token for 'x'. So if it calls compileSubroutineCall(), the first token could be '.' which could be problematic for this function to deal with.
It's been about a year and a half since I wrote my compiler, but if memory serves, I set an objName variable when parsing terms so that I could pass it into compileCall(objName) when I encountered the '.'. CompileCall would then parse the function name and argument list.
do x.y(); would have similarly parsed the 'x' into objName and parsed the '.' before calling compileCall(objName).
--Mark