|Recognition of typedefs in C ? firstname.lastname@example.org (David Pereira) (2001-01-18)|
|Re: Recognition of typedefs in C ? email@example.com (2001-01-19)|
|Re: Recognition of typedefs in C ? firstname.lastname@example.org (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 ? email@example.com (James H.Grosbach) (2001-01-26)|
|Re: Recognition of typedefs in C ? firstname.lastname@example.org (Jos A. Horsmeier) (2001-01-26)|
|From:||"David Pereira" <email@example.com>|
|Date:||18 Jan 2001 01:13:21 -0500|
|Organization:||Excite@Home - The Leader in Broadband http://home.com/faster|
|Keywords:||C, types, parse, question|
|Posted-Date:||18 Jan 2001 01:13:21 EST|
I am writing a C compiler and am at the parser stage. I have run
into a bit of a problem. I need to enable the lexer to distinguish
typedef names from ordinary identifiers. At first glance, it seemed
that building a table of typedef names was enough - the lexer would
consult this table and return TYPENAME if the name was found in this
table, otherwise IDENTIFIER. However, this is inadequate since
*context* matters. How can this context be discerned ?
The following piece of code demonstrates the inadequacies of a simple
typedef int x; /* parser enters 'x' into the typename table */
x blah; /* lexer consults typename table and returns TYPENAME for
'x'. GOOD !!! */
int main ()
int x; /* lexer consults typename table and returns TYPENAME for x.
BAD !!! */
Any ideas ??
[This is by far the ugliest part of parsing C. See the archives, it's
come up before. -John]
Return to the
Search the comp.compilers archives again.