Example #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();
            }
        }
Example #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;
 }
Example #3
0
 public void Compile()
 {
     foreach (var item in program)
     {
         var bs = new BasicStep(item);
         steps.Add(bs);
     }
 }
Example #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);
 }
Example #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;
        }
Example #6
0
 public abstract void Run(BasicStep command);
Example #7
0
 public override void Run(BasicStep command)
 {
     interpreter.Next();
 }