J-F-Liu / pom

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

[Feature request] accept str in the Set #68

Closed wiiznokes closed 1 month ago

wiiznokes commented 1 month ago

In this grammar (incomplete and with custom notation)

header: multiline_text | _
release_title: ## [text]
release: header release_title

For parsing header, i would like to write let header = none_of(b"\n## [").repeat(0..);, but \n## [ must be a sequence.

Thanks

wiiznokes commented 1 month ago

workarround: (any() - (!tag("\n## ["))).repeat(0..)

Just wanted to say that your crate feels like magic, i'm trully amazed by how well rust can infer type and integrate this pattern

Note:

The tag function is not is not part of the documentation. Also, the function i'm using force me to use Parser<'a, char>. I'm fine with it as i should have probably use it in the first place, but a version using u8 would be nice (and also move the char one in utf8 module