Re: Symbol tables and scopes

Peter Flass <Peter_Flass@Yahoo.com>
7 Feb 2006 12:14:04 -0500

          From comp.compilers

Related articles
[2 earlier articles]
Re: Symbol tables and scopes cfc@shell01.TheWorld.com (Chris F Clark) (2006-02-03)
Re: Symbol tables and scopes Peter_Flass@Yahoo.com (Peter Flass) (2006-02-03)
Re: Symbol tables and scopes gdr@integrable-solutions.net (Gabriel Dos Reis) (2006-02-06)
Re: Symbol tables and scopes DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-02-06)
Re: Symbol tables and scopes DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-02-06)
Re: Symbol tables and scopes gah@ugcs.caltech.edu (glen herrmannsfeldt) (2006-02-06)
Re: Symbol tables and scopes Peter_Flass@Yahoo.com (Peter Flass) (2006-02-07)
Re: Symbol tables and scopes alexc@TheWorld.com (Alex Colvin) (2006-02-11)
Re: Symbol tables and scopes cfc@shell01.TheWorld.com (Chris F Clark) (2006-02-11)
Re: Symbol tables and scopes cbarron413@adelphia.net (Carl Barron) (2006-02-12)
Re: Symbol tables and scopes DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-02-14)
Re: Symbol tables and scopes DrDiettrich@compuserve.de (Hans-Peter Diettrich) (2006-02-14)
Re: Symbol tables and scopes david.thompson1@worldnet.att.net (Dave Thompson) (2006-02-14)
[9 later articles]
| List of all articles for this month |
From: Peter Flass <Peter_Flass@Yahoo.com>
Newsgroups: comp.compilers
Date: 7 Feb 2006 12:14:04 -0500
Organization: Road Runner
References: 06-01-101 06-02-027 06-02-045
Keywords: symbols
Posted-Date: 07 Feb 2006 12:14:04 EST

>>I can't lay any claim to originality, but I use a two-layer structure.
>>I have one "base" entry for a unque symbol (name). The "base" entry
>>contains a list of pointers to the actual symbol table entries, one for
>>each declaration, and the id of the block containing the declaration. I
>>look up the symbol and then scan the list to find the applicable
>>declaration for the current scope.


> How exactly do you find the block with the "applicable" definition, in
> an tree of scopes/blocks?
>
> It looks like inefficient to me, when for every currently visible scope
> the block id must be compared with the id's of *all* possible blocks?


I maintain a tree of blocks. The scope of a declaration is the block
it's declared in and all nested blocks that don't contain a
redeclaration. I walk backwards up the tree and, for each block, see
if the declaration list for this variable contains that block id. The
first one I hit is the applicable declaration. Probably not the most
efficient, and, as I said, probably not original. It has the
advantage that it works. I'm open to other suggestions.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.