Create own compiler

R

raja_svks

Hi Group,

I just want to develop a language of my own. Not a big one.. Just I
want to write a line like

printme("Hello World");

I want to create a compiler to compile this and convert into MSIL. As
per CLS, i think we can know what is the format of MSIL. So, if I say,

compileprog.exe mypro.prog

means, it should create mypro.exe. This I should include in any .net
application and use.

How to create a compiler and convert my language to MSIL??

I just want to have a try. So, converting this single line into MSIL is
enough for me...


Regards,
Raja Pandian
 
B

Bruno van Dooren

Hello Raja,

You 'd have to learn Intermediate Language Assembly language first, because
that is the bytecode of managed executables.
What you could do is build a small hello world console application in C#,
and then disassemble it with ildasm.exe
that way you can see how the C# compiler translates your hello world program
into byte code.

That being said, building a compiler is very hard. if you want more
information, you could check out the dotGnu and mono projects on linux, or
rotor on FreeBSD. they are open source C# projects.

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
M

Mattias Sjögren

I just want to have a try. So, converting this single line into MSIL is
enough for me...

Then I suggest you start looking at using the System.Reflection.Emit
namespace. It's powerful enough to handle things like this.


Mattias
 
W

Wiktor Zychla [C# MVP]

How to create a compiler and convert my language to MSIL??
I just want to have a try. So, converting this single line into MSIL is
enough for me...

another option would be to create a compiler that translates your language
to, let's say, C# and then internally calls C# compilers objects to create a
..net executable. there are at least two interesting .net languages known to
me that started this way and the direct msil generation was added much
later.

Wiktor Zychla
 

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