C symbol table structures

mac@coos.dartmouth.edu (Alex Colvin)
2 Jan 1999 00:22:01 -0500

          From comp.compilers

Related articles
C symbol table structures mac@coos.dartmouth.edu (1999-01-02)
Re: C symbol table structures kadhim@lucent.com (Basim Kadhim) (1999-01-04)
Re: C symbol table structures heinrich@idirect.com (1999-01-06)
Re: C symbol table structures drh@microsoft.com (Dave Hanson) (1999-01-11)
Re: C symbol table structures resslere@erols.com (Gene Ressler) (1999-01-17)
| List of all articles for this month |

From: mac@coos.dartmouth.edu (Alex Colvin)
Newsgroups: comp.compilers
Date: 2 Jan 1999 00:22:01 -0500
Organization: Dartmouth College, Hanover, NH, USA
Keywords: C, design

I've been working on a compiler for C* (a dialect of C).

I'm using a symbol table structure that I think I heard about here
(comp.compilers) long ago. Can anyone tell me if this has a name, or if
i got it right?

Each scope (block) is numbered, in increasing order. Each identifier
has a list of definitions and scope numbers.

The parser keeps a stack of the currently active scopes. To find an
identifier's current definition we search its definition list for the
first (innermost) active definition.

Structures have their own scopes, which are searched to find member

In this scheme, scope entry and exit just increment the scope number
and adjust the scope number stack. Instead of having a table for each
scope, we have a list for each identifier. This is sort of like shallow

The idea, as I recall, is that C has lots of scopes, but most
identifiers are defined in only one, typically the global level.

The drawback is that heavily overloaded identifiers have slow lookups,
potentially scanning past lots of out-of-scope definitions. Even this
can probably be fixed by discarding them upon redefinition.

-- mac the naif
Alex Colvin

Post a followup to this message

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