I read in a Compiler Design course that the output of scanning is a sequence of pairs (token code, token position in the symbol table). I am a bit confused about the meaning of the "position" part. When the symbol table is represented as a structure whose elements can be accessed using an index, e.g., an array, "position" is clear, it means the 1st, 2nd, 99th element in the array. E.g., for source code:
if (a == b) a = a + c;
the output of scanning will be the stream: ( ..., (id,1), ..., (id,2), ..., (id,3) ) - I didn't depict the other tokens for simplicity - and the symbol table will be (a,b,c), so a on position 1, b on position 2, c on position 3 in the symbol table.
What happens when the symbol table is represented as a binary search tree? For the same source code, the symbol table tree will have a root node with key 'b'; b's left node will have key 'a' and b's right node will have key 'c'. What should the output of scanning be now ( ...,(id,?), ..., (id,?),..., (id,?))? If my tree is implemented using a Node class, should I do smth like this: ( ...,(id, reference to Node whose key = a),...)?
What about when the symbol table is a hashtable? In C# for instance, could I have a Hashtable object HashST and the output of scanning looking like this: (..., (id,pointer to HashST["a"]),...)?
I really don't know whether this is the right approach, what else could "position" mean in a tree or a hash table?
Thank you in advance!