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