From: | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
Newsgroups: | comp.compilers |
Date: | Sat, 19 May 2007 09:46:27 +0200 |
Organization: | Compilers Central |
References: | 07-05-067 |
Keywords: | parse, symbols |
Posted-Date: | 20 May 2007 22:06:44 EDT |
Ryan Dary wrote:
> Right now, I am walking through the tokens, and building up a tree
> like structure so that I have nodes like Program, Function, Class,
> etc. Then, as I'm parsing some of the source lines, I am actually
> skipping them right now because it seems impossible to know what the
> tokens mean until I have built a symbol table of all the functions,
> etc. Perhaps I have this phase a bit backwards...
I'd create the symbol tables while parsing, and attach them to the
appropriate nodes. At that moment you have at hand all informataion,
telling where symbol definitions are located, and which scope they
belong to. This would allow to add unique references from symbol usage
nodes to the according symbol tables.
I've heard that VB requires up to 3 passes through the source files,
until all declarations are well known. This might indicate that
finishing the symbol tables must occur after parsing, while dealing
with the syntax tree, but it depends on your specific language
semantics.
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.