aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--liblll/Parser.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/liblll/Parser.cpp b/liblll/Parser.cpp
index 2754e9f5..7d594e31 100644
--- a/liblll/Parser.cpp
+++ b/liblll/Parser.cpp
@@ -135,10 +135,19 @@ void dev::eth::parseTreeLLL(string const& _s, sp::utree& o_out)
s.push_back(i);
}
auto ret = s.cbegin();
- qi::phrase_parse(ret, s.cend(), element, space, qi::skip_flag::dont_postskip, o_out);
+ try
+ {
+ 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)
if (!isspace(*i)) {
BOOST_THROW_EXCEPTION(ParserException() << errinfo_comment("Non-whitespace left in parser"));
}
}
-