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


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

Parsing templates as baseclasses



>>>>> "Martin" == Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:

    Martin> I'm trying to investigate the code

As we speak, I'm engaged in the process of redoing the cp/parse.y from
scratch, based directly on the grammar in the standard, with the
addition of the GNU extensions that we currently support.  This is an
unauthorized, unsanctioned project; in particular, Jason's had nothing
to do with it.  I've discovered a number of odd parsing problems, and
after poking around a bit, decided that some major changes were in
order, especially now that the C++ grammar has (finally) stabilized.

So, you might want to hold off; in a week or so I expect to submit the
new (and hopefully much improved) grammar, which should be fully
ISO-conformant.  On the other hand, there's no guarantee whatsoever
that this version will be in g++ any time soon; Jason will of course
have to check it over with his usual eagle eye.

    Martin> namespace foo {

    Martin>   template <class T> class x {};

    Martin> }

    Martin> class y : public foo::x<int> {};

    Martin> I've got the lexer to produce, for the last line

    Martin> (AGGR `class') (IDENTIFIER_DEFN `y') (':')(VISSPEC)
    Martin> (NSNAME)(SCOPE) (PTYPENAME `x')('<')(TYPESPEC `int')('>')
    Martin> ('{')

    Martin> The last line is eventually reduced -> template_type.
    Martin> Then I get an error with the stack state stack now 0 1 4
    Martin> 66 222 223 466 717 958 123

    Martin> In the non-namespace case, the template_type is further
    Martin> reduced
    -> type_name -> nonnested_type -> base_class.1

    Martin> Now, where should I put the support for
    Martin> namespace-qualified template types? I'll have to
    Martin> eventually reduce this to baseclass.1 as well, preferably
    Martin> without declaring foo::x<int> a nested type (it isn't).
    Martin> Also, I'd like to avoid additional conflicts in the
    Martin> grammar.

    Martin> Any guidance appreciated.

    Martin> Martin


-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu



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