-
Notifications
You must be signed in to change notification settings - Fork 205
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
Custom User Defined Syntax Errors #646
Comments
Initiated due to discussion in: #645 |
Just a note on this: I'm not sure a Namely, if you're in some kind of "linting" scenario, you won't necessarily produce a single error. You might want to recover, but add an error to the stack. I guess this will work as long as if (foundRestArg && $.LA(1).tokenType === tokens.Comma) {
this.SAVE_ERROR(new Error("oops, can't have additional params after rest param"))
} |
If it is a syntax error it needs to throw and the Parser will auto recover if errorRecovery is enabled, If it is a linting error which does not affect parsing flow it could be saved in a separate data structure, preferably during a post parsing step (e.g CST Visitor). Although there could be some kind of mish-mash that seems partially syntax and partially semantics related. in that case you could still use SAVE_ERROR without throwing the result. The (minor) problem that this issue needs to resolve is that the SAVE_ERROR API:
|
Example
Requires a slight modification to the SAVE_ERROR code to avoid throwing a new error if the error is not a pre-known "RecognizerError"
The text was updated successfully, but these errors were encountered: