A question regarding handling consecutive '>' characters in "3.2. Lexical Translations"
Alex Buckley
alex.buckley at oracle.com
Mon Dec 20 20:54:51 UTC 2021
Lexical translation was clarified in JLS 17, and the ambiguities called
out. See the revised sections 3.2 and 3.5, especially:
-----
If the input character > appears in a type context (§4.11), that is, as
part of a Type or an UnannType in the syntactic grammar (§4.1, §8.3), it
is always reduced to the numerical comparison operator >, even when it
could be combined with an adjacent > character to form a different operator.
-----
The lexer is expected to interact with the parser in order to figure out
whether a > lexeme could be consumed by the indicated productions of the
syntactic grammar.
Alex
On 3/17/2021 2:20 AM, Javran Cheng wrote:
> Hello Java SE Spec authors,
>
> I'm recently reading Java SE 16 spec (this is also present in many other
> recent versions) and there is one part in "3.2. Lexical Translations" that
> I would want some clarification:
>
>> ... There is one exception: if lexical translation occurs in a type
> context (§4.11) and the input stream has two or more consecutive >
> characters ...
>
> Here I want to know how can I tell whether it is in a type context when the
> lexical analysis is not done - does this sentence just want to make sure
> readers are aware of this ambiguity when it comes to consecutive >
> characters (so how exactly this is done is up to implementor) or is there
> somewhere explained in the spec regarding how to tell a type context during
> lexical analysis?
>
> Thanks!
> Javran (Fang) Cheng
More information about the jls-jvms-spec-comments
mailing list