예제 #1
0
파일: Group.cs 프로젝트: trimonovds/Rxx
        /// <summary>
        /// Matches zero or more values in between the specified <paramref name="open"/> and <paramref name="close"/> parsers.
        /// </summary>
        /// <typeparam name="TSource">The type of the source elements.</typeparam>
        /// <typeparam name="TOpen">The type of the elements that are generated from parsing the <paramref name="open"/> elements.</typeparam>
        /// <typeparam name="TClose">The type of the elements that are generated from parsing the <paramref name="close"/> elements.</typeparam>
        /// <param name="open">The parser after which the group begins.</param>
        /// <param name="close">The parser at which the group ends.</param>
        /// <returns>A parser with a grammar that matches the <paramref name="open"/> parser, followed by everything up to the first
        /// match of the <paramref name="close"/> parser, yielding the results in between.</returns>
        public static IObservableParser <TSource, IObservable <TSource> > Group <TSource, TOpen, TClose>(
            this IObservableParser <TSource, TOpen> open,
            IObservableParser <TSource, TClose> close)
        {
            Contract.Requires(open != null);
            Contract.Requires(close != null);
            Contract.Ensures(Contract.Result <IObservableParser <TSource, IObservable <TSource> > >() != null);

            return(open.Group(open.Next.Not(close).NoneOrMore(), close));
        }