471,570 Members | 1,007 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

Create own compiler

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

Feb 6 '06 #1
3 2966
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.
br**********************@hotmail.com
Remove only "_nos_pam"
"raja_svks" <b.***********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
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

Feb 6 '06 #2
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 6 '06 #3
> 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

Feb 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.