public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Parsing templates as baseclasses
@ 1998-03-03  1:08 Mike Stump
  1998-03-02 20:02 ` Mark Mitchell
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Stump @ 1998-03-03  1:08 UTC (permalink / raw)
  To: mmitchell; +Cc: egcs

> Date: Sun, 1 Mar 1998 17:02:45 GMT
> From: Mark Mitchell <mmitchell@usa.net>

> As we speak, I'm engaged in the process of redoing the cp/parse.y from
> scratch

This is something that needs to be done.

Do you understand the hard parsing issues with C++?  If you think the
grammar in the standard is the be all end all in grammars, then I
suspect there are things that you don't yet understand, and without
that understanding, completing this project to the level of
completeness that makes the project worthwhile will be hard.  Do you
think the grammar in the standard just works?  If so, why?

Do you have the requisite framework to solve all the hard parsing
problems in C++?

Also, have you implemented all the extra semantic checks as found in
the text of the standard that we previously had implemented in the
parser?

As an example of one of the more subtle parsing issues with C++,
consider the following:

          struct T1 {
                  T1 operator()(int x) { return T1(x); }
                  int operator=(int x) { return x; }
                  T1(int) { }
          };
          struct T2 { T2(int){ } };
          int a, (*(*b)(T2))(int), c, d;


          void f() {
                  // dismabiguation requires this to be parsed
                  // as a declaration
                  T1(a) = 3,
                  T2(4),                  // T2 will be declared as
                  (*(*b)(T2(c)))(int(d)); // a variable of type T1
                                          // but this will not allow
                                          // the last part of the
                                          // declaration to parse
                                          // properly since it depends
                                          // on T2 being a type-name
          }

Do you fully understand this example?  Without fixing it now, does
your parser currently get it right?  If not, did you think you had a
full C++ parser?  There are subtleties contained in that this example
that experts in both parsing and C++ find non-obvious.

Do you think you have the full implications of the following paragraph
implemented?

3 The disambiguation is purely syntactic; that is, the  meaning  of  the
  names  occurring  in  such a statement, beyond whether they are  type-  |
  names  or  not,  is  not  generally  used  in  or   changed   by   the  |
  disambiguation.   Class  templates  are  instantiated  as necessary to  |
  determine if  a  qualified  name  is  a    type-name.   Disambiguation
  precedes  parsing,  and a statement disambiguated as a declaration may
  be an ill-formed  declaration.   If,  during  parsing,  a  name  in  a  |
  template  parameter is bound differently than it would be bound during  |
  a trial parse, the program is ill-formed.

Have you addressed all the relevant issues raised in
ftp://ftp.cygnus.com/pub/g++/g++-bugs/parsing ?

Do you solve the complete problem of expr v decl parsing?  How?

What framework do you use (bison, yacc, PCCTS)?  Is is at least as
maintainable as a good PCCTS implementation?


I look forward to hearing about your work.

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Parsing templates as baseclasses
@ 1998-03-01 16:07 Martin von Loewis
  1998-03-01 16:59 ` Mark Mitchell
  0 siblings, 1 reply; 6+ messages in thread
From: Martin von Loewis @ 1998-03-01 16:07 UTC (permalink / raw)
  To: egcs

I'm trying to investigate the code

namespace foo {

  template <class T>
  class x {};

}

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

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

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

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

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

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

Any guidance appreciated.

Martin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-05-09  3:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-03  1:08 Parsing templates as baseclasses Mike Stump
1998-03-02 20:02 ` Mark Mitchell
1998-03-04 13:54   ` Neal Becker
  -- strict thread matches above, loose matches on Subject: below --
1998-03-01 16:07 Martin von Loewis
1998-03-01 16:59 ` Mark Mitchell
1998-05-09  3:34   ` Martin von Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).