C Compiler Using C#3.0
-
Hi.......... I want to develop a C Compiler using C#3.0 So is it possible??? How should i go for this????
-
Hi.......... I want to develop a C Compiler using C#3.0 So is it possible??? How should i go for this????
Take a class on writing compilers. I assume they still teach this in computer science courses...
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Hi.......... I want to develop a C Compiler using C#3.0 So is it possible??? How should i go for this????
Writing a C compiler is not a simple piece of work: it can be done in C#, and the actual lexical / parser / code generator design is well established. But what it won't let you do is run a program - to do that, you will need a library of back up stuff: Add, subtrcat, multiply, divide, write a character, etc., etc. It's a big job, probably a couple of man-years, but if you want to try, give google a shot with "how do I write a c compiler" and you will get thousands of hits!
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
-
Writing a C compiler is not a simple piece of work: it can be done in C#, and the actual lexical / parser / code generator design is well established. But what it won't let you do is run a program - to do that, you will need a library of back up stuff: Add, subtrcat, multiply, divide, write a character, etc., etc. It's a big job, probably a couple of man-years, but if you want to try, give google a shot with "how do I write a c compiler" and you will get thousands of hits!
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
Thanks for ur reply...But i m not getting what u r trying to tell me...can u please elaborate what u r trying to say? Thank You
-
Thanks for ur reply...But i m not getting what u r trying to tell me...can u please elaborate what u r trying to say? Thank You
Writing a C compiler is not a simple piece of work. You also need to write a large amount of background functions that the application written in C and compiled by your compiler need to work. For example, at the most basic, you must provide a function to write a character on a screen. Then to write a string. Then to cope with all the parameters of the "printf" function. And to add two ints. And to add two floats. and to subtract two ints. etc. Actually parsing the input is relatively simple, as is code generation, but I think you will have a lot to do to get a C program to run as output by your compiler. Google can help you if you do decide to do it: try to search for "How do I write a C compiler" and it will give you a lot of information.
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
-
Writing a C compiler is not a simple piece of work. You also need to write a large amount of background functions that the application written in C and compiled by your compiler need to work. For example, at the most basic, you must provide a function to write a character on a screen. Then to write a string. Then to cope with all the parameters of the "printf" function. And to add two ints. And to add two floats. and to subtract two ints. etc. Actually parsing the input is relatively simple, as is code generation, but I think you will have a lot to do to get a C program to run as output by your compiler. Google can help you if you do decide to do it: try to search for "How do I write a C compiler" and it will give you a lot of information.
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
I guess an easier route would actually be to create an intermediate compiler which creates IL (which is effectively what MS did). I would imagine that converting the parsed code into machine code would be something of an arduous task but creating IL would appear to be a translation between languages - parse the input code, create a parse tree, manipulate this tree so you have a syntax tree and then perform a similar process in reverse to generate the IL. By concentrating on a limited set of primitive types and operands you could probably get something basic up and running within a few days.
Sarchasm : The gulf between the author of sarcastic wit and the person who doesn't get it.
-
I guess an easier route would actually be to create an intermediate compiler which creates IL (which is effectively what MS did). I would imagine that converting the parsed code into machine code would be something of an arduous task but creating IL would appear to be a translation between languages - parse the input code, create a parse tree, manipulate this tree so you have a syntax tree and then perform a similar process in reverse to generate the IL. By concentrating on a limited set of primitive types and operands you could probably get something basic up and running within a few days.
Sarchasm : The gulf between the author of sarcastic wit and the person who doesn't get it.
That certainly gets rid of a lot of work. The next problem: how do you use .NET classes with an non-OOP language like C? :-D
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
-
That certainly gets rid of a lot of work. The next problem: how do you use .NET classes with an non-OOP language like C? :-D
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
My bad - I read the question as 'I want to write a c# compiler'... My way was definitely easier! :)
Sarchasm : The gulf between the author of sarcastic wit and the person who doesn't get it.
-
That certainly gets rid of a lot of work. The next problem: how do you use .NET classes with an non-OOP language like C? :-D
If Barbie is so popular, why do you have to buy her friends? Eagles may soar, but weasels don't get sucked into jet engines. If at first you don't succeed, destroy all evidence that you tried.
OriginalGriff wrote:
The next problem: how do you use .NET classes with an non-OOP language like C?
That won't be a problem. How F# is using .NET framework classes? How C++/CLI supports non-OO programing? But it's more work for compiler writers. :)
Best wishes, Navaneeth