/// <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()); } } }
public static Macro Decrement(Environment environment) { return((Macro)Runtime.EvalString("(macro (x) `(= ,x (- ,x 1)))", environment)); }
public static Macro ListP(Environment environment) { return((Macro)Runtime.EvalString("(macro (l) `(eq (typeof LSharp.Cons) (gettype ,l)))", environment)); }
public static Macro DefMacro(Environment environment) { return((Macro)Runtime.EvalString("(macro (name args &rest body) `(= ,name (macro ,args ,@body)))", environment)); }
public static Object EvalString(Cons args, Environment environment) { return(Runtime.EvalString(args.First().ToString(), environment)); }