Re: Symbol conflict in HashTable for variable

alexc@world.std.com (Alex Colvin)
17 Nov 2001 00:38:12 -0500

          From comp.compilers

Related articles
Symbol conflict in HashTable for variable frigot_e@epita.fr (2001-11-14)
Re: Symbol conflict in HashTable for variable alexc@world.std.com (2001-11-17)
| List of all articles for this month |
From: alexc@world.std.com (Alex Colvin)
Newsgroups: comp.compilers
Date: 17 Nov 2001 00:38:12 -0500
Organization: The World Public Access UNIX, Brookline, MA
References: 01-11-078
Keywords: symbols
Posted-Date: 17 Nov 2001 00:38:12 EST

>My question : What could be the best to do when i've got two
>variable with the same name (perhaps they are in two different function or
>something else...), i use the name of variable as key in my hashTable.


>For information, i can't use two or more Hashtables.


Then you'll have to use one, but it will have to store all the variables
with the same name. It will also have to have some way to tell them apart.


One structure that I've used is to label all the scopes (functions,
classes, compound statements, ...), and store that along with the
definition, Then you can find the right definition by remembering which
scopes are active.


This works well in the typical case where there is only one definition,
and correctly in the case where they all have the same name. It also makes
entering and exiting scopes nearly free.


--
mac the naïf



Post a followup to this message

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