On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote:
I like the idea of DSL which are transpiled into the target
language that gets compiled or are interpreted at run-time.
Since D is compiled, I would like to transpile the DSL to D at
compile-time.
The idea is, that I can write a string (or maybe even a scope
block?) in my DSL and use a CTFE grammer to transpile the code.
Does anybody has any experience with such an approach? Are the
CTFE facilities overall sufficient to implement something like
this? Or is there a much better approach?
Sure, there is no problem. PEG actually has several grammars.
CTFE is CT, and CTFE is in general RT(as long as it depends on no
RT inputs). That is CTFE is CT RTFE where runtime functions are
executed at compile time when the inputs are CT.
The issues is that you get no debugger support to help you and so
it can be a real pain for complex languages.