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: Kotlin DSL annotations #19

Open
quad opened this issue Sep 6, 2023 · 1 comment
Open

Feature Request: Kotlin DSL annotations #19

quad opened this issue Sep 6, 2023 · 1 comment

Comments

@quad
Copy link

quad commented Sep 6, 2023

Context: I'm porting an existing handwritten parser to use parsus.

Right now, parsus offers variety of methods to accomplish almost the same task. e.g. repeatOneOrMore vs. oneOrMore

As parsus' API is mostly undocumented and has to be discovered by type-completion, it would be helpful if the "right" methods were more obviously promoted in their context.

Kotlin offers a @DslMarker annotation for type-safe builders that is designed for this situation.

@alllex
Copy link
Owner

alllex commented Sep 9, 2023

That's a good point, I will consider this again.

Using the @DslMarker would allow separating the ParsingScope from other scopes, and potentially forbidding to call oneOrMore declarative combinator in favor of an imperative combinator repeatOneOrMore. This, however, may not be desirable.

Even though using oneOnMore-like combinators inside the parser { ... } blocks is very inefficient, it could still be useful for prototyping. The alternative would force users to always use procedural combinators or to declare named declarative parsers outside the ParsingContext scope.

Having said that, I will play around with this a bit more and figure out if this actually improves discoverability.

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