|
I'm currently reading a book to learn about creating a compiler and/or interpreter for your own language (Writing Compiler and Interpreters by Ronald Mak). I've been learning a lot from this book, however the author uses Java to create the entire framework and the compiler emits Java byte code.
As I've been working though the samples I'm porting the Java code to VB.NET since I use VB.NET for all my other programming. I haven't reached the chapter on building the compiler but when I do I would rather have the compiler emit CLI code just as Visual Studio does when you build a .NET application.
Unfortunately I don't know CLI code but this seems like a good time to learn. I already downloaded the ECMA standard but I learn must better and quicker from books that give concrete examples and implementations.
Does anyone have any recommendations for any books that teaches about CLI code and preferably have example code that I can work with as I'm reading?
As a side note (since this has been brought up to me by other on numerous occasions) I'm not creating this custom language expecting it to take off and be the next big thing. I'm doing it for two reasons: 1) Academic purposes; 2) My company uses specialized measurement tools that produce large data sets that is hard to program for just because unique nature of the data. So I'm looking to create a domain specific language to handle some manipulation of the data.
Thanks in advance for any recommendations.
|
|
|
|
|
DisIsHoody wrote: My company uses specialized measurement tools that produce large data sets that is hard to program for just because unique nature of the data. Data is data, and can be handled by any language that currently exists. Your time would probably be better spent writing the code to do it, particularly as VB.NET emits CLI code, which is what you are hoping to do with your new language, so the end result will be the same.
That being said, you may like to look at some of these links[^].
|
|
|
|
|
As a starting point, what you are looking at is commonly known as a Domain Specific Language. I'd suggest that you start by having a look at this[^] article. Read it through a few times to make sure you fully understand it.
|
|
|
|
|
Mak generates "intermediate code" from the scanning / parsing phases which he eventually interprets or compiles.
For the intermediate code phase, I would suggest you swap in the .Net framework's System.CodeDom classes for building language independent code graphs and ultimately generating assemblies (instead of bothering with MSIL).
|
|
|
|
|
DisIsHoody wrote: I'm currently reading a book to learn about creating a compiler and/or interpreter for your own language (Writing Compiler and Interpreters by Ronald Mak).
Presumably you already know about the Dragon book (google 'compilers dragon book')
As for CLI examples you can look to the Mono project and the Mono compiler
http://www.mono-project.com/CSharp_Compiler[^]
Presumably the book you have also discusses Yacc/Lex which might be more useful if you are creating multiple languages.
|
|
|
|
|
@Richard: I've actually already written software to handle the data. I was going to use this data for this academic project just so I'm working with something real instead of just working with an abstract idea.
@Gerry: I've read about that feature, however I wanted to work with MSIL directly simply because I feel it will give me a deeper understand of the .NET Framework and hopefully, in the long run, help me written better and more efficient code.
@jschell: I was torn between getting the book I did and the Dragon book, but I decided to go with this book first and leave the Dragon book for second. The Dragon book seemed to deal mostly with theory, whereas this book doesn't go so much into theory but gives you actually code to demonstrate how to accomplish the different items. I tend to learn better with actually examples and exercises instead of theory and pseudo-code, however I plan on reading the Dragon book once I finish this one.
In the end I'm looking for a book that will work through MSIL similar to how this book does it. Each chapter building on the previous ones with actually code examples that write MSIL that in the end will lead to a fully functioning program; for me this is the best way to learn.
|
|
|
|