|Recognition of typedefs in C ? email@example.com (David Pereira) (2001-01-18)|
|Re: Recognition of typedefs in C ? firstname.lastname@example.org (2001-01-19)|
|Re: Re: Recognition of typedefs in C ? email@example.com (James H.Grosbach) (2001-01-26)|
|From:||James H.Grosbach <firstname.lastname@example.org>|
|Date:||26 Jan 2001 16:57:52 -0500|
|Posted-Date:||26 Jan 2001 16:57:52 EST|
On Friday 19 January 2001 21:25, you wrote:
> >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.
This is the approach taken by the Roskind grammar (see the FAQ for
sources if you don't already have a copy) and it works quite
well. There's no getting around the fact that typedefs are a right
pain, but they can be done and keep things relatively clean in this
Principal Compiler Engineer
Return to the
Search the comp.compilers archives again.