Related articles |
---|
Recognition of typedefs in C ? davidpereira@home.com (David Pereira) (2001-01-18) |
Re: Recognition of typedefs in C ? henry@spsystems.net (2001-01-19) |
Re: Recognition of typedefs in C ? apiron@ulb.ac.be (Anthony PIRON) (2001-01-19) |
Re: Recognition of typedefs in C ? Joachim.Pimiskern@de.bosch.com (Joachim Pimiskern) (2001-01-19) |
Re: Re: Recognition of typedefs in C ? james.grosbach@microchip.com (James H.Grosbach) (2001-01-26) |
Re: Recognition of typedefs in C ? jos@and.nl (Jos A. Horsmeier) (2001-01-26) |
From: | henry@spsystems.net (Henry Spencer) |
Newsgroups: | comp.compilers |
Date: | 19 Jan 2001 23:25:53 -0500 |
Organization: | SP Systems, Toronto, Canada |
References: | 01-01-096 |
Keywords: | C, types, parse |
Posted-Date: | 19 Jan 2001 23:25:53 EST |
David Pereira <davidpereira@home.com> wrote:
>...consult this table and return TYPENAME if the name was found in this
>table, otherwise IDENTIFIER. However, this is inadequate since
>*context* matters...
Not necessarily...
>typedef int x; /* parser enters 'x' into the typename table */
>...
>int main ()
>{
> int x; /* lexer consults typename table and returns TYPENAME for x.
>BAD !!! */
Rather than trying to return IDENTIFIER for x, it suffices to accept
either IDENTIFIER or TYPENAME for the name being declared. This does
require some rearrangement of the grammar to ensure that the TYPENAME is
not taken as part of the type specification, but it *can* be done -- I did
it in an experimental parser.
--
When failure is not an option, success | Henry Spencer henry@spsystems.net
can get expensive. -- Peter Stibrany | (aka henry@zoo.toronto.edu)
Return to the
comp.compilers page.
Search the
comp.compilers archives again.