Exemplo n.º 1
0
 public void Process(ChunkReader reader, Machine machine, ICompiler compiler)
 {
     if (this.count > 0)
         for (int k = 0; k < this.count; k++)
             this.process(machine, compiler, reader.GetChunk());
     else
         for (string text = reader.GetChunk(); text != null; text = reader.GetChunk())
             if (string.IsNullOrEmpty(text.Trim()))
                 return;
             else
                 this.process(machine, compiler, text);
 }
Exemplo n.º 2
0
        public void LoadAndExecute(Machine machine)
        {
            string blocktext;

            blocktext = this.GetBlockText();

            while (blocktext != null)
            {
                bool isprocessor = false;

                string trimmed = blocktext.Trim();

                if (trimmed.StartsWith("!"))
                {
                    trimmed = trimmed.Substring(1);
                    isprocessor = true;
                }

                if (String.IsNullOrEmpty(trimmed))
                {
                    blocktext = this.GetBlockText();
                    continue;
                }

                Block block = this.compiler.CompileBlock(trimmed);
                var value = block.Execute(machine, null);

                if (isprocessor)
                    ((ChunkReaderProcessor)value).Process(this.reader, machine, this.compiler);

                blocktext = this.GetBlockText();
            }

            this.reader.Close();
            this.reader = null;
        }
Exemplo n.º 3
0
 public Loader(string filename, ICompiler compiler)
 {
     this.reader = new ChunkReader(filename);
     this.compiler = compiler;
 }
Exemplo n.º 4
0
 public Loader(TextReader reader, ICompiler compiler)
 {
     this.reader = new ChunkReader(reader);
     this.compiler = compiler;
 }