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
New Parser: exactly #46
Comments
Hey Jeff,
const exactly = (n, parser) => sequenceOf(Array.from({ length: n}, () => parser); But it would be good to have a proper parser with descriptive error messages. So I'd welcome a PR. As for anti-patterns - since these are already possible with things like |
Merged and published in 3.1.0 🎉, thanks @jeffrose ! |
I found myself in a situation where based on the results of a
lookAhead()
I need to take eitherx
orx-1
characters. I couldn't find a convenient way to do that with the current API, so I wrote a new parser,exactly
.Now this does open the door to some anti-patterns. While
exactly( 3, letter )
makes sense,exactly( 3, letters )
does not.First of all, is there a way I could've done this with the current API that I simply didn't see?
Secondly, would you want a PR for the new parser? Admittedly it's not very complicated but it works.
The text was updated successfully, but these errors were encountered: