Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: maybe_delimited #1770

Open
zeenix opened this issue Jul 23, 2024 · 1 comment
Open

feature request: maybe_delimited #1770

zeenix opened this issue Jul 23, 2024 · 1 comment

Comments

@zeenix
Copy link

zeenix commented Jul 23, 2024

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

@scnerd
Copy link

scnerd commented Aug 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants