private ISList<IInsn> Compile(Parser parser) { try { IExpr expr = parser.Parse(); if (expr == null) { throw new EndOfStreamException(); } Compiler compiler = new Compiler(); expr.Compile(compiler); return compiler.GetResult(); } catch (RheaException e) { Console.WriteLine("{0}: {1}", e.Info, e.Message); return null; } }
private bool Interpret(SourceReader reader, bool interactive) { try { Lexer lexer = new Lexer(reader); Parser parser = new Parser(lexer); while (true) { ISList<IInsn> insns = Compile(parser); if (insns == null) { return false; } IValue result = Run(insns); if (result == null) { return false; } if (interactive) { Console.WriteLine(" => {0}", result); } } } catch (EndOfStreamException) { return true; } }