This is the mail archive of the java@gcc.gnu.org mailing list for the Java 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: how does the JLS deal with the >> ambiguity?


Adam Megacz wrote:
This probably isn't the perfect mailing list for this, but it's close ;)

In C++ there's a known ambiguity where you have to put a space between
two right-angle brackets in a template instantiation:

Foo<Bar,Baz<Bop> >

Otherwise the ">>" is treated as the "shift-right" token by the lexer.

I was wondering how JLS 1.5 handles this, since Javac seems to do just
fine when the space isn't there.  The JLS itself isn't sufficiently
formal at the lexical level to clarify this -- it just says that '>'
"is a token" and '>>' "is a token".

There is a section called "2.3 Handling Consecutive Type Parameter Brackets" in http://www.cis.unisa.edu.au/~pizza/gj/Documents/gj-specification.pdf.


As I understand it all cases of single and double (and in Java even triple) right-angle braces are handled in the parser.

Hope it helps

Stephan


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