I'm hoping someone can help me out a bit with this.
I notice that in the proposed SymbolTable spec, "kindof", "typeof" and "varCount" all refer to the "current scope", however there's no mention that I can see of how the current scope should be known. For example, two of these functions simply take the variable name as a single argument, not passing the current scope along with them.
Should I take it from this that I should add a function to the SymbolTable module such as:
setScope(scope currentScope)So that each respective function in the class can check the current scope before returning a value, with this function called by the compilationEngine module?
Also, it's recommended that you first replace the XML output of the identifiers with information about each variable identifier. However, this seems to suggest that when we hit an identifier, we already know what it belongs to.
If I come across an identifier "myVar", I can't know its scope and type without looking back up the tree. For example, in "static int nAccounts", I can't add nAccounts to the symbolTable until I hit the identifier, but by that point I've moved past "static" and "int", so how am I supposed to know these things?
As the tree is not explicitly stored, how are we supposed to get this information in order to fill in the symbol table or even just look up a value in the correct scope?
Am I missing something really obvious here?
Thanks in advance.