/// <summary> /// Parse and evaluate a single line of script. Done in place, and immediately, and in the /// global scope. /// </summary> /// <param name="scriptline">text to execute</param> /// <returns>Whatever the value of the script line is</returns> public static object eval(IScopeContext c, string scriptline) { var statements = Grammar.ModuleParser.End().Parse(scriptline); object result = null; Action <object> saver = o => result = o; c.AddExpressionStatementEvaluationCallback(saver); try { foreach (var s in statements) { s.Evaluate(c); } } finally { c.RemoveExpressionStatementEvaluationCallback(saver); } return(result); }