I'm working on a mini domain specific language (called say, MyDSL) which
compiles to
(generates) D code and am thinking that it might be nice to be able to embed
MyDSL statements
directly in a D source file in manner similar to string mixins. It's use might
look something like this:
void foo()
{
MyDSLResult res = mixin( mydsl( `some-mydsl-statement-here`);
now_do_something_with( res);
}
There was a question similar to this somewhere around DM newsgroups a while back
(regarding embedding Scheme I think?), but as I recall there wasn't any
definitive
feedback on the idea. Also, being still relatively new to D, there are a
number of possibly
related threads on the NGs that have gone over my head, so please bear with me
if this
has been dealt with before.
My specific question is:
What would be the best way of embedding some DSL code into D source code?
Is there some cool feature of D (that I don't yet know about) that lets you
employ
string mixins for this purpose, or would one need to write a preprocessor to
grok D
source code in order to compile in the embedded DSL code?
The alternative is just to compile/translate MyDSL code into a standalone D
source module
and just run with that .. though the idea of actually embedding directly into D
does
have some real appeal (at least to me).
Hope this makes sense and, as usual, thanks for all help,
-- Justin Johansson