Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / spirit / example / x3 / calc7 / error_handler.hpp
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
12 namespace client { namespace calculator_grammar
13 {
14     ////////////////////////////////////////////////////////////////////////////
15     //  Our error handler
16     ////////////////////////////////////////////////////////////////////////////
17     namespace x3 = boost::spirit::x3;
18
19     struct error_handler
20     {
21         //  Our error handler
22         template <typename Iterator, typename Exception, typename Context>
23         x3::error_handler_result
24         on_error(Iterator&, Iterator const& last, Exception const& x, Context const& context)
25         {
26             std::cout
27                 << "Error! Expecting: "
28                 << x.which()
29                 << " here: \""
30                 << std::string(x.where(), last)
31                 << "\""
32                 << std::endl
33                 ;
34             return x3::error_handler_result::fail;
35         }
36     };
37 }}
38
39 #endif