Пример #1
0
 public static Generator <T> Return(T val)
 {
     return(Generator <T> .Wrap(delegate(Context ctx)
     {
         return CovariantTuple <T, Context> .Create(val, ctx);
     }));
 }
Пример #2
0
 public static Generator <T> SetContext(Generator <T> gen, Context localctx)
 {
     return(Generator <T> .Wrap(delegate(Context ctx)
     {
         var ret = gen.Run(localctx);
         return CovariantTuple <T, Context> .Create(ret.Item1, ctx);
     }));
 }
Пример #3
0
 public static Generator <String> Template(FormattableString formattable)
 {
     return(Wrap(delegate(Context ctx)
     {
         var provider = new GFormatProvider(ctx);
         var res = formattable.ToString(provider);
         return CovariantTuple <String, Context> .Create(res, ctx);
     }));
 }
Пример #4
0
        public static Generator <string> operator +(Generator <T> a, Generator <T> b)
        {
            return(Wrap(delegate(Context ctx)
            {
                StringBuilder o = new StringBuilder();

                var Res1 = a.f(ctx);
                o.Append(Res1.Item1);

                var Res2 = b.f(Res1.Item2);
                o.Append(Res2.Item1);

                return CovariantTuple <String, Context> .Create(o.ToString(), Res2.Item2);
            }));
        }