Parsing C: identifier VS typedef name

"Igor Baltic" <igor@SB8286.spb.edu>
16 Apr 2005 11:12:48 -0400

          From comp.compilers

Related articles
Parsing C: identifier VS typedef name igor@SB8286.spb.edu (Igor Baltic) (2005-04-16)
Re: Parsing C: identifier VS typedef name cfc@world.std.com (Chris F Clark) (2005-04-17)
Re: Parsing C: identifier VS typedef name idbaxter@semdesigns.com (Ira Baxter) (2005-04-17)
Re: Parsing C: identifier VS typedef name drdiettrich@compuserve.de (DrDiettrich) (2005-04-26)
| List of all articles for this month |

From: "Igor Baltic" <igor@SB8286.spb.edu>
Newsgroups: comp.compilers
Date: 16 Apr 2005 11:12:48 -0400
Organization: Compilers Central
Keywords: C, parse, question, comment
x-receiver: compilers@iecc.com

The problem may seem a bit "old", but it does not really make it easier.


As my utilite needs to parse a C program, I tried to use some of the most
well-known grammars, Jim Roskind YACCable C grammar (c5.y) and a lexer for it
(cpp5.l). And it found out that the grammar is dependent on whether the lexeme
is an IDENTIFIER or a TYPEDEFname. To manage with this problem Jim Roskind
recommended to maintain a symbol table for current scope, with the help of
which this problem was to be solved.


But the grammar is dependent on distinguishing IDENTIFIER and TYPEDEFname even
in declarations. So here's the problem: how can the lexer learn at the point
of declaration *WHAT* is that identifier-like string, IDENTIFIER or
TYPEDEFname? We didn't store it in any symbol table yet, we want to parse the
declaration!


Thanks,
        Igor Baltic
        PhML239, St Petersburg
[There's a variety of answers, all kludges. -John]


Post a followup to this message

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