Hi, I've been blogging about macros in Rust, they may be interesting to some of you:
- Macros in general
- Macros in Rust pt1 - macro_rules
- pt2 procedural macros/syntax extensions
- pt3 hygiene
There will be more, stay posted...
Hi, I've been blogging about macros in Rust, they may be interesting to some of you:
There will be more, stay posted...
And another blog post, this one covers import/export, parsing and libsyntax, spans, and expansion traces.
I wonder if
Once parsing is complete, then we have an AST for the whole crate which will include macro uses with un-parsed token trees as arguments. We can then start macro expansion.
is a simplification? When we define macros, we use syntactic categories as expr
and ident
. When is it enforced that the macro argument is really and expression?
Also there are snippets in parser.rs
like this
// Check for a whole path...
let found = match self.token {
token::Interpolated(token::NtPath(_)) => Some(try!(self.bump_and_get())),
_ => None,
};
if let Some(token::Interpolated(token::NtPath(path))) = found {
return Ok(*path);
}
which I suspect are related to macro expansion in some way
Could you point me to the entry point of macro expansion code? I am curious about it.