EvalString() public method

public EvalString ( string s ) : Object
s string
return Object
示例#1
0
        /// <summary>
        ///  Starts the toploop running using specified input, output and error streams
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="writer"></param>
        /// <param name="error"></param>
        public void Run(TextReader reader, TextWriter writer, TextWriter error)
        {
            Symbol LAST = Symbol.FromName("?");


            while (true)
            {
                try
                {
                    Object o = trace ? Runtime.EvalString("(eval (prl (read (in Console))))", environment)
            : Runtime.EvalString("(eval (read (in Console)))", environment);

                    if (o == Reader.EOFVALUE)
                    {
                        return;
                    }

                    if (tracereturn)
                    {
                        writer.Write(prompt);
                        writer.WriteLine(Printer.WriteToString(o));
                    }
                    environment.AssignLocal(LAST, o);
                }
                catch (LSharpException e)
                {
                    error.WriteLine(e.Message);
                }
                catch (Exception e)
                {
                    error.WriteLine(e.GetBaseException());
                }
            }
        }
示例#2
0
 public static Macro Decrement(Environment environment)
 {
     return((Macro)Runtime.EvalString("(macro (x) `(= ,x (- ,x 1)))", environment));
 }
示例#3
0
 public static Macro ListP(Environment environment)
 {
     return((Macro)Runtime.EvalString("(macro (l) `(eq (typeof LSharp.Cons) (gettype ,l)))", environment));
 }
示例#4
0
 public static Macro DefMacro(Environment environment)
 {
     return((Macro)Runtime.EvalString("(macro (name args &rest body) `(= ,name (macro ,args ,@body)))", environment));
 }
示例#5
0
 public static Object EvalString(Cons args, Environment environment)
 {
     return(Runtime.EvalString(args.First().ToString(), environment));
 }