nom
nom copied to clipboard
feature request: `maybe_delimited`
I would like something like:
delimited(
opt(char('(')),
many1(my_parser),
opt(char(')'),
)
so that outer () are optional but I would only want them optional together so unmatched () are treated as an error.
A maybe_delimited function that treats the delimiters as optional in combination, would help with this.
Test case
I cant provide this if needed but of course it would not work currently. :)
Could be easily written as alt(body | delimited(left, body, right)), right?