Compiling Java 9
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Nov 16 23:02:14 UTC 2016
On 11/16/2016 02:55 PM, Stephan Herrmann wrote:
> On 11/16/2016 11:35 PM, Jonathan Gibbons wrote:
>>
>>
>> On 11/16/2016 02:26 PM, Stephan Herrmann wrote:
>>> Still no good news for tools wishing to process just a fragment of
>>> the text.
>>>
>>
>> Just how small a fragment, and in how unknown a context are you
>> worried about? Yes, if you're wanting to locally analyse the
>> character string "module" in isolation, then yes, you cannot say
>> whether it is a keyword or an identifier, but if you know you're in
>> a ModuleBody, then "exports to to exports;" can be processed just fine.
>
>
> For syntax highlighting: processing just one line of text would be great.
> And the line break could be in the middle of an exports clause.
>
> For error recovery: let's say, s.o. just forgot a ';', we'd like to
> search for the next keyword to get back on track parsing.
> So even if we started from the top of the file, we don't have the
> context for sure, because we don't know where the syntax error happened.
> I guess in that case reverting to always seeing restricted keywords as
> keywords will give the best heuristics ... but it looks messy to me.
I agree error recovery can be tricky, but if you are before the first
'{' then the
only restricted keywords are 'open', 'module'. Once you're inside a module
declaration, ';' is a good recovery point. ';' is always followed by a
restricted
keyword, or '}'.
>
> Different tools / tool features have different requirements, a full IDE
> will have tens if not hundreds of different use cases in this regard.
> Mind you: during editing text with syntax errors is the norm, not the
> exception.
>
> Stephan
More information about the jigsaw-dev
mailing list