Only allow class in top level scope

* Throw error if class is in unexpected place
 * Allow catching of `eval_error` from inside of script

closes #297
This commit is contained in:
Jason Turner
2016-10-28 10:56:12 -06:00
parent 77231461ca
commit a38b254a98
3 changed files with 15 additions and 14 deletions

View File

@@ -1313,11 +1313,8 @@ namespace chaiscript
try {
retval = this->children[0]->eval(t_ss);
}
catch (exception::eval_error &) {
if (this->children.back()->identifier == AST_Node_Type::Finally) {
this->children.back()->children[0]->eval(t_ss);
}
throw;
catch (const exception::eval_error &e) {
retval = handle_exception(t_ss, Boxed_Value(std::ref(e)));
}
catch (const std::runtime_error &e) {
retval = handle_exception(t_ss, Boxed_Value(std::ref(e)));