Saturday, 15 February 2014

compiler construction - How to take scope into account when building a symbol table with yacc? -


My yacc parser creates a symbol table, but I need to take this into account. How would I do that? I have heard that when you get out of one area, the symbol table is destroyed, still it is not very clear how to do it.

There are several ways to handle scoping in a symbol table. A very easy way is to have a separate table for each area and maintain a list of active scraps.

Whenever a new radius is entered, you can create a table for it and start it. Active field list when you leave the scope, then simply remove the head of the active area list Please give it.

I usually find that when you parse an area you do not want to delete the table. You may need it later to perform semantic analysis, debug info etc. can be generated.


No comments:

Post a Comment