public static void IfJumpTo(CookCompiler machine, string line) { var operators = line.Split(new[] { "jumpto" }, StringSplitOptions.None); var conditional = operators[0].Trim(); conditional = machine.ApplyVariablesInString(conditional); bool result = false; try { conditional = ComparationParser.Evaluator(conditional); conditional = BooleanParser.Evaluator(conditional); result = BooleanParser.EvaluatorFinal(conditional); } catch (System.Exception e) { Console.WriteLine(e.ToString()); machine.error = $"Conditional error at line {machine.pointer}"; return; } if (result) { machine.returnStack.Push(machine.pointer); machine.pointer += int.Parse(operators[1], Utils.usNumberFormat) + 1; return; } machine.pointer++; }
public static void Operation(CookCompiler machine, string line) { line = machine.ApplyVariablesInString(line); try { line = AritmeticParser.Evaluator(line).ToString(); } catch { machine.error = $"Syntax in line {machine.pointer}"; return; } machine.variables["Temporal"] = line; machine.pointer++; }
public static void Assign(CookCompiler machine, string line) { var v = line.Split(' '); var name = v[0].Trim().Replace(" ", ""); var data = line.Replace($"{name} ", ""); data = machine.ApplyVariablesInString(data); machine.pointer++; if (machine.variables.ContainsKey(name)) { machine.variables[name] = data; return; } machine.variables.Add(name, data); }
public static void Print(CookCompiler machine, string line) { line = machine.ApplyVariablesInString(line); Console.WriteLine(line); machine.pointer++; }