Initial support for the Koka language

This commit is contained in:
Daan 2013-05-11 12:56:27 -07:00
Родитель 7485ce78e2
Коммит b851a1b963
4 изменённых файлов: 119 добавлений и 0 удалений

Просмотреть файл

@ -87,6 +87,7 @@
<Compile Include="Compilation\Languages\JavaScript.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Compilation\Languages\Koka.cs" />
<Compile Include="Compilation\Languages\Php.cs" />
<Compile Include="Compilation\Languages\PowerShell.cs" />
<Compile Include="Compilation\Languages\Typescript.cs" />

Просмотреть файл

@ -22,5 +22,6 @@ namespace ColorCode.Common
public const string Sql = "sql";
public const string VbDotNet = "vb.net";
public const string Xml = "xml";
public const string Koka = "koka";
}
}

Просмотреть файл

@ -0,0 +1,107 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
using System.Collections.Generic;
using ColorCode.Common;
namespace ColorCode.Compilation.Languages
{
public class Koka : ILanguage
{
public string Id
{
get { return LanguageId.Koka; }
}
public string Name
{
get { return "Koka"; }
}
public string CssClassName
{
get { return "koka"; }
}
public string FirstLinePattern
{
get
{
return null;
}
}
public IList<LanguageRule> Rules
{
get
{
return new List<LanguageRule> {
new LanguageRule(
// Handle nested block comments using named balanced groups
@"/\*([^*/]+|/+[^*/]|\*+[^*/])*" +
@"(" +
@"((?<comment>/\*)([^*/]+|/+[^*/]|\*+[^*/])*)+" +
@"((?<-comment>\*/)([^*/]+|/+[^*/]|\*+[^*/])*)+" +
@")*" +
@"(\*+/)",
new Dictionary<int, string>
{
{ 0, ScopeName.Comment },
}),
new LanguageRule(
@"\b(infix|infixr|infixl|type|cotype|rectype|struct|alias|forall|exists|some|interface|instance|with|external|fun|function|val|var|con|if|then|else|elif|match|return|module|import|as|public|private|abstract|yield)\b",
new Dictionary<int, string>
{
{ 1, ScopeName.Keyword }
}),
new LanguageRule(
@"(//.*?)\r?$",
new Dictionary<int, string>
{
{ 1, ScopeName.Comment }
}),
new LanguageRule(
@"'[^\n]*?(?<!\\)'",
new Dictionary<int, string>
{
{ 0, ScopeName.String }
}),
new LanguageRule(
@"(?s)@""(?:""""|.)*?""(?!"")",
new Dictionary<int, string>
{
{ 0, ScopeName.StringCSharpVerbatim }
}),
new LanguageRule(
@"(?s)(""[^\n]*?(?<!\\)"")",
new Dictionary<int, string>
{
{ 0, ScopeName.String }
}),
new LanguageRule(
@"^\s*(\#error|\#line|\#pragma|\#warning|\#!/usr/bin/env\s+koka|\#).*?$",
new Dictionary<int, string>
{
{ 1, ScopeName.PreprocessorKeyword }
}),
};
}
}
public bool HasAlias(string lang)
{
switch (lang.ToLower()) {
case "kk":
case "kki":
return true;
default:
return false;
}
}
public override string ToString()
{
return Name;
}
}
}

Просмотреть файл

@ -40,6 +40,7 @@ namespace ColorCode
Load<PowerShell>();
Load<Typescript>();
Load<FSharp>();
Load<Koka>();
}
/// <summary>
@ -212,6 +213,15 @@ namespace ColorCode
get { return LanguageRepository.FindById(LanguageId.FSharp); }
}
/// <summary>
/// Language support for Koka.
/// </summary>
/// <value>Language support for Koka.</value>
public static ILanguage Koka
{
get { return LanguageRepository.FindById(LanguageId.Koka); }
}
/// <summary>
/// Finds a loaded language by the specified identifier.
/// </summary>