예제 #1
0
 private void DoRegexMatch(string text, Language language, List<StyleRun> runs)
 {
     if (language.Regex != null)
     {
         MatchCollection matches = language.Regex.Matches(text);
         foreach (Match match in matches)
         {
             GroupCollection groups = match.Groups;
             for (int i = 1; i <= language.ElementCount; ++i)
             {
                 Group g = groups[i];
                 if (g.Success)
                 {
                     string type = language.ElementName(i);
                     if (i == 1 && language.StylesWhitespace)
                         DoMatchWhitespace(text, g, language, runs);
                     else
                         if (g.Length > 0)
                             runs.Add(new StyleRun(g.Index, g.Length, type));
                         else if (type != "ParseError")
                             Log.WriteLine(TraceLevel.Error, "Styler", "{0} matched zero characters", type);
                     break;
                 }
             }
         }
     }
 }