Skip to content
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

Missing utilities #14

Open
spookylukey opened this issue Oct 2, 2017 · 6 comments
Open

Missing utilities #14

spookylukey opened this issue Oct 2, 2017 · 6 comments

Comments

@spookylukey
Copy link
Member

There are probably a few missing pieces in terms of building parsers. Some of the following from Parsec/Parsimmon:

It would be good to be able to easily express "discard everything until ..." or "collect everything until ..." which doesn't seem to be easy at the moment, but would be easier with the above utilities.

@spookylukey spookylukey modified the milestone: 1.0 Oct 2, 2017
@tungd
Copy link

tungd commented Dec 20, 2017

Hi, just wonder if there is anyone working on this? I've just finished one project using Parsy and willing to contribute.

@spookylukey
Copy link
Member Author

I'm not working on this, contributions would be welcome. notFollowedBy is already implemented in the form of should_fail.

@lisael
Copy link
Contributor

lisael commented Jun 18, 2019

I've just sent a PR implementing the lookAhead #29

@lisael
Copy link
Contributor

lisael commented Jun 22, 2019

And here's a proposal for manyTill : #31

@lisael
Copy link
Contributor

lisael commented Jun 22, 2019

I've got a concern about my implementation of lookAhead. peek is a function rather than a method on Parser. It's something I find confusing when I'm working with Parsy: Is stuff a method or a function that takes a parser?

I did make a function, because it's how I implemented this as a helper function in a project of mine, no other reason.

Is there a rule of thumb for this dilemma, method or function?

Note that peek(p) is the exact equivalent of p.should_fail().should_fail() (and we should benchmark this to decide wich implementation is better). Maybe it makes sense to make it a method on Parser.

Same question for #31.

@spookylukey
Copy link
Member Author

@lisael - yes, it is a bit hard to decide in some cases.

I think many_until makes more sense as a method, because it is similar to other things like many, and peek for a similar argument comparing to should_fail. I guess it's about a consistent fluent API.

For things that don't take a parser as an argument, or can take more than one, we use functions. I think that's a good rule of thumb.

@mcdeoliveira mcdeoliveira mentioned this issue Apr 5, 2022
spookylukey pushed a commit that referenced this issue Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants