On 11/16/2016 02:08 PM, Stephan Herrmann wrote:
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
I suspect you're not using the latest javac. Your example works for
me, after I also create a class called open.module that I can import.
$ more $(find play/stephan/ -name \*.java)
::::::::::::::
play/stephan/open/module.java
::::::::::::::
package open;
public class module { }
::::::::::::::
play/stephan/module-info.java
::::::::::::::
import open.module;
module foo {
}
$ /opt/jdk/jake/bin/javac -sourcepath play/stephan
play/stephan/module-info.java
$
-- Jon