Since this is my first real compiler, I wanted to start off with a simple language. So, I created a simple esoteric programming language (its not turing complete though) that was inspired by Fortran and BrainF*ck.
Lets take the following VB:
Public Class App
Public Shared Sub Main()
Dim x As Integer = 5
Dim y As Integer() = {1,2,3,4,...} '1 through 10
For Each num As Integer in y
Dim result As Integer = 2+(x*num)
Console.Writeline(result.ToString())
Next
End Sub
End Class
If I wanted to write that in Mizu, it would go something like this:
x`5|y`[1..11]|?z:2+(x*y)|.z
Yes, I know this language is not practical, but the point is... I made a compiler. The compiler even emits debugging information so you can debug your exe via VS:

Now, how I generate IL and the executable is simple. I use the System.Reflection.Emit namespace.
I used a tool called TinyPG to generate my scanner/parser combo.
I used the tool called Peverify (included with VS) to verify my IL.
Let me know what you think or if you have any questions. You can find the source code here. Oh and I plan on making this into a tutorial. More information is on the README.
This post has been edited by Amrykid: 05 September 2011 - 01:01 PM

New Topic/Question
Reply



MultiQuote








|