nom icon indicating copy to clipboard operation
nom copied to clipboard

feature request: `maybe_delimited`

Open zeenix opened this issue 1 year ago • 1 comments

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. :)

zeenix avatar Jul 23 '24 13:07 zeenix

Could be easily written as alt(body | delimited(left, body, right)), right?

scnerd avatar Aug 20 '24 21:08 scnerd