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

Add TakeWhile and TakeWhile1 combinators #2

Open
oleiade opened this issue Sep 7, 2022 · 0 comments
Open

Add TakeWhile and TakeWhile1 combinators #2

oleiade opened this issue Sep 7, 2022 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@oleiade
Copy link
Owner

oleiade commented Sep 7, 2022

The library should have some version of a TakeWhile and/or TakeWhile1 character parser combinators.

TakeWhile

The combinator would return the longest continuous subset of the input that matched the provided predicate. It would likely have a prototype such as:

func TakeWhile[Input Bytes](input Input, predicate func(input rune)bool) gomme.Parser[Input, Input]

and be used like:

func separator() gomme.Parser[string, string] {
	return gomme.TakeWhile[string](isSeparator)
} 

func isSeparator(c rune) bool {
    return c == '\t' || c == '\r' || c == '\n'
}

TakeWhile1

Would fulfill the same contract as above, with the added condition that the predicate should be matched at least once.

@oleiade oleiade added the enhancement New feature or request label Sep 7, 2022
@oleiade oleiade added this to the v1.0.0 milestone Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant