J-F-Liu / pom

PEG parser combinators using operator overloading without macros.
MIT License
496 stars 30 forks source link

Documentation or examples for Range and Set #58

Open mcclure opened 1 year ago

mcclure commented 1 year ago

I don't quite understand what Range and Set are for. It would be good if they had documentation strings, or at least an example. I could help write documentation as a PR if I had an example to compare to or an explanation.

If "Range" is something used internally by the library and not intended to be messed with directly by users, the documentation strings should say that.

I would very much like to be able to match a range of values, like (('a' as u8)..=('z' as u8)). Is that what Range does?

nigeleke commented 7 months ago

You've probably found an answer to this already; I'm not the OA but both Range and Set appear helper classes for one_of(aSet) or repeat(range). A recent PR I requested makes these pub(crate).

WRT the match of range of values - this is (almost) possible with one_of(&(b'A'..b'Z')). Note: that example is not an inclusive range however a recent PR I requested enables inclusive ranges one_of(&(b'A'..=b'Z'))