aboutsummaryrefslogtreecommitdiffstats
path: root/liblll
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2016-10-26 21:29:08 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2016-11-01 09:08:57 +0800
commitb92bb41be78c4277a16974353ec2e21ea8cd5f7b (patch)
tree56be0416586585f57abf1c4f5decad726b64e63c /liblll
parent5be1996ea5bc73ef37df55cdd28504de5ec357c4 (diff)
downloaddexon-solidity-b92bb41be78c4277a16974353ec2e21ea8cd5f7b.tar.gz
dexon-solidity-b92bb41be78c4277a16974353ec2e21ea8cd5f7b.tar.zst
dexon-solidity-b92bb41be78c4277a16974353ec2e21ea8cd5f7b.zip
LLL: catch and display spirit::qi errors
Diffstat (limited to 'liblll')
-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"));
}
}
-