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

How about a "trace" macro ? #630

Open
2 tasks done
wakuflair opened this issue Dec 12, 2024 · 1 comment
Open
2 tasks done

How about a "trace" macro ? #630

wakuflair opened this issue Dec 12, 2024 · 1 comment
Labels
A-combinator Area: combinators C-enhancement Category: Raise on the bar on expectations

Comments

@wakuflair
Copy link

wakuflair commented Dec 12, 2024

Please complete the following tasks

winnow version

0.6.20

Describe your use case

I found myself always need to surround my parser in trace function, so why don't we add a "trace" macro to make us more lazy?

Describe the solution you'd like

Something like:

#[trace]
fn my_parser(input: I) -> PResult<O> {
  ...
}

will be expanded to:

fn my_parser(input: I) -> PResult<O> {
  trace("my_parser", move |input: &mut _| {
   ...
  }).parse_next(input)
}

Alternatives, if applicable

No response

Additional Context

No response

@wakuflair wakuflair added the C-enhancement Category: Raise on the bar on expectations label Dec 12, 2024
@epage epage added the A-combinator Area: combinators label Dec 12, 2024
@epage
Copy link
Collaborator

epage commented Dec 12, 2024

I'm trying to hold off on having proc macros. There is an RFC for attribute macro-by-example. That would allow us to support a #[winnow::trace] macro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-combinator Area: combinators C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants