5 #define BOOST_SPIRIT_USE_PHOENIX_V3
6 #include <boost/spirit/include/qi.hpp>
7 #include <boost/spirit/include/support_line_pos_iterator.hpp>
11 namespace spirit = boost::spirit;
12 namespace qi = boost::spirit::qi;
15 template<
typename>
struct result {
using type = qi::error_handler_result; };
16 template<
typename T1,
typename T2>
17 qi::error_handler_result
operator()(T1 b, T1 e, T1 where, T2
const& what)
const {
19 auto line_start = spirit::get_line_start(b, where);
20 auto line_end = std::find(where, e,
'\n');
21 std::string line(++line_start, line_end);
23 std::cout <<
"Parsing error at " << spirit::get_line(where) <<
":" << spirit::get_column(line_start, where) << std::endl;
24 std::cout <<
"expected" << std::endl <<
"\t" << what.tag <<
": " << what << std::endl;
25 std::cout <<
"but got" << std::endl <<
"\t" << std::string(where, line_end) << std::endl;
26 std::cout <<
"in line " << spirit::get_line(where) << std::endl <<
"\t" << line << std::endl;
qi::error_handler_result operator()(T1 b, T1 e, T1 where, T2 const &what) const
qi::error_handler_result type