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