-
Notifications
You must be signed in to change notification settings - Fork 91
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
Tolerant error handling #9
Comments
This would be great for syntax highlighting, autocompletion, getting a list of definitions and even better static analysis (letting you get many errors in a single run)... What would need to be changed in order to support this? |
I'm sorry, are there any news on this? Somewhere where help is needed or a way to start working on this? |
To my knowledge, unless @oxyc is sitting in a cave and secretly crafting a solution, this isn't being worked on currently. As the cliché goes, patches are welcome. I think simply slapping some try-catch blocks in a few strategic places (where the catch block puts the syntax error in some array and then just swallows the exception) could give us a rudimentary solution. But that would hardcode some policy decisions about interpreting non-well-formed code into the parser. I'm not sure what design @oxyc had in mind when he filed this issue. (And while we're doing this, I'd change the |
Yeah I've given a a few shots at implementations but couldn't really come up with anything that was useful. At the moment I don't have access to the code I experimented with and it was a while ago so not certain what I tried. I at least wrapped Acorns loose parser would be a something to look at. https://github.com/ternjs/acorn/tree/master/src/loose |
When parse errors are made recoverable, it seems it shouldn't be too hard to go the whole way and introduce warning lints as well, or at least a mechanism for such lints to be easily plugged in. Some warnings to consider:
|
Implement a mode where errors are stored instead of thrown. Necessary recovery functions should be exposed so that users can hook into it.
I don't think the parser itself should include recovery functionality but should definitely have an example available.
The text was updated successfully, but these errors were encountered: