silentmatt / expr-eval

Mathematical expression evaluator in JavaScript
http://silentmatt.com/javascript-expression-evaluator/
MIT License
1.18k stars 239 forks source link

Position of syntax error in parsed string #247

Open bscbrn opened 3 years ago

bscbrn commented 3 years ago

Hi, I am looking for a way to get some syntax error information from the parser in case there is any.

Something like the position of the offending character or token in the parsed expression string could be enough.

Is there anything I could use?

Thank you

silentmatt commented 3 years ago

Certain types of syntax errors include the character position in the error message, but it's not consistent. That could definitely use some work, maybe including using a custom Error sub-class that includes position properties instead of just a string.