Lately I have been working my way through Ayende’s Building Domain Specific Languages in Boo, it’s a really good read and would recommend it to anyone wanting to put together their own DSL and also to learn about the meta programming that Boo has to offer.
Anyway this afternoon I spent a long time trying to get a macro to work for my DSL using Rhino DSL, in the end I think it was a number of issues, so here is a list of things to check if your macro is not working:
- Make sure that the namespace of where the macro is declared is passed thorugh to the ImplicitBaseClassCompilerStep, this can be done in the constructor, which takes a string array of namespaces.
- When you name the macro it must be in pascal case, I was falling foul because in my DSL I was referring to it as add_foo so named it add_fooMacro, this doesn’t work it must be Add_fooMacro.
- If the macro is declared in a seperate assembly to the rest of your DSL classes you will need to add a reference to the assembly for the Boo compiler.
- This one is a general rule, don’t try to use macros inside macros (using, lock etc…) they ain’t gonna work!
As for the DSL project I’m working on… watch this space :o)