From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22024 invoked by alias); 11 Jun 2008 18:15:18 -0000 Received: (qmail 22015 invoked by uid 22791); 11 Jun 2008 18:15:18 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 11 Jun 2008 18:15:00 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m5BIEvr4026040; Wed, 11 Jun 2008 14:14:57 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5BIEvAp025868; Wed, 11 Jun 2008 14:14:57 -0400 Received: from opsy.redhat.com (vpn-10-84.bos.redhat.com [10.16.10.84]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m5BIEuu0030128; Wed, 11 Jun 2008 14:14:57 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id BEB66378182; Wed, 11 Jun 2008 12:14:55 -0600 (MDT) To: Alan Mackenzie Cc: gcc@gcc.gnu.org Subject: Re: Help requested on C++ template syntax (for Emacs development). References: <20080610183707.GB4844@muc.de> From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom Date: Wed, 11 Jun 2008 18:15:00 -0000 In-Reply-To: <20080610183707.GB4844@muc.de> (Alan Mackenzie's message of "Tue\, 10 Jun 2008 18\:37\:07 +0000") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2008-06/txt/msg00274.txt.bz2 >>>>> "Alan" == Alan Mackenzie writes: Alan> So, the question: is it possible to identify with 100% certainty, PURELY Alan> SYNTACTICALLY (i.e. without access to the compiler's symbol table), Alan> when "< ... >" is a pair of template (C++) or generic (Java) brackets? In Java, yes, if the source is error-free. Alan> I'm thinking of things like Alan> foo (a < b, c > d); Alan> I think this is unambiguously a function call with 2 parameters, the Alan> expressions "a < b" and "c > d". In Java this is a function call. If 'a' is a type, this is an error, since you can't declare 'd' here. So... if cc-mode assumes that the code it is looking at is syntactically correct, you can always guess. But, it is a lot nicer for the user if errors are flagged. That way lies the Eclipse approach :-) Alan> Another related question: although there is no maximum bound on how far Alan> apart template/generic brackets can be, I believe that in practice, they Alan> are never that far apart (a few hundred bytes max, perhaps). Is this, in Alan> fact, the case? For Java, yeah, generally speaking. There may be exceptions. And sometimes I think you may find surprising amounts of whitespace in there. For C++, I think you are just doomed. Even if you could get the compiler to emit perfect information, it would only emit information about the code it actually saw -- not stuff in ignored #if groups. Tom