Improved effiency of Koka comment regular expression

This commit is contained in:
Daan 2013-05-11 21:50:05 -07:00
Родитель 689d5989a1
Коммит b51abc4b87
1 изменённых файлов: 7 добавлений и 5 удалений

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

@ -30,6 +30,8 @@ namespace ColorCode.Compilation.Languages
}
}
private const string incomment = @"([^*/]|/+[^*/]|\*+[^*/])*";
private const string plainKeywords = @"infix|infixr|infixl|type|cotype|rectype|struct|alias|interface|instance|external|fun|function|val|var|con|module|import|as|public|private|abstract|yield";
private const string controlKeywords = @"if|then|else|elif|match|return";
private const string typeKeywords = @"forall|exists|some|with";
@ -53,10 +55,10 @@ namespace ColorCode.Compilation.Languages
// Nested block comments
new LanguageRule(
// Handle nested block comments using named balanced groups
@"/\*([^*/]+|/+[^*/]|\*+[^*/])*" +
@"/\*" + incomment +
@"(" +
@"((?<comment>/\*)([^*/]+|/+[^*/]|\*+[^*/])*)+" +
@"((?<-comment>\*/)([^*/]+|/+[^*/]|\*+[^*/])*)+" +
@"((?<comment>/\*)" + incomment + ")+" +
@"((?<-comment>\*/)" + incomment + ")+" +
@")*" +
@"(\*+/)",
new Dictionary<int, string>
@ -104,11 +106,11 @@ namespace ColorCode.Compilation.Languages
{ 4, ScopeName.Keyword},
{ 5, ScopeName.TypeVariable },
{ 6, ScopeName.StringEscape }, // use stringescape (gray) for type parameters
{ 6, ScopeName.PlainText },
{ 7, ScopeName.Keyword },
{ 8, ScopeName.TypeVariable },
{ 9, ScopeName.StringEscape },
{ 9, ScopeName.PlainText },
{ 10, ScopeName.Keyword },
{ 11, ScopeName.TypeVariable },
}),