예제 #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);
 }
예제 #2
0
파일: Loader.cs 프로젝트: ajlopez/AjTalk
        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;
        }
예제 #3
0
파일: Loader.cs 프로젝트: ajlopez/AjTalk
 public Loader(string filename, ICompiler compiler)
 {
     this.reader = new ChunkReader(filename);
     this.compiler = compiler;
 }
예제 #4
0
파일: Loader.cs 프로젝트: ajlopez/AjTalk
 public Loader(TextReader reader, ICompiler compiler)
 {
     this.reader = new ChunkReader(reader);
     this.compiler = compiler;
 }