.NET DSL implementation.

I am implementing a small DSL on top of .NET (4.0) and I am currently using expression trees to turn DSLs into executable chunks.

DSL is predefined because we are implementing support for the legacy file format.

Are expression trees the most appropriate tool for the job?

+3


source to share


2 answers


Expression trees are useless if you want to generate new types. And for most typical DSLs, you need to create types. So a good old System.Reflection.Emit

one is probably the best choice.



+5


source


You can take a look at Boo and more specifically at Rhino.DSL , which is built on top of it. To get an idea of ​​what Boo brings to the table, Ayende's posts are a great starter.

Boo is described by its receptors as:

a new object-oriented statically typed programming language for a common language infrastructure with python-inspired syntax and a particular emphasis on language and compiler extensibility.

Basically, this is an alternative to C #: also compiled, but much more flexible so that you can dynamically tune new language constructs. Expression trees are only part of what is related.



By placing Boo somewhere in your pipeline, as Rhino.DSL does, you expose a lot of versatility that doesn't even need a bloated or high performance hang (it's still compiled by the bytecode that runs).

If you look at unit tests on Rhino.DSL , you get a quick idea of ​​what is possible.

One note: all the repositories mentioned are currently inactive (there has been no activity for the last year), but IMHO that does not devalue their practical use.

Hope this helps you.

+1


source







All Articles