-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser error position #134
Conversation
cfa6e8a
to
dd52a90
Compare
Sorry for the late response, and thanks so much for your initiative! I've added the calculation of the exact text position in line numbers and column offsets. What do you think about that? |
Hi, thanks for considering my pull request! I had a quick look in you additions: I appreciate the calculation of lines/columns. (In my application had to do this after catching the exception anyways, so this makes things simpler). However, now the position is only available in the text of the error message and I think there is no way to get it programmatically (without parsing the error message, which I'd like to avoid). In my case, I'd need the exact location of the error because I want to draw squiggles in a template editor. |
Ah, I haven't thought about your use case. I've updated my code so you can get the location programmatically. |
… into parser-error-position
@pantor : Hi, finally I got time to integrate the new version of the line numbers patch back into my project - thanks for merging!
Here, I would expect an error at the end of line 2 or beginning of line 3 because
So, instead of 4:2 I would expect 3:1. There is probably something wrong in Lexer::current_position() but I'm mot sure if I understand this function. Can you have a look? |
This PR adds a new parser_error exception which contains the error location, i.e. the position of the last token parsed.
With this information it is possible to count the line number where the error happened (which would fix also #10)