Re: Am I parsing this correctly? (when do I build the symbol table)

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Sat, 19 May 2007 09:46:27 +0200

          From comp.compilers

Related articles
Am I parsing this correctly? (when do I build the symbol table) iecc@ryandary.com (Ryan Dary) (2007-05-17)
Re: Am I parsing this correctly? (when do I build the symbol table) wyrmwif@tsoft.org (SM Ryan) (2007-05-19)
Re: Am I parsing this correctly? (when do I build the symbol table) mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2007-05-19)
Re: Am I parsing this correctly? (when do I build the symbol table) DrDiettrich1@aol.com (Hans-Peter Diettrich) (2007-05-19)
Re: Am I parsing this correctly? (when do I build the symbol table) mburrel@uwo.ca (Mike Burrell) (2007-05-19)
Re: Am I parsing this correctly? (when do I build the symbol table) jeffrey.kenton@comcast.net (Jeff Kenton) (2007-05-19)
Re: Am I parsing this correctly? (when do I build the symbol table) gneuner2@comcast.net (George Neuner) (2007-05-19)
Re: Am I parsing this correctly? (when do I build the symbol table) 148f3wg02@sneakemail.com (Karsten Nyblad) (2007-05-20)
Re: Am I parsing this correctly? (when do I build the symbol table) ulimakesacompiler@googlemail.com (Uli Kusterer) (2007-05-20)
Re: Am I parsing this correctly? (when do I build the symbol table) chris.dollin@hp.com (Chris Dollin) (2007-05-21)
[3 later articles]
| List of all articles for this month |

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

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


Post a followup to this message

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