how does the JLS deal with the >> ambiguity?

Adam Megacz megacz@gcc.gnu.org
Thu Sep 15 08:52:00 GMT 2005


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

Are we to assume that this implies that any JLS 1.5-compliant parser
with a separate lexer (lexerless parsers don't have this problem in
the first place) is REQUIRED to implement some form of token-ambiguity
and decide whether or not to merge the tokens during parsing?

  - a

-- 
PGP/GPG: 5C9F F366 C9CF 2145 E770  B1B8 EFB1 462D A146 C380



More information about the Java mailing list