Exemple #1
0
        static void CommandProcessor()
        {
            Console.WriteLine();
            while (true)
            {
                Console.Write("> ");
                var command = Console.ReadLine();
                if (command == null)
                    continue;

                if (command.StartsWith("run "))
                {
                    var code = new StringBuilder(200);
                    command = command.Substring(4);
                    // import this by default to enable logging
                    code.Append("import bE\n");
                    code.Append(command + "\n");
                    Console.Write("      ");
                    while ((command = Console.ReadLine()) != "")
                    {
                        Console.Write("      ");
                        code.Append(command.Replace(@"\t", "\t") + "\n");
                    }
                    var cb = new CodeBite(code.ToString());
                    try
                    {
                        var res = Python.Repr(cb.Run());
                        if (res != "0" && res != "None")
                            Console.WriteLine(" => " + res);
                    }
                    catch (PyException py)
                    {
                        Console.WriteLine(" => runtime error: " + py.Type + ": " + py.Value);
                        continue;
                    }
                    catch (CompileException)
                    {
                        Console.WriteLine(" => compiler error");
                        continue;
                    }
                }

                foreach (var plugin in Core.Plugins)
                {
                    if (command.StartsWith(plugin.ShortName))
                    {
                        command = command.Substring(plugin.ShortName.Length + 1);
                        plugin.ProcessCommand(command);
                        break;
                    }
                }
            }
        }
Exemple #2
0
 public static IntPtr Run(string code)
 {
     var cb = new CodeBite(code);
     return cb.Run();
 }
Exemple #3
0
 public static void Run(RunFunction func)
 {
     var cb = new CodeBite(func);
     cb.Run();
 }
Exemple #4
0
        public static IntPtr Run(string code)
        {
            var cb = new CodeBite(code);

            return(cb.Run());
        }
Exemple #5
0
        public static void Run(RunFunction func)
        {
            var cb = new CodeBite(func);

            cb.Run();
        }