Here is a small tutorial on how to write a language binding:
The first step is creating a project type and the compiler binding. For
the compiler, you need to write a MSBuild task for the compiler. Then
you'll need a targets file that can be included by MSBuild and calls
that task.
In the SharpDevelop source code, take a look at
SharpDevelop\src\Libraries\ICSharpCode.Build.Tasks\Project\ILAsm.cs and
SharpDevelop.Build.MSIL.targets
Now the real start: Create a new SharpDevelop AddIn project.
The video at
http://laputa.sharpdevelop.net/WritingASharpDevelopAddInTutorialVideo.aspx
should help you understand the basics. Don't forget to look at the
SharpDevelop\doc\technotes directory (in the SharpDevelop source code
download).
Then you should look at the ILAsmBinding source code (it's the simplest
backend binding possible). When you look at ILAsmBinding.addin, you'll
see the most important things to provide:
1. FileFilter entry. Just copy it from ILAsmBinding and adjust to your
needs.
2. Templates: The XML entry tells SharpDevelop to look for a "Templates"
directory inside the directory containing your AddIn assembly. Just
create such a directory in the project browser and add a .xpt file to
it, then set "Copy to output directory" for the .xpt file to "Always".
For writing the .xpt project template, just use the one from
ILAsmBinding and adjust it to your needs. The important part is the
<LanguageName> property: this must match the language name used in the
next step.
3. Language Binding. Use the <LanguageBinding> codon to register your
language binding with SharpDevelop. Create your own GUID
(Tools > Insert New GUID) and use a new file extension.
For writing the LanguageBinding class: just adapt the
ILAsmLanguageBinding to your needs. The "single file compilation" is not
supported by SharpDevelop 2.0, it'll always use MSBuild. The important
methods left are LoadProject and CreateProject. Both have to return a
new instance of your project class. The project class can be really
simple (again, look at ILAsmProject) if you inherit from MSBuildProject.
Just set the language name; don't forget to call base.Create(info) in
the new project constructor / SetupProject(fileName) in the load project
constructor. In the constructor creating a new project, you have to use
"imports.Add()" to add a reference to your MSBuild target file. If you
put your targets file in your AddIn's directory, you can create your own
MSBuild property like this:
static bool initialized = false;
static void Init()
{
if (!initialized) {
initialized = true;
MSBuildEngine.CompileTaskNames.Add("nameOfMyMSBuildCompilerTask"); //
makes SharpDevelop show the "Compiling ProjectName..."-line when
compiling your projects
MSBuildEngine.MSBuildProperties.Add("MyLanguageBinPath",
Path.GetDirectoryName(typeof(MyProject).Assembly.Location));
}
}
Make sure you call Init() in both constructors of your project class.
4. ILAsmBinding.addin also contains the project options section. The
dialog panels reference panels in the main SharpDevelop code that can be
used for all (.NET) languages. If you use them, you need a "<Import
assembly = ":ICSharpCode.SharpDevelop"/>" entry in your <Runtime> section.
5. Syntax mode for the text editor should be compiled as embedded
resource and can be loaded using the <SyntaxMode> codon. You don't need
this at the beginning.
This is everything you need for very simple integration of a language.
The next step after this is providing a parser for the language. That is
a bit complicated (especially if you cannot use the parser from the
IronPython compiler and have to write your own), but it will enable
folding and the class browser (both the "Classes" pad and the combo
boxes above the code editor).