| 232 | } |
| 233 | |
| 234 | void interactive(chaiscript::ChaiScript& chai) |
| 235 | { |
| 236 | using_history(); |
| 237 | |
| 238 | for (;;) { |
| 239 | std::string input = get_next_command(); |
| 240 | try { |
| 241 | // evaluate input |
| 242 | chaiscript::Boxed_Value val = chai.eval(input); |
| 243 | |
| 244 | //Then, we try to print the result of the evaluation to the user |
| 245 | if (!val.get_type_info().bare_equal(chaiscript::user_type<void>())) { |
| 246 | try { |
| 247 | std::cout << chai.eval<std::function<std::string(const chaiscript::Boxed_Value &bv)> >("to_string")(val) << std::endl; |
| 248 | } |
| 249 | catch (...) {} //If we can't, do nothing |
| 250 | } |
| 251 | } |
| 252 | catch (const chaiscript::exception::eval_error &ee) { |
| 253 | std::cout << ee.what(); |
| 254 | if (ee.call_stack.size() > 0) { |
| 255 | std::cout << "during evaluation at (" << ee.call_stack[0].start().line << ", " << ee.call_stack[0].start().column << ")"; |
| 256 | } |
| 257 | std::cout << std::endl; |
| 258 | } |
| 259 | catch (const std::exception &e) { |
| 260 | std::cout << e.what(); |
| 261 | std::cout << std::endl; |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | int main(int argc, char *argv[]) |
| 267 | { |
no test coverage detected