1/*=============================================================================
2 Copyright (c) 2001-2014 Joel de Guzman
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6=============================================================================*/
7#if !defined(BOOST_SPIRIT_X3_CALC7_ERROR_HANDLER_HPP)
8#define BOOST_SPIRIT_X3_CALC7_ERROR_HANDLER_HPP
9
10#include <boost/spirit/home/x3.hpp>
11#include <iostream>
12
13namespace client { namespace calculator_grammar
14{
15 ////////////////////////////////////////////////////////////////////////////
16 // Our error handler
17 ////////////////////////////////////////////////////////////////////////////
18 namespace x3 = boost::spirit::x3;
19
20 struct error_handler
21 {
22 // Our error handler
23 template <typename Iterator, typename Exception, typename Context>
24 x3::error_handler_result
25 on_error(Iterator&, Iterator const& last, Exception const& x, Context const& context)
26 {
27 std::cout
28 << "Error! Expecting: "
29 << x.which()
30 << " here: \""
31 << std::string(x.where(), last)
32 << "\""
33 << std::endl
34 ;
35 return x3::error_handler_result::fail;
36 }
37 };
38}}
39
40#endif
41

source code of boost/libs/spirit/example/x3/calc/calc7/error_handler.hpp