-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
RFC: Allow throwing custom errors within grammar files #352
Comments
I'll close this in favor of #333 and add a chapter about it there once I get to do a revision based on the feedback left! |
Just a few thoughts on the actual implementation (I love this idea for giving more control over errors!): As a generalization, add a very limited form of "actions", which are written as As some examples of possible actions pest could add (and in a pseudo-#333 syntax),
This would emit an error pointing to the id if it started with an underscore, which isn't a valid identifier under profile-less UAX-31, but still match it as one, allowing parsing to continue (and emit a later error as well, if found.)
This could both allow customizing the error message emitted by pest as well as in this case, defining a span which to grab and point at in the constructed error. This is a super rough proposal generalization of this, but these usages I've demonstrated here seem like they could be very useful. |
Add a special term that, if matched, immediately throws an error with custom error message appended.
The purpose would be to:
The text was updated successfully, but these errors were encountered: