Example #1
0
        public static void Repl(string loadFile)
        {
            int start = Environment.TickCount;

            A_Program prog = null;

            for (int i = 0; i < 10; i++)
            {
                prog = new A_Program();
                prog.LoadEmbededInitTachy();
            }

            int end = Environment.TickCount;

            if (loadFile != null)
            {
                String init = File.OpenText(loadFile).ReadToEnd();
                prog.Eval(new StringReader(init));
            }
            else
            {
                while (true)
                {
                    // Application.DoEvents();
                    StreamWriter str = new StreamWriter("transcript.ss", true);
                    try
                    {
                        Console.WriteLine("(" + (end - start) + " ms)");
                        Console.Write("> ");

                        String val = ReadAvailable();

                        str.WriteLine(val);

                        start = Environment.TickCount;
                        object result = prog.Eval(new StringReader(val));
                        end = Environment.TickCount;

                        Console.WriteLine(result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Tachy Error: " + e.Message);                         // + e.Message); // .Message);
                        Console.WriteLine("Stacktrace: " + e.StackTrace);
                    }
                    str.Close();
                }
            }
        }
Example #2
0
        private static void EvalImmediate()
        {
            if (!InitCalled)
            {
                return;
            }

            Env EvalEnv = GetCurrentEnvFromCallStackListView();

            if (EvalEnv == null)
            {
                MessageBox.Show("The environment to execute the selected text could not be determined. This Error should not occur.");
            }
            else
            {
                bool curRunHidden = RunHidden;
                RunHidden = true;
                try
                {
                    object result = null;
                    if (Immediate is string)
                    {
                        result = tachyProg.Eval((string)Immediate, EvalEnv);
                    }
                    else if (Immediate is TextReader)
                    {
                        result = tachyProg.Eval((TextReader)Immediate, EvalEnv);
                    }
                    else
                    {
                        MessageBox.Show("The environment to execute the selected text could not be determined. This Error should not occur.");
                    }

                    if (result != null)
                    {
                        tachyOutputWindowPane.OutputString(result.ToString() + "\n");
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message + "      " + e.InnerException);
                }
                finally
                {
                    RunHidden = curRunHidden;
                }
            }
        }
Example #3
0
        public static void Repl(string loadFile)
        {
            int start = Environment.TickCount;

            A_Program prog = null;
            for (int i = 0; i < 10; i++)
            {
                prog = new A_Program();
                prog.LoadEmbededInitTachy();
            }

            int end = Environment.TickCount;

            if (loadFile != null)
            {
                String init = File.OpenText(loadFile).ReadToEnd();
                prog.Eval(new StringReader(init));
            }
            else
            {
                while (true)
                {
                    // Application.DoEvents();
                    StreamWriter str = new StreamWriter("transcript.ss", true);
                    try
                    {
                        Console.WriteLine("(" + (end - start) + " ms)");
                        Console.Write("> ");

                        String val = ReadAvailable();

                        str.WriteLine(val);

                        start = Environment.TickCount;
                        object result = prog.Eval(new StringReader(val));
                        end = Environment.TickCount;

                        Console.WriteLine(result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Tachy Error: " + e.Message); // + e.Message); // .Message);
                        Console.WriteLine("Stacktrace: " + e.StackTrace);
                    }
                    str.Close();
                }
            }
        }
Example #4
0
 private void replInputBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
 {
     if (Convert.ToInt32(e.KeyChar) == 10)
     {
         StreamWriter str = new StreamWriter("..\\..\\transcript.ss", true);
         try
         {
             String val = this.replInputBox.Text;
             str.WriteLine(val);
             object result = prog.Eval(new StringReader(val));
             this.replOutputBox.Text += result + "\r\n";
             this.replInputBox.Clear();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Tachy Error: " + ex.ToString());
         }
         str.Close();
     }
 }