Exemple #1
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     foreach (var targetMatch in _target.SimpleMatchings(str, context))
     {
         var nextPos        = str.SubString(targetMatch.Length);
         var conditionMatch = _condition.SimpleMatchings(nextPos, context).FirstOrDefault();
         if (conditionMatch == null)
         {
             yield return(new CompositeMatch(this, str, targetMatch));
         }
     }
 }
Exemple #2
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)
 {
     foreach (var selfMatch in _target.HeadMatches(str, context))
     {
         var next = str.SubString(selfMatch.Length);
         foreach (var nextMatch in SimpleMatchings(next, context))
         {
             var list = new List <RegexMatch>();
             list.Add(selfMatch);
             var composite = (CompositeMatch)nextMatch;
             list.AddRange(composite.Matches);
             yield return(new CompositeMatch(this, str, list.ToArray()));
         }
         yield return(new CompositeMatch(this, str, selfMatch));
     }
 }
Exemple #3
0
        private IEnumerable <RegexMatch> Sm(StringPointer str, MatingContext context, int minCount, int maxCount)
        {
            if (maxCount == 0)
            {
                yield return(new PositionMatch(this, str));

                yield break;
            }
            foreach (var selfMatch in _target.HeadMatches(str, context))
            {
                var next = str.SubString(selfMatch.Length);
                foreach (var targetMatch in Sm(next, context, minCount - 1, maxCount - 1))
                {
                    var composite = targetMatch as CompositeMatch;
                    var list      = new List <RegexMatch>();
                    list.Add(selfMatch);
                    if (composite != null)
                    {
                        list.AddRange(composite.Matches);
                    }
                    else
                    {
                        break;
                    }
                    yield return(new CompositeMatch(this, str, list.ToArray()));
                }
                if (minCount <= 1)
                {
                    yield return(new CompositeMatch(this, str, selfMatch));
                }
            }
            if (minCount <= 0)
            {
                yield return(new PositionMatch(this, str));
            }
        }
Exemple #4
0
 public override IEnumerable <RegexMatch> SimpleMatchings(StringPointer str, MatingContext context)//TODO:fix
 {
     foreach (var selfMatch in _target.HeadMatches(str, context))
     {
         var next = str.SubString(selfMatch.Length);
         foreach (var targetMatch in SimpleMatchings(next, context))
         {
             var composite = targetMatch as CompositeMatch;
             var list      = new List <RegexMatch>();
             list.Add(selfMatch);
             if (composite != null)
             {
                 list.AddRange(composite.Matches);
             }
             else
             {
                 break;
             }
             yield return(new CompositeMatch(this, str, list.ToArray()));
         }
         yield return(new CompositeMatch(this, str, selfMatch));
     }
     yield return(new PositionMatch(this, str));
 }