Re: Q: How to preserve symbol table info through multiple pass compilation?

cfc@world.std.com (Chris F Clark)
30 Apr 1997 21:00:38 -0400

          From comp.compilers

Related articles
Q: How to preserve symbol table info through multiple pass compilation jlee@espresso.ucsd.edu (Justin Lee) (1997-04-22)
Re: Q: How to preserve symbol table info through multiple pass compila cfc@world.std.com (1997-04-30)
Re: Q: How to preserve symbol table info through multiple pass compila leichter@smarts.com (Jerry Leichter) (1997-05-04)
Re: Q: How to preserve symbol table info through multiple pass compila bduncan@tiac.net (Bruce Duncan) (1997-05-08)
| List of all articles for this month |

From: cfc@world.std.com (Chris F Clark)
Newsgroups: comp.compilers
Date: 30 Apr 1997 21:00:38 -0400
Organization: The World Public Access UNIX, Brookline, MA
References: 97-04-153
Keywords: design, symbols

> I originally preserved the symbol table by saving the contents for a
> specific scope at the appropriate places in the parse tree, but this
> is giving me problems when I want to insert something new into the
> symbol table after the initial pass through the parse tree. I am
> playing around with the idea of representing the symbol table as a
> tree of scopes, with nested scopes being children of the scope they
> are nested in. This, however, gives me a problem with constructs like
> the following:
>
>
> void foo () {
> ...
> }
>
> int x;
>
> void boo() {
> ...
> }
>
> 'x' should be visible to boo but not foo even though they have the
> same parent scope.


Your idea of using tree of scopes is just fine. The problem is with
"C". Each declaration in C introduces a new scope. In other words,
boo and foo do not share the same parent scope, there are at least 3
scopes illustrated in your fragment. The scope including the
declaration of foo, the scope nested inside that which also has an x
inside it, and the scope inside that that adds a boo.


-Chris Clark
--


Post a followup to this message

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