-
Notifications
You must be signed in to change notification settings - Fork 3
/
error_handler.hpp
44 lines (35 loc) · 1.33 KB
/
error_handler.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*=============================================================================
Copyright (c) 2001-2009 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef ERROR_HANDLER_HPP_
#define ERROR_HANDLER_HPP_
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <iostream>
///////////////////////////////////////////////////////////////////////////////
// Our error handler
///////////////////////////////////////////////////////////////////////////////
struct error_handler_
{
template <typename, typename, typename>
struct result { typedef void type; };
template <typename Iterator>
void operator()(
boost::spirit::qi::info const& what
, Iterator err_pos, Iterator last) const
{
std::cout
<< "Error! Expecting "
<< what // what failed?
<< " here: \""
<< std::string(err_pos, last) // iterators to error-pos, end
<< "\""
<< std::endl
;
}
};
boost::phoenix::function<error_handler_> const error_handler =
error_handler_();
#endif /* ERROR_HANDLER_HPP_ */