From mboxrd@z Thu Jan 1 00:00:00 1970 From: mrs@wrs.com (Mike Stump) To: mmitchell@usa.net Cc: egcs@cygnus.com Subject: Re: Parsing templates as baseclasses Date: Tue, 03 Mar 1998 01:08:00 -0000 Message-id: <199803030157.RAA02370@kankakee.wrs.com> X-SW-Source: 1998-03/msg00066.html > Date: Sun, 1 Mar 1998 17:02:45 GMT > From: Mark Mitchell > 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.