rust-bakery / nom

Rust parser combinator framework
MIT License
9.18k stars 792 forks source link

Feature Request: Add branching parser combinator for `exclude()` and `depend()` #1734

Open evan0greenup opened 3 months ago

evan0greenup commented 3 months ago

Currently, there is alt().

For a parser a and another parser b, If we need logic which is: using applying parser b to the input, only if parser a success or in other case not success. (parser a does not consume input).

Adding this feature would be good.

epage commented 3 months ago

If I'm understanding, you want a parser(a, b) that does one of

tuple((peek(a), b))
tuple((not(a), b))

I can't think of a time that I've needed them. I'd be interested to know more about your case that this is common that having this in a library would be helpful.