| 16 | } |
| 17 | |
| 18 | std::optional<CompiledScript> compile(const std::string& scriptBody, bool shouldFail = false) |
| 19 | { |
| 20 | mParser.reset(); |
| 21 | mErrorHandler.reset(); |
| 22 | std::istringstream input(scriptBody); |
| 23 | Compiler::Scanner scanner(mErrorHandler, input, mCompilerContext.getExtensions()); |
| 24 | try |
| 25 | { |
| 26 | scanner.scan(mParser); |
| 27 | } |
| 28 | catch (...) |
| 29 | { |
| 30 | if (!shouldFail) |
| 31 | logErrors(); |
| 32 | throw; |
| 33 | } |
| 34 | if (mErrorHandler.isGood()) |
| 35 | return CompiledScript(mParser.getProgram(), mParser.getLocals()); |
| 36 | else if (!shouldFail) |
| 37 | logErrors(); |
| 38 | return {}; |
| 39 | } |
| 40 | |
| 41 | void logErrors() |
| 42 | { |
nothing calls this directly
no test coverage detected