| 460 | } |
| 461 | |
| 462 | Expected<Any> ParseScriptAndExecute(Ast::Environment& env, const std::string& script) |
| 463 | { |
| 464 | auto executor = ParseScript(script); |
| 465 | if(executor) |
| 466 | { |
| 467 | try |
| 468 | { |
| 469 | return executor.value()(env); |
| 470 | } |
| 471 | catch(RuntimeError& err) |
| 472 | { |
| 473 | return nonstd::make_unexpected(err.what()); |
| 474 | } |
| 475 | } |
| 476 | return nonstd::make_unexpected(executor.error()); |
| 477 | } |
| 478 | |
| 479 | Result ValidateScript(const std::string& script) |
| 480 | { |