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

How to do error recovery that *adds* tokens #236

Closed
MalekiRe opened this issue Dec 24, 2022 · 2 comments
Closed

How to do error recovery that *adds* tokens #236

MalekiRe opened this issue Dec 24, 2022 · 2 comments

Comments

@MalekiRe
Copy link

Hey, I'm working on my own language using this parser, and all the error recovery options appear to be for skipping/removing/consuming tokens. I'm not sure if what I am thinking is the proper way to go about it, but if I have a language construct like a function arguments my_function(1, 2, 3) and I miss a comma my_function(1, 2 3) I think that the proper move here would be an error recovery strategy that would add a , comma token and see if that fixed the input. I don't know though, thoughts?

@zesterer
Copy link
Owner

zesterer commented Dec 27, 2022

I think the best approach here would probably be to attempt to parse the correct pattern, and then fall back to a lot lenient parser that tries to deal with such errors, generating an error in the process. This should be possible with the new recovery strategy introduced in #233.

@zesterer
Copy link
Owner

Closing because the approach chumsky takes when performing error recovery is to generalise parsers over erroneous inputs and emit ancillary errors in the process instead of trying to 'fix' the original input.

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

2 participants