From: Tom Tromey <tromey@redhat.com>
To: Alan Mackenzie <acm@muc.de>
Cc: gcc@gcc.gnu.org
Subject: Re: Help requested on C++ template syntax (for Emacs development).
Date: Wed, 11 Jun 2008 18:15:00 -0000 [thread overview]
Message-ID: <m3d4mnyh28.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20080610183707.GB4844@muc.de> (Alan Mackenzie's message of "Tue\, 10 Jun 2008 18\:37\:07 +0000")
>>>>> "Alan" == Alan Mackenzie <acm@muc.de> 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
prev parent reply other threads:[~2008-06-11 18:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-10 18:15 Alan Mackenzie
2008-06-10 18:56 ` Ian Lance Taylor
2008-06-10 19:05 ` Ian Lance Taylor
2008-06-15 14:12 ` Alan Mackenzie
2008-06-11 18:15 ` Tom Tromey [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3d4mnyh28.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=acm@muc.de \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).