Open Metaxal opened 3 years ago
Just realized this doesn't fit the purpose of Syntax Parse Bee, sorry! I may try to enhance it to make it a worthwhile example... if I get the time (and an idea).
Feel free to discard it.
Hm? This looks like a perfect fit to me --- two useful syntax-parse macros. It's fine that these would work as normal syntax rules.
Macro
The purpose of the first macro is to make it easy to parse command line arguments in a hierarchical way using the built-in
command-line
form. The second macro is an additional helper that displays the help message automatically when no command-line argument is specified at this level, which avoids the case where the user tries one argument is then has no information about what to do next.Example
Before and After
I've heard several times that
command-line
can't parse arguments hierarchically. Well, turns out it's easy withsyntax-parse
! (although admittedly,syntax-rules
would have worked too. But at least withsyntax-parse
it's easy to extend the macro to parse additional keywords, such as if one wants to shift the arguments by more than 1.)These macros were written for a PR to
resyntax
. See the diff there.Licence
Yes.
Yes.