| 80 | } |
| 81 | |
| 82 | std::optional<Error> parseAndReturnFirstError(std::string const& _source, Dialect const& _dialect, bool _allowWarningsAndInfos = true) |
| 83 | { |
| 84 | ErrorList errors; |
| 85 | ErrorReporter errorReporter(errors); |
| 86 | if (!parse(_source, _dialect, errorReporter)) |
| 87 | { |
| 88 | BOOST_REQUIRE(!errors.empty()); |
| 89 | BOOST_CHECK_EQUAL(errors.size(), 1); |
| 90 | return *errors.front(); |
| 91 | } |
| 92 | else |
| 93 | { |
| 94 | // If success is true, there might still be an error in the assembly stage. |
| 95 | if (_allowWarningsAndInfos && !Error::containsErrors(errors)) |
| 96 | return {}; |
| 97 | else if (!errors.empty()) |
| 98 | { |
| 99 | if (!_allowWarningsAndInfos) |
| 100 | BOOST_CHECK_EQUAL(errors.size(), 1); |
| 101 | return *errors.front(); |
| 102 | } |
| 103 | } |
| 104 | return {}; |
| 105 | } |
| 106 | |
| 107 | bool successParse(std::string const& _source, Dialect const& _dialect, bool _allowWarningsAndInfos = true) |
| 108 | { |
no test coverage detected