-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
Allow combination of _ and @ for silent rules that disallow whitespace #118
Comments
Really nice to hear about that. Version 1.0 is just around the corner with a lot of improvements, including the fact that comments and whitespace are atomic by default. Apart from these two special cases, I see no use case for a rule that should be both silent and atomic, but I'm open to suggestions. |
Thanks for the quick response; that's very exciting to hear! A case I ran into (but it wasn't a big deal, honestly) is when I wanted to parse a variable name in my language, knowing that all variables are prefixed by "$". I did something like:
And in the process macro, I have no need to see the leading "$" and so I am just skipping over variable rules and handling variable_names. I might have chosen therefor to make variable _@ in this case. If I run into any more compelling use cases I'll let you know - intuitively _ and @ feel somewhat orthogonal and so I expect there are times when using both would help reduce clutter in the token queue. |
Since my first comment, I've run into a couple more use cases:
This (admittedly looks messy - I'd love to hear an alternative) would allow ; or \n to end a rule, without adding any unnecessary tokens to my queue. The only alternative I'm aware of is not allowing newlines in my whitespace rule (which I may well do) and supporting them manually in places |
In this particular case The reason I'm hesitant about this is because I feel it makes the grammar a bit harder to wrap your mind around when first starting to use it. |
This will become useful in more cases with #261; consider the case of a
The desired semantics here are that the |
Will close this in favor of #271. |
First off, I have found pest a pleasure to use, so thankyou for this library!
I have run into times when it would be nice to be able to decalre a rule as not accepting whitespace but also not being silent, ie using something like "@" rather than just "" or "@" to prefix a rule.
A particular example I think I have run into (but it may very well be my lack of experience) is comments that end on a newline. If my grammer is like:
I want to be able to specify that the whitespace rule does not get applied between each ~ in the comment rule, to ensure that the whitespace rule doesn't swallow the newline before the rule can be applied to end the comment. I also don't want to hear anything about comments in my queue.
Regardless of whether that is a problem, it would be nice in general to be able to opt out of whitespace and be silent about a rule.
The text was updated successfully, but these errors were encountered: