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) |
From: | Justin Lee <jlee@espresso.ucsd.edu> |
Newsgroups: | comp.compilers |
Date: | 22 Apr 1997 21:16:52 -0400 |
Organization: | Interactive Cognition Lab at UC San Diego |
Keywords: | parse, symbols, question |
Hi,
I'm currently writing a multiple pass (tree-based) compiler. So far
I've accomplished the following:
1) lexed input into tokens
2) parsed tokens and created a parse tree
Next I will accomplish the semantic checking and code gen with
multiple passes on the parse tree.
My question is this: what is the best way to structure a symbol table
so that the scope relationships are preserved/updated through multiple
passes of the parse tree?
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.
Does anyone have any suggestions? Please mail reply. Thanks!
--
Justin Lee
jlee@espresso.ucsd.edu
Interactive Cognition Lab at UCSD
(619) 822-0673
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.