Compiling Java 9

Stephan Herrmann stephan.herrmann at berlin.de
Wed Nov 16 22:08:56 UTC 2016


On 11/16/2016 10:02 PM, Alex Buckley wrote:
> - If you lex 'package', then the sequence must parse as the first alternative.
> - If you don't lex 'package', but rather lex 'import', then parsing is ambiguous until you've looked ahead to lex either 'open',
> 'module', or a keyword that can start TypeDeclaration. [Ignoring annotations for simplicity.]
> - If you lexed 'open' or module', then the sequence must parse as the second alternative; if you lexed anything else, then the
> sequence must parse as the first alternative.

I just tried this:

---8<---
import open.module;

module foo {
}
---8<---

According to lang-vm this should be legal. The import statement
contains restricted keywords in positions where they cannot be keywords.
=> Parsing should succeed.
javac rejects this, which supports your explanation that lexical lookahead
should suffice to recognize a ModuleDeclaration.

Which one will it be?

Stephan



More information about the jigsaw-dev mailing list