Alex,

I understand the motivation of not breaking existing code that uses these as 
identifiers.
I just want to understand the precise rules and figure out if any established 
technology
can recognize the desired language.

On 11/16/2016 10:02 PM, Alex Buckley wrote:
[...]
Make a close reading of JLS 2.2. It's true that identifiers are terminal 
symbols of the _syntactic grammar_. However, I want to
speak of 'open', 'module', et al as terminal symbols of the _lexical grammar_. 
Basically I mean "a fixed width font presentation of
a reserved lexeme spelled o p e n".

JLS 2.2:
"A lexical grammar for the Java programming language is given in ยง3 (Lexical 
Structure).
 This grammar has as its terminal symbols the characters of the Unicode character 
set."

"open" is not a character of the Unicode character set.
That's why I concluded you must be speaking of terminals of the syntactic 
grammar,
which has as its terminals identifiers, keywords, etc.

Or is 2.2 going to be extended to include restricted keywords as terminals of
the lexical grammar? But how can they be interpreted as identifiers if they
are already terminals of the lexical grammar?

I believe your newer phrase "where they can be keywords in ModuleDeclaration"
is already closer, if you add what you mean by "can": don't cause parsing
the ModuleDeclaration rule to fail.
At the end of the day we need full pattern matching right?
I.e., find a combination of interpreting each occurrence of a restricted keyword
as either a keyword or an identifier that allows to match the rule 
ModuleDeclaration.


Anyway, your answers tell me that javac matches your intentions,
even if I still can't match the current text in lang-vm to this.

Remain my worries that this will cause a lot of pain for all kinds of tools.
Even simple syntax highlighting becomes a major challenge,
it's impossible to process only sections of a module declaration.
Error reporting and syntax recovery are much harder, still.

BTW: has it been considered to use an escape character to explicitly turn a
restricted keyword into an identifier? That's the only way I can see that
a traditional parser can grok a ModuleDeclaration without "wasting" keywords.

Stephan

Reply via email to