Moved how Return exceptions were handled into evaluate_string. General file cleanups
This commit is contained in:
parent
a66905b292
commit
4739d67c89
@ -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 <iostream>
|
||||||
|
|
||||||
#include "wesley.hpp"
|
#include "wesley.hpp"
|
||||||
@ -22,19 +12,16 @@ int main(int argc, char *argv[]) {
|
|||||||
std::getline(std::cin, input);
|
std::getline(std::cin, input);
|
||||||
while (input != "quit") {
|
while (input != "quit") {
|
||||||
Boxed_Value val;
|
Boxed_Value val;
|
||||||
try {
|
|
||||||
val = we.evaluate_string(input);
|
val = we.evaluate_string(input);
|
||||||
}
|
|
||||||
catch (const ReturnValue &rv) {
|
|
||||||
val = rv.retval;
|
|
||||||
}
|
|
||||||
if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) {
|
if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) {
|
||||||
try {
|
try {
|
||||||
Boxed_Value printeval = dispatch(we.get_eval_engine().get_function("to_string"), Param_List_Builder() << val);
|
Boxed_Value printeval = dispatch(we.get_eval_engine().get_function("to_string"), Param_List_Builder() << val);
|
||||||
std::cout << "result: ";
|
std::cout << "result: ";
|
||||||
dispatch(we.get_eval_engine().get_function("print"), Param_List_Builder() << printeval);
|
dispatch(we.get_eval_engine().get_function("print"), Param_List_Builder() << printeval);
|
||||||
} catch (const std::runtime_error &e) {
|
} 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> ";
|
std::cout << "eval> ";
|
||||||
@ -43,7 +30,6 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
//Boxed_Value val = we.evaluate_string(we.load_file(argv[i]), argv[i]);
|
|
||||||
try {
|
try {
|
||||||
Boxed_Value val = we.evaluate_file(argv[i]);
|
Boxed_Value val = we.evaluate_file(argv[i]);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,9 @@ public:
|
|||||||
TokenPtr parent = parse(parser, tokens, filename);
|
TokenPtr parent = parse(parser, tokens, filename);
|
||||||
value = eval_token<Eval_Engine>(engine, parent);
|
value = eval_token<Eval_Engine>(engine, parent);
|
||||||
}
|
}
|
||||||
|
catch (const ReturnValue &rv) {
|
||||||
|
value = rv.retval;
|
||||||
|
}
|
||||||
catch (ParserError &pe) {
|
catch (ParserError &pe) {
|
||||||
if (filename != std::string("__EVAL__")) {
|
if (filename != std::string("__EVAL__")) {
|
||||||
std::cout << "Parsing error: \"" << pe.reason << "\" in '" << pe.location->filename << "' line: " << pe.location->start.line+1 << std::endl;
|
std::cout << "Parsing error: \"" << pe.reason << "\" in '" << pe.location->filename << "' line: " << pe.location->start.line+1 << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user