Okay, let's get our hands dirty and prototype a proc-macro for the Refined Syntax Idea 4! This will be a non-trivial proc-macro, but breaking it down into steps will make it manageable. We'll focus on the core parsing and code generation, without implementing all the features initially (like full expression parsing within the handlers). We'll build up the functionality iteratively.
Project Setup (Proc-Macro Crate)
First, create a new proc-macro crate within your muchin
project. This is crucial because proc-macros must be in a separate crate. Assuming your main muchin
crate is in a directory called muchin
, do the following:
cd muchin
cargo new muchin_macros --lib