HELP: How to parse forward references in C++ classes

Tomas Telecky <tft@fi.muni.cz>
10 Apr 1996 08:30:04 -0400

          From comp.compilers

Related articles
HELP: How to parse forward references in C++ classes tft@fi.muni.cz (Tomas Telecky) (1996-04-10)
Trying to parse C++ jar@netscape.com (Jim Roskind) (1996-04-11)
Re: HELP: How to parse forward references in C++ classes jsgray@ix.netcom.com (1996-04-11)
Re: HELP: How to parse forward references in C++ classes kanze@gabi-soft.fr (1996-04-11)
| List of all articles for this month |

From: Tomas Telecky <tft@fi.muni.cz>
Newsgroups: comp.compilers
Date: 10 Apr 1996 08:30:04 -0400
Organization: Masaryk University,Brno
Keywords: C++, parse, question

Hello,


I am trying to write some kind of C++ syntactical analyzer using the
Roskind's C++ bison grammar. This grammar contains two different
tokens for identifiers - IDENTIFIER and TYPEDEFname. The lexer has to
decide which one of them to return when it scans a common
identifier. This decision is made accordingly to the contents of the
symbol table.


There are, however, forward references in C++ classes definitions
possible, like


class X { X(){ i = 0; } int i; };


The "i" identifier is used before it is declared in class X (at least
lexically). The lexer must return correct value for "i" though.


Thanks for any advice on how to do it.
--------------------------------------------------------------------
Tomas Telecky, tft@fi.muni.cz
[All the approaches I know of use either guessing, backing up, or both.
You'll be happier with a more powerful tool than bison -- visit
comp.compilers.pccts. -John]


--


Post a followup to this message

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