Evolution of procedural macros

Many thanks for this answer and your work on syntax extension and so on.

I better understand now, macros will stay context-free and you propose a mechanism to “patch” the Rust compiler for context-dependant stuff. I read the tutorial, as I understand it I can extend the Rust compiler with my own feature. My question is:

  • How does it compose? I could want to use a parser generator along with the EDSL constraint modelling language in the same crate.

Also, I have the feeling that for syntax extension it is a bit hardest than procedural macros. Say that I add a new construct inside the language, I can only handle this before the parsing (otherwise a parse error will occur). However it means that I need to parse regular Rust code too. Maybe we could overcome this problem by allowing a procedural macro to return arbritrary string data along with the Rust AST so it can be processed later with the custom compiler API. I do not really know but I think what you propose is better suited for context-dependant AST transformation rather than for syntax extension.