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