diff --git a/wesley/main.cpp b/wesley/main.cpp index 6197bbb..06a9e1d 100644 --- a/wesley/main.cpp +++ b/wesley/main.cpp @@ -1,13 +1,3 @@ -/* -#include -#include -#include - -#include -#include -#include -*/ - #include #include "wesley.hpp" @@ -22,19 +12,16 @@ int main(int argc, char *argv[]) { std::getline(std::cin, input); while (input != "quit") { Boxed_Value val; - try { - val = we.evaluate_string(input); - } - catch (const ReturnValue &rv) { - val = rv.retval; - } + + val = we.evaluate_string(input); + if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) { try { Boxed_Value printeval = dispatch(we.get_eval_engine().get_function("to_string"), Param_List_Builder() << val); std::cout << "result: "; dispatch(we.get_eval_engine().get_function("print"), Param_List_Builder() << printeval); } catch (const std::runtime_error &e) { - //std::cout << "unhandled type: " << val.get_type_info().m_type_info->name() << std::endl; + std::cout << "result: object #" << &val << std::endl; } } std::cout << "eval> "; @@ -43,7 +30,6 @@ int main(int argc, char *argv[]) { } else { for (int i = 1; i < argc; ++i) { - //Boxed_Value val = we.evaluate_string(we.load_file(argv[i]), argv[i]); try { Boxed_Value val = we.evaluate_file(argv[i]); } diff --git a/wesley/wesley_engine.hpp b/wesley/wesley_engine.hpp index f6956a4..8292287 100644 --- a/wesley/wesley_engine.hpp +++ b/wesley/wesley_engine.hpp @@ -258,6 +258,9 @@ public: TokenPtr parent = parse(parser, tokens, filename); value = eval_token(engine, parent); } + catch (const ReturnValue &rv) { + value = rv.retval; + } catch (ParserError &pe) { if (filename != std::string("__EVAL__")) { std::cout << "Parsing error: \"" << pe.reason << "\" in '" << pe.location->filename << "' line: " << pe.location->start.line+1 << std::endl;