Hi Alex,

On 11/15/2016 12:20 AM, Alex Buckley wrote:
You have a lot of questions here, mainly not about the OpenJDK implementation 
of JSR 379 but rather about JSR 379 itself. I'm
working on JLS text that will be presented alongside lang-vm.html in the next 
few weeks, but here are some quick points:

I'm looking forward to the JLS text very much ...

- lang-vm.html does not say that restricted keywords are keywords only inside a 
module declaration; it says they are keywords
_solely where they appear as terminals in ModuleDeclaration_.

Thanks, so for one this settles, that the compilation unit is irrelevant for 
the questions
at hand, only the syntactical structure of the content is relevant, right?

I'm still reluctant to believe the full consequences of what you seem to be 
saying.
With ModuleDeclaration being a non-terminal in the grammar, is the definition of
"restricted keywords" intended to mean:
   Whether or not a word is a keyword or identifier is decided *after* parsing 
has completed?
   Viz.: if a given text could be parsed as a ModuleDeclaration then exactly 
those words
   that have been used as keywords are keywords.
It seems so, because before parsing we don't have any knowledge whether or not 
a given
text *is* a ModuleDeclaration.
Is it even justified to speak of "parsing" in this context? Syntax inference?

The current grammar can be parsed, e.g., with a hand-written scannerless parser,
but can we assume any regularities about the grammar now and in the future?
If not, should all tool implementers be prepared to replace the parser with
full pattern matching with back tracking, as to try all possible combinations of
interpreting keyword candidates as keywords or identifiers?

Thinking aloud about possible consequences, I wonder what happens in case of a 
syntax error.
Strictly speaking a text that almost looks like a ModuleDeclaration but still 
cannot be fully
accepted as such, contains no keywords at all (because we have no 
ModuleDeclaration), right?
That's probably a fact which tools should carefully hide from users, to avoid 
producing
utterly confusing error messages. Generally speaking, the only "correct" syntax 
error
message seems to be: "the input text could not be matched as a 
ModuleDeclaration".

Picking on words, I still hold that my example contains restricted keywords as 
terminals
in a ModuleDeclaration where they are apparently interpreted (by javac) as 
identifiers:

    module module {            // second word is an identifier
        requires requires;     // second word is an identifier
        exports to to exports; // words #2 and #4 are identifiers
        uses module;           // second word is an identifier
        provides uses with to; // words #2 and #4 are identifiers
    }

So, am I possibly still barking up the wrong tree?
Or should the definition really say
   "where they appear as _keywords_ in ModuleDeclaration"
?

thanks,
Stephan




Reply via email to