Sign in to follow this  

C# Compilers

This topic is 3882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright. I'm attempting to learn C# and i've been going at it for a few days now. I have previous experience in other programming languages, so I'm probably not going over the top. And I want to make a game suite, just a small one. However, I want to implement a compiler (or many). Are there any free open-source compilers (for any language) written in C#?

Share this post


Link to post
Share on other sites
I was looking at the Coco thing. And I mean it looks cool, but what the hell does it do! Sorry, this might be an easy question for you to answer, but this whole Coco thing is complete jibberish to me. I tried the ICSharpCode compiler and have too been lost for two days, partly because it doesn't even come with the correct dlls...

As for the Mono's compiler, I will try that, but is there a compiler for multiple languages that's written in C#, or is that impossible or is that what the Coco thing is? Might be stupid questions, but then again, this is the "For Beginners" forum after all.

Share this post


Link to post
Share on other sites
Coco is a compiler/parser generator written in (among others) C#. In principle it generates the compiler and parser for your language of choice. Usually you don't want to write them "by hand" because it's a tedious and error-prone procedure, especially for people who are not experienced in the field.

Basically, you feed the generator with the grammar of your language (represented in a special form) and get a parser/compiler for it as output (i.e. the source code for it).

If you really want to write both, parser and compiler from the ground up, be warned that this is a non-trivial task. Considering you haven't mastered C# yet - let alone compiler and language theory - I would strongly recommend against it. Don't be tempted to think that by just looking at the source code of something as complex and sophisticated as an optimising compiler, you learn how to write one.

Writing a compiler can be a fun, educating and challenging journey, but don't underestimate the required effort.

Good luck,
Pat

Share this post


Link to post
Share on other sites
Quote:
Original post by darookie
If you really want to write both, parser and compiler from the ground up, be warned that this is a non-trivial task.
Forget non-trivial -- it's tedious, boring, error prone, and unrewarding.

Share this post


Link to post
Share on other sites
Quote:
Original post by Promit
Forget non-trivial -- it's tedious, boring, error prone, and unrewarding.

I remember it being quite fun for a while, but then again that was 9 years ago[rolleyes].

Share this post


Link to post
Share on other sites
Quote:
Original post by mntlinstituteflr
I tried the ICSharpCode compiler and have too been lost for two days, partly because it doesn't even come with the correct dlls...


huh? There's no such thing as "the ICSharpCode compiler". There's a website called ICSharpCode, but all it has is a bunch of tools for .Net languages, mainly SharpDevelop which is an IDE. What exactly are you looking for?

Share this post


Link to post
Share on other sites
Sorry Scet, yes that's what I meant. I used (or did whatever) the ICSharp tools. And it led to more confusion. Now, I don't know if anybody understands my question clearly. Or maybe I still don't get it. Here' my question:

I want to be able to include a text editor inside of the application I'm making and when you hit compile it compiles the code you have in the text box in the language you selected. Does this make any sence?

Thanks for the help everyone!

Share this post


Link to post
Share on other sites
Is your goal to write a compiler, or just to be able to compile from within your own application rather than from visual studio, or someone else's IDE?

If you don't necessarily want to write your own entire compiler, have a look at This thread... for some C# code that lets you compile other C# code from text into memory entirely within your own app.

The title of that thread is deceptive "easy scripting in .net" - you CAN use the technique for scripting, or you can modify it slightly to output EXE or DLLs to disk.

Share this post


Link to post
Share on other sites
Quote:
Original post by mntlinstituteflr
I want to be able to include a text editor inside of the application I'm making and when you hit compile it compiles the code you have in the text box in the language you selected. Does this make any sence?

Do you want syntax-highlighting, too? If so, you'd best use a component written by someone else, such as CodeHighlighter - saves you a lot of time and (in this case) doesn't cost a dime.
In case you want to compile into IL, have a look at the System.CodeDom.Compiler namespace of the .NET runtime. Support for Visual Basic, C# and javascript comes with the .NET SDK, IIRC. Providers for other languages such as Ruby, Python, Eiffel, Boo and many others that you can easily find using your google-fu are available on the web.

Hope that clears things up,
Pat

Share this post


Link to post
Share on other sites

This topic is 3882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this