DLR stands for Dynamic Language Runtime – a Microsoft’s library which provides services for building dynamic (script) languages such as IronPython and IronRuby. It is employing DynamicMethod technology to produce IL code. The benefit of DynamicMethod is that it may be garbagge collected.
After my first glance at DLR library I have been scared a little bit about it’s design. But, now I came to it again with a strong wish to get deeper.
After some unsuccessfull attempts a I have finaly got it to work. The language is simply arithmetic expressions which then being compiled and evaluated. The source codes and binaries may be downloaded: DLR Calculator.
I am planning to write more detailed article describing this solution soon.
For now consider a list of classes in the order in which they had been implemented.
- 1. MyConsoleHost
- 2. MyLanguageProvider
- 3. MyLEngine
- 4. MyLOptionsParser
- 5. MyLConsoleOptions
- 6. MyLEngineOptions
- 7. MyLLanguageContext
- 8. MyLEngine.PrintIteractiveCodeResult
- 9. Classes in Compiler directory
The solution has the following structure:
- Compiler – a custom classes with parser, lexer, etc. which will generate DLR Ast for compilation
- Hosting – a set of classes for hosting a new language, interaction with console, options, etc
- Runtime – a set of classes using during code execution, such as language context
For testing try following expressions: 1+2, 3+3*2, 1+(2+3*(1+1))+1