Making a Language?

Jul 25, 2015 at 3:34 AM
Hello. I have recently become interested in developing a .net language of my own for a few reasons.

1) I would like my own syntax for ascetic reasons.
2) It would make my source initially incompatabile with people who dont have direct access to the lang bindings.
3) Me and a few friends find things about the 2 existing top .net langs(C#/ to be pleasant but want something in between.

I have personally looked through google as well as I can and trust me, Google is NOT my friend it suggests everything BUT what im looking for. I havent found any information well enough on specificly what this is aside to test syntax and people have mentioned in blogs that this is useful for developing a compiler for custom languages So I'd like to ask is this software specificly used for creating a compiler or testing logic or what? If it should be used for creating compilers or even just a simple language parser/wrapper, is the functionality there to basicly "inherit" a language and make modifications from there or would I have to basicly define EVERYTHING from scratch of functionality I want to exist?

Thanks for your time. Also sorry if this has been asked before and/or answered somewhere else, I struggle to find things when I do searches it seems itll just take 1 abstract word and find anything thats most irrelevant to what im looking for anytime I try to do research, and even trying to scan for anything specific to give me clues on here seems to give me things unreleted to answering my query.
Jul 25, 2015 at 7:09 AM
Edited Jul 25, 2015 at 7:20 AM
Making a completely new general-purpose language is not an easy task, don't expect it to succeed.
If you expect to use it for anything serious you're pretty much doomed to fail.

I am not trying to be demeaning, but your posts reads a bit like "I don't like any of the cars currently available, how do I build my own car?".

That said it can be a fun and/or great learning experience. Irony isn't really a tool you'd want for this though, although you could do it it lacks a quite bit of the power/components you'd want to have to do this. I'd recommend you take a look at a full language development suite, I've personally used Spoofax. Here's the accompanying "tutorial" (which takes about a 100 hours to implement a subset of Java which compiles to JVM bytecode). You'll also want to have a good compiler construction book, the dragon book is the canonical example.
Jul 25, 2015 at 8:42 AM
Well thanks to your suggestion I decided to look at what i was searching for differently, and I accidently stumbled across an Open Source C# compiler released by microsoft, and I understand it will take patience but I can modify that to the syntax I prefered :D I meen its not even complex changes I desired just some changing of the symbols and like a few keywords (make it more newb friendly for my buddies who are still learning to code in the first place). Thank you for your time but I think I may have that success yet, if fate permits it xD.
Jul 27, 2015 at 7:56 PM
A while back I wrote about my experience writing a full compiler using Irony:

(The compiler could generate a console EXE which I could step through using the VS debugger)
Jul 29, 2015 at 9:12 AM
Well, as already said, writing a complete, general-purpose language is a huge work that will require a lot of time and effort.

However, Irony can greatly help you for this, and if you want to target the .NET runtime (that is, your compiler will generate IL), it gets even easier. I have done something similar writing a"scripting" language which is a subset of C#. Here is how I worked:
  • Use Irony to parse the source code and generate an AST (since my "scripting language" is close to C#, I used the C# grammar that is provided as a sample in Irony as a start for my grammar, but if you want to define your own syntax/grammar from scratch, you can do it).
  • Once you have your AST, you can traverse it (checking for source code errors that cannot be seen by Irony parser on the way) and build another kind of syntax tree, this one based on the .NET Framework "System.Linq.Expression" namespace . This namespace contains a Framework that can generate IL from a syntax tree, or directly generate a functor/lambda expression corresponding to the tree. Using this facilities, you basically can have the back-end of your compiler targeting .NET IL for (almost) free.
Hope this helps.