Ejemplo n.º 1
0
 /// <summary>
 /// Returns a parser which runs the current parser and applies a selector function.
 /// The selector function receives a <see cref="InputRange{TToken}"/> as its first argument, and the result of the current parser as its second argument.
 /// The <see cref="InputRange{TToken}"/> represents the sequence of input tokens which were consumed by the parser.
 ///
 /// This allows you to write "pattern"-style parsers which match a sequence of tokens and return a view of the part of the input stream which they matched.
 /// </summary>
 /// <param name="selector">
 /// A selector function which computes a result of type <typeparamref name="U"/>.
 /// The arguments of the selector function are a <see cref="InputRange{TToken}"/> containing the sequence of input tokens which were consumed by this parser,
 /// and the result of this parser.
 /// </param>
 /// <typeparam name="U">The result type</typeparam>
 /// <returns>A parser which runs the current parser and applies a selector function.</returns>
 public Parser <TToken, U> MapWithInputRange <U>(InputRangeFunc <TToken, T, U> selector)
 {
     if (selector == null)
     {
         throw new ArgumentNullException(nameof(selector));
     }
     return(new MapWithInputRangeParser <TToken, T, U>(this, selector));
 }
Ejemplo n.º 2
0
 public MapWithInputRangeParser(Parser <TToken, T> parser, InputRangeFunc <TToken, T, U> selector)
 {
     _parser   = parser;
     _selector = selector;
 }