Re: Parsing C++

David L Moore <>
7 Dec 1996 22:59:52 -0500

          From comp.compilers

Related articles
Parsing C++ (1996-11-15)
Re: Parsing C++ (Graham Hughes) (1996-11-18)
Re: Parsing C++ (1996-11-18)
Re: Parsing C++ (Jan Gray) (1996-11-19)
Re: Parsing C++ (1996-12-03)
Re: Parsing C++ (David L Moore) (1996-12-07)
Re: Parsing C++ (1996-12-09)
Re: Parsing C++ (1996-12-09)
Re: Parsing C++ (1996-12-10)
Re: Parsing C++ (1996-12-18)
| List of all articles for this month |

From: David L Moore <>
Newsgroups: comp.lang.c++.moderated,comp.compilers
Date: 7 Dec 1996 22:59:52 -0500
Organization: Netcom
References: 96-11-102 96-12-029
Keywords: C++, parse

John Lilley wrote:

> The "identifier vs. type" problem is not an LALR(1) problem per se.
> It has nothing to do with the parser approach -- a parser with
> infinite lookahead and backtracking would do no better. The solution
> lies in connecting the symbol table to the lexer (or using predicates
> ala PCCTS), not in the parser class.

One interesting thing about C++ is the "injection" rule which says that
a method defined in a class is compiled as if it immediately followed

int foo;
class A {
void bar()
foo x;
enum foo {bar,bletch};

I believe this should compile with x being an enum. (On the other
hand there is a "Symbols cannot change meaning" rule which may apply
here - my
references appear to be all at work, so I am not certain this is

Anyway, this should be compiled as if it read:

int foo;
class A {
void bar();
inline void A::bar()
foo x;

One way to do this is to save the text of the definition and then
insert it after the declaration of the class (while keeping the class

This is rather ugly. Is there an efficient way to compile the method
definition in place? How have C++ implementors handled this?

David L Moore

Post a followup to this message

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