rust-bakery / nom

Rust parser combinator framework
MIT License
9.38k stars 806 forks source link

Add `is_bin_digit` method #1652

Closed Chasing1020 closed 11 months ago

Chasing1020 commented 1 year ago

Prerequisites

Question

nom currently provides a set of character test functions like: is_digit: Tests if byte is ASCII digit: [0-9] is_hex_digit: Tests if byte is ASCII hex digit: [0-9A-Fa-f] is_oct_digit: Tests if byte is ASCII octal digit: [0-7]

It appears that there is no method like is_bin_digit and bin_digit0/1 to recognize one or more binary characters: [0-1]. At the moment, I am using many1(one_of("01")) to implement this feature, and this will return Vec<char>. However, I am not entirely satisfied with this approach. If you have any suggestions for a better method, please let me know. If there are no better solutions, I may consider submitting a pull request at a later time.

NickCrews commented 1 year ago

I would vote to keep this feature out, I think it's utility is limited and your current solution does not look that painful.