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]
Other format: [Raw text]

Re: Help requested on C++ template syntax (for Emacs development).


>>>>> "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


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