Compiling Java 9

Alex Buckley alex.buckley at oracle.com
Wed Nov 16 23:10:31 UTC 2016


On 11/16/2016 3:03 PM, Stephan Herrmann wrote:
> On 11/16/2016 11:57 PM, Alex Buckley wrote:
>> On 11/16/2016 2:26 PM, Stephan Herrmann wrote:
>>> And we may safely assume regularity of the grammar, i.e.,
>>> the above approach will never lead to ambiguities, right?
>>>
>>> Fictitious counter example
>>>
>>>     ModuleDeclaration:
>>>       module open Identifier ModuleBody;
>>>       module Identifier ModuleBody;
>>>
>>> With this the second token could be keyword or identifier, and we're
>>> stuck, aren't we?
>>>
>>> May we assume that the grammar will not be extended in such ambiguous
>>> ways?
>>
>> There is already a production like this:
>>
>> ModuleStatement:
>>   requires transitive ModuleName ;
>>   requires ModuleName ;
>
> Outch!!
>
> So when you read "requires transitive" which rule are you parsing against?
> When do you decide whether transitive is a keyword or an identifier?
> I guess we have to wait until we matched the full rule.
> That requires backtracking, or what am I missing?

Yes, you need to lookahead to a ;

Alex


More information about the jigsaw-dev mailing list