Passing through tokens in a procedural macro

I want a procedural macro where blocks of code in {..} are passed through unchanged to rustc. Something like

fn use_self(&self) {
    my_macro! {
         custom dsl syntax { self.valid().rust() }
    }
}

But whatever I do I get a "unexpected token" error.

I'm storing the ParseStream from inside the braces and then just using it in my ToTokens implementation.

Can anyone help, or point me towards resources that may help?

EDIT

For context, I'm trying to build a tool to help parse css styles, so I can typecheck them before using them in dodrio/seed/etc. Link to repo: https://github.com/derekdreery/style.

You may want to look at syn::Block if you are using syn.

1 Like

Perfect, thankyou!