-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: negative/positive look-ahead/behind, non-consuming surrounding context parsers, negation parsers #50
Comments
Hey, thanks for the feedback and suggestions! I've already started working on lookahead/backtracking combinators and playing around with non-consuming parsers in general, so your use cases and thoughts will be a great help for sure. I have to take care of some personal stuff though, so I'll get back to this and other issues on weekends-holidays. |
Thank you for your work, I really appreciate it! |
I took a glance at your examples and can tell you right away what the problem is: the missing Under the hood As for the word boundaries... Well, it's sad it doesn't work, but I believe this should be handled on the library consumer's side, as this seems to be a rather specific issue with regular expressions in JS. Besides, nothing stops you from either wrapping Ultimately, I would like to keep the core of the library as small as possible. As for the other stuff in the issue, I'll reply later and link a PR. |
Oh, adding What concerns word boundaries it was my desire to completely migrate from regexps and I'm just fine to implement it myself! I do not expect that this library will cover all the features of regular expressions. And if there will be such a need I guess it should be done through an extension package e.g. |
Returning to the first part of the issue...
|
The idea must be silly but what if we restrict the use of I know that it conflicts with the overall API design but maybe it's not needed to make it work the way other parsers do. It may be just fine to make it work as a support function for |
Hm-m, that could work, thanks for the idea! I'll have to add names or some other identification means for parsers and combinators, but I'll need to add it anyway for future tracing/debugging features. |
There are multiple things described in this issue, but I think it's better to keep them close.
I'm doing some free text parsing migrating from the regular expressions based solution. I faced an issue that I couldn't fully specify the surrounding context.
when
is the only parser that could work with context but documentation doesn't say anything whether it consumes input or not (I assume it does which raises a question how it is different fromsequence
). Alsowhen
allows to specify preceding context only and I'm not sure what should I use to specify the context after the target parser.It would be nice to have non-consuming parser (
context
) and negation parser (not
) so it would be possible to specify surrounding context e.g.Also it would be nice to have some default non-consuming parsers such as
wordBoundary
. What is more this will require polyfilling JS\b
since it's not unicode friendly.More examples can be found in the codesandbox.
The text was updated successfully, but these errors were encountered: