예제 #1
0
        public override void Run(BasicStep command)
        {
            var atr = command.AllTheRest;
            var ptrs = atr.Split(new []{"FROM"},StringSplitOptions.RemoveEmptyEntries);
            atr = ptrs[1];
            var varName = ptrs[0].Trim();
            ptrs = atr.Split(new[] { "TO" }, StringSplitOptions.RemoveEmptyEntries);
            var start = int.Parse( ptrs[0].Trim());
            var endName = ptrs[1].Trim();
            int end;

            if (!interpreter.Variables.TryGetValue(endName, out end))
            {
                end = int.Parse(endName);
            }

            if(interpreter.Loop == null){
                interpreter.Loop = new ForLoop
                {
                    from = start,
                    to = end,
                    stepNumber = command.Number,
                    VarName = varName
                };
                interpreter.Variables[varName] = start;
            }
            else
            {
                var varVal = interpreter.Variables[varName];
                varVal++;
                interpreter.Variables[varName] = varVal;
                if (varVal > end)
                    interpreter.FinishLoop();
            }
        }
예제 #2
0
 public override void Run(BasicStep command)
 {
     var parts = command.AllTheRest.Split('=');
     var variableName = parts[0].Trim();
     var valueOfVar = int.Parse(parts[1].Trim());
     interpreter.Variables[variableName] = valueOfVar;
 }
예제 #3
0
파일: Program.cs 프로젝트: 1extra/prog2015
 public void Compile()
 {
     foreach (var item in program)
     {
         var bs = new BasicStep(item);
         steps.Add(bs);
     }
 }
예제 #4
0
 public void Run(BasicStep command)
 {
     var atr = command.AllTheRest;
     foreach (var item in interpreter.Variables)
     {
         atr = atr.Replace("{" + item.Key + "}", item.Value.ToString());
     }
     Console.WriteLine(atr);
 }
예제 #5
0
        public override void Run(BasicStep command)
        {
            var parts = command.AllTheRest.Split(' ');
            var x = parts[0];
            var y = parts[1];

            var xv = interpreter.Variables[x];
            xv *= interpreter.Variables[y];
            interpreter.Variables[x] = xv;
        }
예제 #6
0
 public abstract void Run(BasicStep command);
예제 #7
0
 public override void Run(BasicStep command)
 {
     interpreter.Next();
 }