This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: data structures


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]