static void RunRepl() { WrenVM vm = new WrenVM(null, null); LibraryLoader.LoadLibraries(vm); WrenScript.LoadLibrary <ScriptTest>(vm); Console.WriteLine("-- wren v0.0.0"); string line = ""; for (; ;) { Console.Write("> "); line += Console.ReadLine() + "\n"; if (OpenBrackets(line) > 0) { continue; } // TODO: Handle failure. var result = new WrenVM.ResultRef(); var coroutine = vm.InterpretCoroutines("Prompt", "Prompt", line, result); // quick and dirty sim of unity's coroutines Stack <IEnumerator> stack = new Stack <IEnumerator>(); stack.Push(coroutine); while (stack.Count > 0) { if (!stack.Peek().MoveNext()) { stack.Pop(); } else { if (stack.Peek().Current is IEnumerator) { stack.Push(stack.Peek().Current as IEnumerator); } else { Console.WriteLine("yielded " + stack.Peek().Current); } } } line = ""; } }