public Interpreter() { Functions = new Dictionary<string, Function>(); Variables = new Dictionary<string, float>(); Functions["print"] = new ExternFunction(new FunctionPrototype("print", new List<string>() { "x" }), x => { Console.WriteLine(x); return 0; }); Functions["read"] = new ExternFunction(new FunctionPrototype("read", new List<string>()), () =>{return Convert.ToSingle(Console.ReadLine()); }); Functions["putchar"] = new ExternFunction(new FunctionPrototype("putchar", new List<string>() { "x" }), x => { Console.Write((char)x); return 0; }); Functions["putpos"] = new ExternFunction(new FunctionPrototype("putpos", new List<string>() { "x", "y" }), (x, y) => { Console.SetCursorPosition((int)x, (int)y); return 0; }); }
public void AddFunction(string name, ExternFunction.CalculateDelegate3 func2) { Functions[name] = new ExternFunction(new FunctionPrototype(name, new List<string>() { "x", "y", "z" }), func2); }