A few syntax issues
Opened this issue · 1 comments
Test cases
// Problem with async
++async()();
// Spreading literal number
[....1``++];
// Keyword `await` is allowed as identifier name
`${await++}//`;
// Same for `let` keyword
`${let++}//`;
// I am not sure if this is an issue, or you did it on purpose
if(0);else/\//;
// Any reason for matching fourth grave accent as wrong strign sequence?
`${````}`;
// This is valid script, ES allows incrementing result of function call
````++
{[]};
How it looks
Regarding some of these, like let
and async
, while some allowances are made for these to be recognized as identifiers in plausible scenarios, keep in mind that a regex based syntax highlighter can never have adequate context to differentiate a Script from a Module. ES Sublime presumes module.
We also can't actually parse expressions, so instead we need to rely on heuristics to determine plausible continuations — loosely categorizing each possibly terminal token in one of four or five groups to make decisions about what comes next. If you’d like to submit a PR to permit the incremented template literal in the final example or spreading numeric literals, I’d be happy to review & merge, but it’s obviously not real code so between that and the fact that a regexp syntax def can't be entirely precise, I don’t consider these bugs.
The if (exp) ;
example is definitely a bug though. It affects while (true) ;
as well — I’ll spin that off into a ticket on its own, but am closing this one.