Ejemplo n.º 1
0
 internal void Run()
 {
     try
     {
         var(filter, sourceInformation) = new Parser().Parse(_program);
         IMashStack stack  = _options.Debug ? new DebugMashStack() : DefaultMashStack.Instance;
         var        inputs = _input.AsMultipleJson();
         if (_options.Slurp)
         {
             inputs = Json.Array(inputs).AsEnumerable();
         }
         var(results, context) = new Mashers.JsonMasher().Mash(
             inputs, filter, stack, sourceInformation);
         foreach (var result in results)
         {
             Console.WriteLine(result);
         }
         foreach (var log in context.Log)
         {
             Console.Error.WriteLine(log.ToString());
         }
     }
     catch (JsonMasherException ex)
     {
         Console.WriteLine(ex.ToString());
         Environment.Exit(-1);
     }
 }
Ejemplo n.º 2
0
        public (IEnumerable <Json> sequence, IMashContext context) Mash(
            IEnumerable <Json> seq,
            IJsonMasherOperator op,
            IMashStack stack,
            SourceInformation sourceInformation = null,
            int tickLimit = 0)
        {
            MashContext _context = MashContext.CreateContext(tickLimit, sourceInformation, stack);

            return(
                sequence : seq.SelectMany(json => op.Mash(json, _context)),
                context : _context);
        }