From b51abc4b87ff107445c2c778c3018ea6a245356d Mon Sep 17 00:00:00 2001 From: Daan Date: Sat, 11 May 2013 21:50:05 -0700 Subject: [PATCH] Improved effiency of Koka comment regular expression --- ColorCode/Compilation/Languages/Koka.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ColorCode/Compilation/Languages/Koka.cs b/ColorCode/Compilation/Languages/Koka.cs index f637ec1..96e5b85 100644 --- a/ColorCode/Compilation/Languages/Koka.cs +++ b/ColorCode/Compilation/Languages/Koka.cs @@ -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>\*/)([^*/]+|/+[^*/]|\*+[^*/])*)+" + + @"((?/\*)" + incomment + ")+" + + @"((?<-comment>\*/)" + incomment + ")+" + @")*" + @"(\*+/)", new Dictionary @@ -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 }, }),