Compiling Java 9
Alex Buckley
alex.buckley at oracle.com
Wed Nov 16 22:47:44 UTC 2016
On 11/16/2016 1:41 PM, Stephan Herrmann wrote:
> 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?
Please disregard 'open' being a terminal symbol of the lexical grammar
... I was looking at the opening sentence to 2.4 at the time, which
smashes together the terminals of both grammars, and I got mixed up.
Nothing is changing in 2.2.
I say again: I agree identifiers are terminals in the syntactic grammar,
and that it's confusing for lang-vm to say that 'module' is a keyword
solely where it may appear as a terminal in ModuleDeclaration, since
here it appears as a terminal (Identifier) in the second-word place yet
plainly it should not be a keyword there:
module module { // second word is an identifier
But by "appears as a terminal", I didn't mean "can be parsed as the
terminal Identifier". I literally meant "appears in fixed width font
presentation on the RHS of a production under ModuleDeclaration".
> 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.
Frankly no.
Alex
More information about the jigsaw-dev
mailing list