Example #1
0
 /// <summary>
 /// Given a Match, emits into the StringBuilder the evaluated
 /// substitution pattern.
 /// </summary>
 private void ReplacementImpl(StringBuilder sb, Match match)
 {
     for (int i = 0; i < _rules.Count; i++)
     {
         int r = _rules[i];
         if (r >= 0)   // string lookup
             sb.Append(_strings[r]);
         else if (r < -Specials) // group lookup
             sb.Append(match.GroupToStringImpl(-Specials - 1 - r));
         else
         {
             switch (-Specials - 1 - r)
             { // special insertion patterns
                 case LeftPortion:
                     sb.Append(match.GetLeftSubstring());
                     break;
                 case RightPortion:
                     sb.Append(match.GetRightSubstring());
                     break;
                 case LastGroup:
                     sb.Append(match.LastGroupToStringImpl());
                     break;
                 case WholeString:
                     sb.Append(match.GetOriginalString());
                     break;
             }
         }
     }
 }
Example #2
0
 /// <summary>
 /// Given a Match, emits into the List<String> the evaluated
 /// Right-to-Left substitution pattern.
 /// </summary>
 private void ReplacementImplRTL(List<String> al, Match match)
 {
     for (int i = _rules.Count - 1; i >= 0; i--)
     {
         int r = _rules[i];
         if (r >= 0)  // string lookup
             al.Add(_strings[r]);
         else if (r < -Specials) // group lookup
             al.Add(match.GroupToStringImpl(-Specials - 1 - r));
         else
         {
             switch (-Specials - 1 - r)
             { // special insertion patterns
                 case LeftPortion:
                     al.Add(match.GetLeftSubstring());
                     break;
                 case RightPortion:
                     al.Add(match.GetRightSubstring());
                     break;
                 case LastGroup:
                     al.Add(match.LastGroupToStringImpl());
                     break;
                 case WholeString:
                     al.Add(match.GetOriginalString());
                     break;
             }
         }
     }
 }
        /*
         *
         * Given a Match, emits into the StringBuilder the evaluated
         * substitution pattern.
         */
        private void ReplacementImpl(StringBuilder sb, Match match)
        {
            for (int i = 0; i < _rules.Count; i++)
            {
                int r = (int)_rules[i];
                if (r >= 0)
                {
                    sb.Append((string)_strings[r]);
                }
                else if (r < -Specials)
                {
                    sb.Append(match.GroupToStringImpl(-Specials - 1 - r));
                }
                else
                {
                    switch (-Specials - 1 - r)
                    {
                    case LeftPortion:
                        sb.Append(match.GetLeftSubstring());
                        break;

                    case RightPortion:
                        sb.Append(match.GetRightSubstring());
                        break;

                    case LastGroup:
                        sb.Append(match.LastGroupToStringImpl());
                        break;

                    case WholeString:
                        sb.Append(match.GetOriginalString());
                        break;
                    }
                }
            }
        }
        private void ReplacementImplRTL(List <string> al, Match match)
        {
            for (int i = this._rules.Count - 1; i >= 0; i--)
            {
                int num2 = this._rules[i];
                if (num2 >= 0)
                {
                    al.Add(this._strings[num2]);
                }
                else if (num2 < -4)
                {
                    al.Add(match.GroupToStringImpl(-5 - num2));
                }
                else
                {
                    switch ((-5 - num2))
                    {
                    case -4:
                        al.Add(match.GetOriginalString());
                        break;

                    case -3:
                        al.Add(match.LastGroupToStringImpl());
                        break;

                    case -2:
                        al.Add(match.GetRightSubstring());
                        break;

                    case -1:
                        al.Add(match.GetLeftSubstring());
                        break;
                    }
                }
            }
        }
        private void ReplacementImpl(StringBuilder sb, Match match)
        {
            for (int i = 0; i < this._rules.Count; i++)
            {
                int num2 = this._rules[i];
                if (num2 >= 0)
                {
                    sb.Append(this._strings[num2]);
                }
                else if (num2 < -4)
                {
                    sb.Append(match.GroupToStringImpl(-5 - num2));
                }
                else
                {
                    switch ((-5 - num2))
                    {
                    case -4:
                        sb.Append(match.GetOriginalString());
                        break;

                    case -3:
                        sb.Append(match.LastGroupToStringImpl());
                        break;

                    case -2:
                        sb.Append(match.GetRightSubstring());
                        break;

                    case -1:
                        sb.Append(match.GetLeftSubstring());
                        break;
                    }
                }
            }
        }
        private void ReplacementImplRTL(List<string> al, Match match)
        {
            for (int i = this._rules.Count - 1; i >= 0; i--)
            {
                int num2 = this._rules[i];
                if (num2 >= 0)
                {
                    al.Add(this._strings[num2]);
                }
                else if (num2 < -4)
                {
                    al.Add(match.GroupToStringImpl(-5 - num2));
                }
                else
                {
                    switch ((-5 - num2))
                    {
                        case -4:
                            al.Add(match.GetOriginalString());
                            break;

                        case -3:
                            al.Add(match.LastGroupToStringImpl());
                            break;

                        case -2:
                            al.Add(match.GetRightSubstring());
                            break;

                        case -1:
                            al.Add(match.GetLeftSubstring());
                            break;
                    }
                }
            }
        }
        private void ReplacementImpl(StringBuilder sb, Match match)
        {
            for (int i = 0; i < this._rules.Count; i++)
            {
                int num2 = this._rules[i];
                if (num2 >= 0)
                {
                    sb.Append(this._strings[num2]);
                }
                else if (num2 < -4)
                {
                    sb.Append(match.GroupToStringImpl(-5 - num2));
                }
                else
                {
                    switch ((-5 - num2))
                    {
                        case -4:
                            sb.Append(match.GetOriginalString());
                            break;

                        case -3:
                            sb.Append(match.LastGroupToStringImpl());
                            break;

                        case -2:
                            sb.Append(match.GetRightSubstring());
                            break;

                        case -1:
                            sb.Append(match.GetLeftSubstring());
                            break;
                    }
                }
            }
        }