Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi! I want to create my own programming language based on c#.
Does anyone know how can I do it?
I searched on google and I found nothing...
I want my own language to support:
Syntax Highlight, Intellisense and to be compiled to CLR and to support all .net features and to work in Visual Studio 2010.

Thanks in advance!
Posted
Updated 3-Jan-16 4:05am
v2

For the compiler: as the language you want to create would be based on C#, the easiest way to create it might be to compile your language into C#, and compile the C# into an executable. To compile C# code to an executable, take a look here:
How to programmatically compile code using C# compiler[^]

For the Visual Studio support: you'll have to write a Visual Studio extension, which would take care of the syntax highlighting and such. You can start here:
Building and publishing an extension for Visual Studio 2010 - The Visual Studio Blog - Site Home - MSDN Blogs[^]
(Examples in this blog posts are in VB.NET, but it shouldn't be too hard to port them to C#).

Good luck!
 
Share this answer
 
Comments
Abhinav S 3-Jan-16 10:23am    
5!
Sergey Alexandrovich Kryukov 3-Jan-16 11:57am    
Sorry, but, well, this is just not serious. The .NET language is only a real .NET language when it compiles into CIL. And this is not too hard to achieve, as soon as language scanning, parsing, etc. is implemented. Please see Solution 3.
—SA
There is a read on Domain Specific Langauges here[^]. Maybe it can help you.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Jan-16 11:59am    
Sorry, this answer is not quite on the topic of the question. The article does not really covers the topic; and the language the inquirer wants to develop is universal, not domain-specific.

Please see Solution 3.

—SA
Unfortunately, both Solution 1 or 2 are off-topic. They don't tell you a word on how build your own language with the "real" compiler. You need to compile from your language to CIL, and nothing else. Compilation to C#, being quite possible, will be, first of all, inefficient (extra compilation step will eat up build time) and inflexible. You really need to compile into CIL.

And this is not too hard to do if you use CodeDOM. You can compile your language into CodeDOM tree. This is how: Using the CodeDOM[^].

See also: How to: Create a Class Using CodeDOM[^].

Ideally, you should create your own code provided for your language in the form of CodeDomProvider. This way, you can extend CodeDOM to use your language. Note that this is not the same as compilation of your language to CIL. Please see: CodeDomProvider Class (System.CodeDom.Compiler)[^].

For deeper analysis of this problem, please see this CodeProject article: Creating a CodeDOM: Modeling the Semantics of Code (Part 2)[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900