On 11/16/2016 11:01 PM, Jonathan Gibbons wrote:


On 11/16/2016 01:41 PM, Stephan Herrmann wrote:

At the end of the day we need full pattern matching right?

Not really, at least, not in javac.

Words like 'module', 'requires', etc are lexed as identifiers. When we get to 
the point where the grammar would accept one of these
words as a keyword,  we simply check to see if we have an identifier with the 
appropriate value.

-- Jon

OK, feedback from the parser to the scanner to tell it
whether the current context accepts a specific restricted keyword.

And we may safely assume regularity of the grammar, i.e.,
the above approach will never lead to ambiguities, right?

Fictitious counter example

   ModuleDeclaration:
     module open Identifier ModuleBody;
     module Identifier ModuleBody;

With this the second token could be keyword or identifier, and we're stuck, 
aren't we?

May we assume that the grammar will not be extended in such ambiguous ways?

For all tools that read from the start of the file this is good news.

Still no good news for tools wishing to process just a fragment of the text.

thanks,
Stephan

Reply via email to