Re: C Language Scoping

"Michael S. Schliephake" <mss@emsoft.de>
29 Oct 1997 23:00:10 -0500

          From comp.compilers

Related articles
C Language Scoping gilberto_persico@it.ibm.com (Gilberto Persico) (1997-10-26)
Re: C Language Scoping mss@emsoft.de (Michael S. Schliephake) (1997-10-29)
Re: C Language Scoping hbve@camoes.rnl.ist.utl.pt (Hugo Branco Venancio) (1997-10-29)
| List of all articles for this month |
From: "Michael S. Schliephake" <mss@emsoft.de>
Newsgroups: comp.compilers
Date: 29 Oct 1997 23:00:10 -0500
Organization: LF.net GmbH, Internet Services, Stuttgart, Germany
References: 97-10-118
Keywords: C, parse, symbols

Gilberto Persico wrote:


> I can't understand: how can a
> symbol be assigned to a scope (global, a function, a structure) during
> parsing ??? And if I have the same symbol used in more contexts like the
> following example:
> ...
> how can I know in the parser that the first X is an int in scope A and
> the second X is a float in scope test ??


First you know if you are accessing a variable x or a structure component
like a->x or a.x.In the case of two variable, of course the inner definition
is valid.


For a first implementation (well described) look at "Compiler design in C"
from Allen Holub, Chapter 6. The source is available from
http://www.holub.com But I would recommend the text in every case too. This
may be used directly or serve as an inspiration for another implementation.


Michael.


--
Engineering Firm info@emsoft.de
Michael S. Schliephake http://www.emsoft.de
Phone: +49 (7472) 91 287
Fax: +49 (7472) 28 13 82 Translating dreams into action.
--


Post a followup to this message

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