apps/runner/src/eu/runner/script.cc
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "eu/runner/script.h" | ||
| 2 | |||
| 3 | #include "eu/io/file.h" | ||
| 4 | |||
| 5 | #include "lax/lax.h" | ||
| 6 | #include "lax/printhandler.h" | ||
| 7 | |||
| 8 | namespace eu::runner | ||
| 9 | { | ||
| 10 | |||
| 11 | |||
| 12 | struct PrintLaxError : lax::PrintHandler | ||
| 13 | { | ||
| 14 | ✗ | void on_line(std::string_view line) override | |
| 15 | { | ||
| 16 | ✗ | LOG_ERR("> {0}", line); | |
| 17 | ✗ | } | |
| 18 | }; | ||
| 19 | |||
| 20 | |||
| 21 | ✗ | Script:: Script() | |
| 22 | ✗ | : lax(std::make_unique<PrintLaxError>(), [](const std::string& str) { LOG_INFO("> {0}", str); }) | |
| 23 | { | ||
| 24 | ✗ | } | |
| 25 | |||
| 26 | ✗ | bool Script::run_file(const std::string& file) | |
| 27 | { | ||
| 28 | ✗ | const auto content = io::string_from_file("main.lax"); | |
| 29 | ✗ | const auto result = lax.run_string(content); | |
| 30 | |||
| 31 | ✗ | if(result == false) | |
| 32 | { | ||
| 33 | ✗ | LOG_ERR("Failed to run lax file {}", file); | |
| 34 | } | ||
| 35 | |||
| 36 | ✗ | return result; | |
| 37 | ✗ | } | |
| 38 | |||
| 39 | |||
| 40 | } | ||
| 41 |