|Parsing C: identifier VS typedef name igor@SB8286.spb.edu (Igor Baltic) (2005-04-16)|
|Re: Parsing C: identifier VS typedef name email@example.com (Chris F Clark) (2005-04-17)|
|Re: Parsing C: identifier VS typedef name firstname.lastname@example.org (Ira Baxter) (2005-04-17)|
|Re: Parsing C: identifier VS typedef name email@example.com (DrDiettrich) (2005-04-26)|
|From:||"Igor Baltic" <igor@SB8286.spb.edu>|
|Date:||16 Apr 2005 11:12:48 -0400|
|Keywords:||C, parse, question, comment|
|Posted-Date:||16 Apr 2005 11:12:48 EDT|
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
PhML239, St Petersburg
[There's a variety of answers, all kludges. -John]
Return to the
Search the comp.compilers archives again.