mozilla/rust — pull request #4021 by paulstansifer (2012-11-22 16:44:12+00:00)
Title: Allow `macro_rules!` to also define item and stmt macros

Now it's possible to invoke macros in statement and item position. The extra argument that syntax extensions in item position take is now optional (things defined with `macro_rules!` cannot see it).

At expansion time, the expansion of a macro defined with `macro_rules!` is parsed as an expr, an item, or a stmt, depending on where it is.

The delimiters around the RHS of a macro are no longer transcribed (this interfered with the parsing of items). This means that `macro_rules! mytuple( () => (1,2,3) )` doesn't work; an extra set of delimiters must be added around the `(1,2,3)`.

Closes #3086.

Outstanding issues:
* Expanding to multiple items is still not done.
* `{ my_expr_mac!() + 16 }` is a parse error because the macro is interpreted as a statement. Workaround: wrap in parentheses.