rspivak / slimit

SlimIt - a JavaScript minifier/parser in Python
MIT License
550 stars 94 forks source link

Bug: Error when parsing "`" #110

Closed fengh16 closed 5 years ago

fengh16 commented 5 years ago

The back quote("`") can't be parsed.

Example of input that caused error:


function a() {
  var b = `b`;
}

Error message:

Illegal character '`' at 1:27 after LexToken(EQ,'=',1,25)
Illegal character '`' at 1:29 after LexToken(ID,'b',1,28)
metatoaster commented 5 years ago

slimit was written at a time when ES5 was the latest standard, which did not have backquotes (`) as part of the syntax, as this was not introduced until ES6/ECMASript 2015 (Section 11.8.6), so unfortunately, what you want to do is not currently supported by this library.

If parsing ECMAScript 2015 is the only requirement, try esprima-python, which has support up to ECMAScript 2017.

fengh16 commented 5 years ago

Thank you!