| 53 | { |
| 54 | |
| 55 | std::optional<Error> parseAndReturnFirstError( |
| 56 | std::string const& _source, |
| 57 | bool _assemble = false, |
| 58 | bool _allowWarnings = true, |
| 59 | YulStack::Machine _machine = YulStack::Machine::EVM |
| 60 | ) |
| 61 | { |
| 62 | YulStack stack( |
| 63 | solidity::test::CommonOptions::get().evmVersion(), |
| 64 | solidity::test::CommonOptions::get().eofVersion(), |
| 65 | solidity::frontend::OptimiserSettings::none(), |
| 66 | DebugInfoSelection::None() |
| 67 | ); |
| 68 | bool success = stack.parseAndAnalyze("", _source); |
| 69 | if (success && _assemble) |
| 70 | stack.assemble(_machine); |
| 71 | std::shared_ptr<Error const> error; |
| 72 | for (auto const& e: stack.errors()) |
| 73 | { |
| 74 | if (_allowWarnings && e->type() == Error::Type::Warning) |
| 75 | continue; |
| 76 | if (error) |
| 77 | BOOST_FAIL( |
| 78 | "Found more than one error:\n" + |
| 79 | SourceReferenceFormatter::formatErrorInformation(stack.errors(), stack) |
| 80 | ); |
| 81 | error = e; |
| 82 | } |
| 83 | if (!success) |
| 84 | BOOST_REQUIRE(error); |
| 85 | if (error) |
| 86 | return *error; |
| 87 | return {}; |
| 88 | } |
| 89 | |
| 90 | bool successParse( |
| 91 | std::string const& _source, |
no test coverage detected