Exemplo n.º 1
0
 /// <summary>
 /// The results of the given parser are optional. If the given parser fails, a default value
 /// will be returned.
 /// </summary>
 /// <typeparam name="TInput"></typeparam>
 /// <typeparam name="TOutput"></typeparam>
 /// <param name="p"></param>
 /// <param name="getDefault"></param>
 /// <returns></returns>
 public static IParser <TInput, TOutput> Optional <TInput, TOutput>(this IParser <TInput, TOutput> p, Func <IParseState <TInput>, TOutput> getDefault)
 => ParserMethods <TInput> .Optional(p, getDefault);
Exemplo n.º 2
0
 /// <summary>
 /// The results of the given parser are optional. Returns success with an Option value
 /// which can be used to determine if the parser succeeded.
 /// </summary>
 /// <typeparam name="TInput"></typeparam>
 /// <typeparam name="TOutput"></typeparam>
 /// <param name="p"></param>
 /// <returns></returns>
 public static IParser <TInput, IOption <TOutput> > Optional <TInput, TOutput>(this IParser <TInput, TOutput> p)
 => ParserMethods <TInput> .Optional(p);