You have long seen the remnants of addiction for C programmers: it is assumed that characters will be on some lists, and instead of highlighting list structures separately, list pointers are included as part of the character structure. This trick saves one distribution in the list element, but at a cost: the set of lists on which the symbol can be included is fixed, and this structure confuses programmers. If the application is a compiler, there is no reason to use this trick. It is much clearer to have a separate list structure, which is defined something like this:
struct ste_list { struct ste *symbol_table_entry; struct str_list *next; };
You can have as much as you like, and no one is wiser. And the internal pointers that you find obscure go away.
You're asking
What is the logic behind this?
Part of the answer is that it is useful to have characters in the highlighted list. I can’t answer the question definitively without knowing more about a specific compiler. It’s best to assume that the prev entry will be used to implement nested areas (brackets { ... } in C), but this assumption is based on the compilers I saw or worked. Thus, perhaps the logic is that when a trailing parenthesis occurs, the compiler can follow this link until it reaches ste in the enclosing area. People with a little more experience than the author of the compiler you are studying usually put this logic in a “symbol table abstraction,” which will include functions such as enterscope() and exitscope() , and the details of these operations will be hidden from the inside represent individual character table entries.
source share