rust-bakery / nom

Rust parser combinator framework
MIT License
9.49k stars 805 forks source link

Followup: Candidates for range syntax #1613

Open cenodis opened 1 year ago

cenodis commented 1 year ago

This is a followup to #1402 which was merged in #1608. The merged implementation only includes range variants for many and fold. More parsers were mentioned as candidates in #1402.

This issue tracks the status of those candidates for conversion to a range syntax.

Current candidates

Geal commented 1 year ago

I'm less sure about converting those right now, because they rely on specialized implementations (the split_at_position* methods) to make most parsers fast, but maybe those methods could be generalized

epage commented 1 year ago

One way to handle this is to dispatch to different implementations like my complete/streaming work, hoping the compiler inlines enough to remove the overhead.

Geal commented 1 year ago

separated_list could be a good target for this

vwkd commented 1 year ago

+1 for a separated_list that accepts an additional range argument like 2..10.

Currently, there is only separated_list0 and separated_list1. If you wanted say separated_list2 you'd have to add more stuff like wrapping it in a separated_pair, duplicating the parser and separator, and mapping to push the first item onto the Vec of the rest. If you wanted a separated_list21to42 you'd probably need to dive down and implement it yourself.

All multi parsers accepting a range argument would be very nice!