Exemple #1
0
 /// <summary> Matches this pattern for at least min times
 /// and at most max times.
 /// Return the total match length.
 /// </summary>
 /// <param name="min">the minimal number of times to match.
 /// </param>
 /// <param name="max">the maximal number of times to match.
 /// </param>
 /// <returns> the new Pattern object.
 /// </returns>
 public Pattern Some(int min, int max)
 {
     if (min < 0 || max < 0 || min > max)
     {
         throw new System.ArgumentException();
     }
     if (max == 0)
     {
         return(Patterns.Always());
     }
     return(new SomeMinPattern(min, this, max));
 }
Exemple #2
0
 /// <summary> Matches the input against this pattern for n times.</summary>
 /// <param name="n">the number of times to match.
 /// </param>
 /// <returns> the new Pattern object.
 /// </returns>
 public Pattern Repeat(int n)
 {
     if (n == 0)
     {
         return(Patterns.Always());
     }
     if (n == 1)
     {
         return(this);
     }
     return(new RepeatPattern(n, this));
 }
Exemple #3
0
 /// <summary> Matches this pattern for up to max times.
 /// Return the total match length.
 /// </summary>
 /// <param name="max">the maximal number of times to match.
 /// </param>
 /// <returns> the new Pattern object.
 /// </returns>
 public Pattern Some(int max)
 {
     if (max < 0)
     {
         throw new System.ArgumentException("max<0");
     }
     if (max == 0)
     {
         return(Patterns.Always());
     }
     return(new SomePattern(max, this));
 }