How to best implement a DSL?
Robert M. Münch
robert.muench at saphirion.com
Sat Jul 28 16:53:42 UTC 2018
On 2018-07-28 15:43:12 +0000, rikki cattermole said:
>> * Could I somehow call an external program during compilation which
>> gets the DSL block as input and returns D code?
>
> No. But you can pre-process.
Yes, sure, but this complicates the build-system. I preferr to use as
few parts as possible.
>> * Is it possible to populate such a dictonary via CTFE?
>
> Sort of, it can be registered, but the actual execution of the
> registration occurs at runtime.
Yes, no problem. How is this done?
> But you're slightly over thinking this. Write an interpreter and a
> parser. The fact that the parser can work at CTFE is irrelevant and
> almost a footnote on the page of details ;).
Not really if you think about deployment. I want to create a single
executable, no external files. So I somehow have to get the scripts
included or use the compiler as generator. The main use-case is, that I
want to use a very declarative approach for some UI parts.
> If you want to be clever you could generate D code and mix it in based
> upon what was parsed. But you'd still want that dictionary.
Yes, mixing in generate D code was the idea. However, I think a good
included infrastructure that support creating DSLs might help a lot to
simplify this.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20180728/52b8078b/attachment.html>
More information about the Digitalmars-d-learn
mailing list