Closed Jacob-Roberts closed 3 years ago
Hey @Jacob-Roberts , that is correct! The lexer does not detect semantic errors (and it shouldn't!) but just makes sure that the input can be converted into valid JS tokens (such as keywords, strings, number literals, and interpunction/operators). In this case the source contains all valid tokens. If you want to find semantic errors, you should run the parser instead (js.NewParser
). This should return the following:
ERROR: cannot minify in.js: unexpected : in expression on line 2 and column 16
2: "elementId": "mJn9mpMQwIYyBe",
^
Let me know if that works for you or whether you have additional questions! ;-)
Thank you!
Maybe as an improvement point, you could point out in the Readme for the JS page that the parser is available. It seems from the README that the Lexer is the only option
Good idea, I've added a short description, hopefully that covers it.
When using this library with the following code:
and the following input
No error is detected. This returns true.