Moved how Return exceptions were handled into evaluate_string. General file cleanups

This commit is contained in:
Jonathan Turner 2009-06-10 21:47:21 +00:00
parent a66905b292
commit 4739d67c89
2 changed files with 7 additions and 18 deletions

View File

@ -1,13 +1,3 @@
/*
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <iostream>
#include <map>
#include <fstream>
*/
#include <iostream>
#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]);
}

View File

@ -258,6 +258,9 @@ public:
TokenPtr parent = parse(parser, tokens, filename);
value = eval_token<Eval_Engine>(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;