AddMatch() private method

private AddMatch ( int cap, int start, int len ) : void
cap int
start int
len int
return void
Example #1
0
        // Called by Go() to capture a subexpression. Note that the
        // capnum used here has already been mapped to a non-sparse
        // index (by the code generator RegexWriter).
        //| <include file='doc\RegexRunner.uex' path='docs/doc[@for="RegexRunner.Capture"]/*' />
        protected void Capture(int capnum, int start, int end)
        {
            if (end < start)
            {
                int T;

                T     = end;
                end   = start;
                start = T;
            }

            Crawl(capnum);
            runmatch.AddMatch(capnum, start, end - start);
        }
Example #2
0
 /// <summary>
 /// Searches the specified input string for the first occurrence of the specified regular expression.
 /// </summary>
 /// <param name="input">The input string to match at</param>
 /// <param name="beginning">The place to start matching</param>
 ///<param name="length">NOT YET USED</param>
 /// <returns>The Match resulting from the input against the compiled pattern</returns>
 internal Match Match(string input, int beginning, int length)
 {            
     //Sanity checks
     if(beginning < 0 || beginning > input.Length) throw new ArgumentException("beginning");
     //Set timing flag
     //If the RegexOption is set OR the timed flag passed
     this.timed = (this.Options & RegexOptions.Timed) == RegexOptions.Timed;
     //Attempt a match
     Match result = RegularExpressions.Match.Empty;            
     if (IsMatch(input, beginning))
     {
         result = new Match(this, matchCount, input, start0, end0 - start0, beginning);
         //Must call AddMatch to ensure the start and ends are allocated to result.groups[i].caps
         for(int i = 0; i < matchCount; ++i)
         {
             int start = GroupStart(i), end = GroupEnd(i), len = end - start;
             result.AddMatch(i, start, len);
         }
         //Clean up the result using the members calculated when AddMatch was called
         result._index = result._matches[0][0];
         result._length = result._matches[0][1];                            
         result._capcount = result._matchcount[0];
         //Set the position of the result which is the end of the first subexpression
         //subsequent matches will proceed from this index
         result._textpos = end0;    
     }
     return result;
 }
Example #3
0
 /// <summary>
 /// Transfers a Capture to a Match
 /// </summary>
 /// <param name="match"></param>
 /// <param name="capnum"></param>
 /// <param name="uncapnum"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 internal void TransferCapture(Match match, int capnum, int uncapnum, int start, int end)
 {
     if (end < start)
     {
         int numx = end;
         end = start;
         start = numx;
     }
     int num = match.MatchIndex(uncapnum);
     int num2 = match.MatchLength(uncapnum);
     if (start >= num2)
     {
         end = start;
         start = num2;
     }
     else if (end <= num)
     {
         start = num;
     }
     else
     {
         if (end > num2)
         {
             end = num2;
         }
         if (num > start)
         {
             start = num;
         }
     }
     //this.Crawl(uncapnum);
     match.BalanceMatch(uncapnum);
     if (capnum != -1)
     {
         //this.Crawl(capnum);
         match.AddMatch(capnum, start, end - start);
     }
 }
Example #4
0
 /// <summary>
 /// Adds a match to a Match
 /// </summary>
 /// <param name="capnum"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 internal void Capture(Match match, int capnum, int start, int end)
 {
     if (end < start)
     {
         int num = end;
         end = start;
         start = num;
     }
     //this.Crawl(capnum);
     match.AddMatch(capnum, start, end - start);
 }