How to write a compiler for .NET?

Z

Zingam

Since I'm interested in formal languages I've decided to write a simple
compiler for .NET for my studies.
I would like to be able to use the .NET class library too (especially
windows forms).

Could you give me an idea where should I start from? Probably I have to
qualify myself as a beginner, so too advanced stuff might be not clear
to me yet. What would you recommend in that case?

Thank you!
 
G

Gabriele G. Ponti

Zingam,

Thomas and Jay gave you reference to good material, so you want to check
those out to begin with. I am working on a compiler targeting the .NET
Framework too, and if you already have some experience with writing
compilers you shouldn't have too many problems. The MSIL is very powerful
and way easier to target than a regular CPU.

I would recommend you to read John Gough "Compiling for the .NET Common
Language Runtime (CLR)"
(http://www.phptr.com/browse/product.asp?product_id={1590B1B8-35AB-484B-B231
-6D40E8D2A60D}), it's a little too much academic here and there but it was a
great source of information. I would also recommend you to read Jason Bock
"CIL Programming: Under the Hood of .NET"
(http://www.apress.com/book/bookDisplay.html?bID=88) if you are interested
in the results produced by different compilers (mainly C# and VB.NET), which
can be a good source of tips.

Don't forget the good old ILDASM (part of the .NET Framework SDK), and Lutz
Roeder "Reflector for .NET" (http://www.aisto.com/roeder/dotnet/). Reverse
engineering is very useful when you are not sure how to implement a
particular feature of your language.

HTH,

Gabriele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top