This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: data structures
- From: Perry Smith <pedz at easesoftware dot com>
- To: Joe Buck <Joe dot Buck at synopsys dot COM>
- Cc: Deepan Chakravarthy <codeshepherd at gmail dot com>, libstdc++ at gcc dot gnu dot org
- Date: Mon, 17 Apr 2006 12:49:42 -0500
- Subject: Re: data structures
- References: <4443A9F9.6090304@gmail.com> <20060417162138.GG17383@synopsys.com>
On Apr 17, 2006, at 11:21 AM, Joe Buck wrote:
On Mon, Apr 17, 2006 at 08:15:13PM +0530, Deepan Chakravarthy wrote:
Hello,
We are in the process of designing compiler for another language. We
use gcc for most part of it. We want to know how classes, inheritance
are implemented in g++ . We find that is not separate dot y (.y)
file to
list all the grammar rules for C++. The parser seems to take care of
everything.
GCC uses a recursive descent parser for C++. Releases before 3.4 used
a Bison (.y, as you call it) parser together with a special pass
between
the lexical analyzer and the parser to try to deal with the fact that
the C++ grammar is not LR(1), but requires unbounded lookahead (for
example, to distinguish constructor calls from function declarations).
After years of trying to make that parser work, it was discarded and
replaced.
This (the fact that GCC abandoned an automatically generated parser in
favor of a hand-written one) seems to regularly shock students who
have
recently completed a typical university compiler course; most of these
courses devote excessive attention to the theory of LR parsing
after a few
disparaging words against recursive descent parsers, taking so much
time
to cover lexing and LR parsing that there's little time for
anything else.
That sounds like a fascinating thesis: determine what class of
languages C++ belongs to and then develop a meta-processor and input
specification to properly parse C++.