示例#1
0
        public RepeatParser(ParserFactory <TSubValue> part, Quantification quantification)
        {
            factory             = part;
            this.quantification = quantification;

            quantification.Validate();
        }
示例#2
0
文件: P.cs 项目: Jirka-Mayer/Lemon
 /// <summary>
 /// Matches a parser as many times as possible
 /// Takes parameter-less parser builders as the arguments
 /// </summary>
 /// <param name="builder">Parser builder to be repeated</param>
 /// <param name="quantification">How many times to repeat</param>
 /// <typeparam name="TValue">Return type of the whole composite parser</typeparam>
 /// <typeparam name="TSubValue">Return type of the internal parser that's being repeated</typeparam>
 public static ParserFactory <RepeatParser <TValue, TSubValue>, TValue> RepeatB <TValue, TSubValue>(
     Func <ParserFactory <TSubValue> > builder, Quantification quantification
     )
 {
     return(new ParserFactory <RepeatParser <TValue, TSubValue>, TValue>(() => {
         return new RepeatParser <TValue, TSubValue>(builder(), quantification);
     }));
 }
示例#3
0
文件: P.cs 项目: Jirka-Mayer/Lemon
 /// <summary>
 /// Matches a parser as many times as possible
 /// </summary>
 /// <param name="part">Parser to be repeated</param>
 /// <param name="quantification">How many times to repeat</param>
 /// <typeparam name="TValue">Return type of the whole composite parser</typeparam>
 /// <typeparam name="TSubValue">Return type of the internal parser that's being repeated</typeparam>
 public static ParserFactory <RepeatParser <TValue, TSubValue>, TValue> Repeat <TValue, TSubValue>(
     ParserFactory <TSubValue> part, Quantification quantification
     )
 {
     return(new ParserFactory <RepeatParser <TValue, TSubValue>, TValue>(() => {
         return new RepeatParser <TValue, TSubValue>(part, quantification);
     }));
 }
示例#4
0
 public CastParser(ParserFactory <TFrom> parser) : base(parser, Quantification.Exactly(1))
 {
     // default processor
     this.Processor = p => (TTo)this.Matches[0].Value;
 }