yshavit / mdq

like jq but for Markdown: find specific elements in a md doc
Apache License 2.0
5 stars 0 forks source link

parser conveniences #52

Closed yshavit closed 3 months ago

yshavit commented 3 months ago

I was going to do something more clever with having a higher-order Parser on top of the Iterator, but by the time I got done with the checkbox parsing (with its optionals etc), I realized I'd just basically written a few convenience methods on top of the parser, but still needed the low-level ones (like next() or peek()). So, this just adds the conveniences.

I could imagine an even higher-level abstraction, where for example I specify an enum and get back which if any of its string-equivalent-variants was next; basically a parser.peek_one_of( { "foo", "bar", "baz" } ). But without static typing (ie if I literally just pass in a Vec<&str> it doesn't feel very compelling, and with static typing (ie an enum) it feels too heavyweight. At least for now.