How Do I write codes for classVarDec* in the compileClass?
I tried to parse classVarDec* in compileClass() using while expression for an attached sample Jack program. However, I received an error message 'list index out of range.' I wrote while expression as below.
test.jack while token[i]=='static' or 'field':
cn.CompileVarDec() //cn is a CompilationEngine class
Instead of using while expression, I called CompileclassVarDec() twice to parse classVarDec and then it worked out. I guess CompileclassVarDec() is correct and the problem is related to while expression.
I have no idea why my code output the error and could you give me any clue? If a complete parser program is needed, I will share it.