Adventures in Compilers - Building on the DLR
So, to get started, head on over to the IronPython download at CodePlex and let's get started. The DLR doesn't compile down to MSIL, instead expression trees. The DLR contains a set of expression trees that allow you to define variable assignments, functions, loops, if/then/else, and much more. After making the DLR expression tree from the aforementioned pieces, the DLR handles the code. This will be covered by Martin Maly in some of his posts.
Building Your Own DLR Language Series
Martin Maly from the Microsoft DLR team has started a series on building languages on top of the DLR. The posts in the series are so far:
- Building a DLR Language - ToyScript
This post covers the basics of the ToyScript sample from the IronPython download. This covers the tokenizer, parser and the Abstract Syntax Tree (AST). This is the starter for the series.
- Building a DLR Language - Trees
This post covers that the ToyScript language generates not MSIL, but instead trees which the DLR then take care of the code generation. This also covers the expressions that the DLR trees support
- Building a DLR Language - Trees 2
This is a follow-up to the previous post and covers the constructs for creating functions and lambdas.
- Building a DLR Language - Dynamic Behaviors
This post covers dynamic behaviors, instead of the previous samples which covered static linked and strongly typed. This sample covers arbitrarily adding two objects.
- Building a DLR Language - Dynamic Behaviors 2
This is a follow-up to the previous post on dynamic behaviors, and this time covers using the ActionExpression. This time he digs into Reflector to show samples of the output. Very cool stuff...
- Building a DLR Language - Dynamic Behaviors 3
In the final post so far in the series, it covers what happens when the DLR encounters a new runtime condition it hasn't seen and doesn't know yet how to handle. These conditions are handled by Rules in the DLR sense.
Tomas Restrepo recently blogged about just that kind of adventure as well with some good posts recently. Here are the ones so far:
- Building On The DLR
This is the first post in the series which gives an introduction to the basics and where to get started.
- DLR Notes 1
This post covers simple things such as declaring global and local functions and variables and the trials and tribulations.
- DLR Notes 2
This post is a rather long post about implementing function calls through Call Actions. This includes such things as call expressions, IDynamicObject and ActionBinders
- DLR Notes 3
This is a follow-up which covers InvokeMember actions which are used to invoke instance members on .NET objects.
This is pretty exciting stuff as it has whetted my appetite for building dynamic languages. My mind is still swimming with the possibilities of this, but to make one of these languages is simpler than ever. Once again, I'll start taking that deep dive after I finish my F# kick, but I still thought I'd start gathering my resources now.
Until next time...