Skip to content
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

err without context of L #6

Open
longxueyuu opened this issue May 19, 2021 · 3 comments
Open

err without context of L #6

longxueyuu opened this issue May 19, 2021 · 3 comments

Comments

@longxueyuu
Copy link

when the lexer starts to analyze the source string, if err occurs, L does not provider any interface to expose 'start', 'position' info of source string to bind to the error;
the error is printed without this context info, so it is kind of difficult to locate the error in source string.

@bbuck
Copy link
Owner

bbuck commented May 12, 2022

Sorry for seeing this so late, I think that's a good point. I suppose the solution will be to add that information to the error being thrown so that it can show this information in its message.

I'd be happy to merge a PR with these changes.

tvanriel added a commit to tvanriel/go-lexer that referenced this issue Jun 4, 2022
Errors generated by l.Error() will now be wrapped with
"lexer(pos=line,pos): " to improve the developer experience.

Fix: bbuck#6

Signed-off-by: Ted van Riel <80752652+tvanriel@users.noreply.github.com>
@tvanriel
Copy link
Contributor

tvanriel commented Jun 4, 2022

@longxueyuu @bbuck If you're interested in my solution I can make a merge request :-)

@bbuck
Copy link
Owner

bbuck commented Jun 5, 2022

Sure let me take a look this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants