Way back when Glop was going to be called GLIC1, it was going to be an extension to C++ with closures and such. I started by trying to write a huge grammar for C++, which I would then extend with my own special rules.
I’ve just implemented a proof-of-concept framework for a very similar idea, which, instead of being thousands of lines of code, is 150. I think I’m going to turn it into a module. It is pcpp, the Perl C(++) Preprocessor. You can define macros in terms of context-free rules (Parse::RecDescent format) and associate metainformation with lexical scopes. You can even make the macro affect elsewhere in the program (for instance, to declare your variables for you at the beginning of the block). It’s very simple, and only knows about blocks (it does nothing at the statement level). Still, I think it’s good enough to do (almost) everything I want to do with it.
I’ll slap on a nice non-hash interface and make the parser handle a few more things, and I’ll have a neato module, which will probably end up getting used in games I write in C++.
1I now find myself amazed that I missed the super-cool name GLOC