static void Main(string[] args) { try { // // boot lisp // LispRuntime.Boot(); // // create a runtime object and keep evaluating till "quit" is entered // using (LispRuntime runtime = new LispRuntime()) { // // setup console to read up to 10K of code // int BUFFER_SIZE = 1024 * 10; byte[] buffer = new byte[BUFFER_SIZE]; System.IO.Stream input = Console.OpenStandardInput(BUFFER_SIZE); string form; EvalResult result; Console.Write("> "); while ((form = ReadLine(input, buffer)) != "quit\r\n") { result = runtime.Eval(form); Console.WriteLine(result.ToString()); Console.Write("> "); } } // // shutdown lisp // LispRuntime.Shutdown(); } catch (Exception ex) { Console.WriteLine("ERROR: {0}", ex.ToString()); } }
public void ProcessRequest(HttpContext context) { try { // // retrieve the lisp form to be evaluated from the post data // using (StreamReader reader = new StreamReader(context.Request.InputStream)) { EvalResult result = runtime.Eval(reader.ReadToEnd()); context.Response.ContentType = "application/json"; context.Response.Write(result.ToJson()); } } catch (Exception ex) { context.Response.Write(new EvalResult { Success = false, ErrorOutput = ex.ToString() }.ToJson()); } }