mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
LLL: catch and display spirit::qi errors
This commit is contained in:
parent
5be1996ea5
commit
b92bb41be7
@ -135,10 +135,19 @@ void dev::eth::parseTreeLLL(string const& _s, sp::utree& o_out)
|
|||||||
s.push_back(i);
|
s.push_back(i);
|
||||||
}
|
}
|
||||||
auto ret = s.cbegin();
|
auto ret = s.cbegin();
|
||||||
|
try
|
||||||
|
{
|
||||||
qi::phrase_parse(ret, s.cend(), element, space, qi::skip_flag::dont_postskip, o_out);
|
qi::phrase_parse(ret, s.cend(), element, space, qi::skip_flag::dont_postskip, o_out);
|
||||||
|
}
|
||||||
|
catch (qi::expectation_failure<it> const& e)
|
||||||
|
{
|
||||||
|
std::string fragment(e.first, e.last);
|
||||||
|
std::string loc = std::to_string(std::distance(s.cbegin(), e.first) - 1);
|
||||||
|
std::string reason("Lexer failure at " + loc + ": '" + fragment + "'");
|
||||||
|
BOOST_THROW_EXCEPTION(ParserException() << errinfo_comment(reason));
|
||||||
|
}
|
||||||
for (auto i = ret; i != s.cend(); ++i)
|
for (auto i = ret; i != s.cend(); ++i)
|
||||||
if (!isspace(*i)) {
|
if (!isspace(*i)) {
|
||||||
BOOST_THROW_EXCEPTION(ParserException() << errinfo_comment("Non-whitespace left in parser"));
|
BOOST_THROW_EXCEPTION(ParserException() << errinfo_comment("Non-whitespace left in parser"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user