Ejemplo n.º 1
0
        private static void CompileRule(MacroRule rule, StringBuilder regex, IList <string> captures, bool isFirstRule)
        {
            if (!isFirstRule)
            {
                regex.AppendLine();
                regex.AppendLine();
                regex.AppendLine("|");
                regex.AppendLine();
            }

            regex.AppendFormat("(?-xis)(?m)({0})(?x)", rule.Regex);

            int numberOfCaptures = GetNumberOfCaptures(rule.Regex);

            for (int i = 0; i <= numberOfCaptures; i++)
            {
                string scope = null;

                foreach (int captureIndex in rule.Captures.Keys)
                {
                    if (i == captureIndex)
                    {
                        scope = rule.Captures[captureIndex];
                        break;
                    }
                }

                captures.Add(scope);
            }
        }
Ejemplo n.º 2
0
        private static void CompileRule(MacroRule rule, StringBuilder regex, IList<string> captures, bool isFirstRule)
        {
            if (!isFirstRule)
            {
                regex.AppendLine();
                regex.AppendLine();
                regex.AppendLine("|");
                regex.AppendLine();
            }

            regex.AppendFormat("(?-xis)(?m)({0})(?x)", rule.Regex);

            int numberOfCaptures = GetNumberOfCaptures(rule.Regex);

            for (int i = 0; i <= numberOfCaptures; i++)
            {
                string scope = null;

                foreach (int captureIndex in rule.Captures.Keys)
                {
                    if (i == captureIndex)
                    {
                        scope = rule.Captures[captureIndex];
                        break;
                    }
                }

                captures.Add(scope);
            }
        }