1 /*=============================================================================
2     Copyright (c) 1998-2003 Joel de Guzman
3     http://spirit.sourceforge.net/
4 
5     Use, modification and distribution is subject to the Boost Software
6     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7     http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #include <boost/spirit/include/classic_core.hpp>
10 #include <boost/spirit/include/classic_exceptions.hpp>
11 #include <iostream>
12 #include <boost/detail/lightweight_test.hpp>
13 
14 using namespace std;
15 using namespace BOOST_SPIRIT_CLASSIC_NS;
16 
17 struct handler
18 {
19     template <typename ScannerT, typename ErrorT>
20     error_status<>
operator ()handler21     operator()(ScannerT const& /*scan*/, ErrorT const& /*error*/) const
22     {
23         cout << "exception caught...Test concluded successfully" << endl;
24         return error_status<>(error_status<>::fail);
25     }
26 };
27 
28 int
main()29 main()
30 {
31     cout << "/////////////////////////////////////////////////////////\n\n";
32     cout << "\t\tExceptions Test...\n\n";
33     cout << "/////////////////////////////////////////////////////////\n\n";
34 
35     assertion<int>  expect(0);
36     guard<int>      my_guard;
37 
38     bool r =
39         parse("abcx",
40             my_guard(ch_p('a') >> 'b' >> 'c' >> expect( ch_p('d') ))
41             [
42                 handler()
43             ]
44         ).full;
45 
46     BOOST_TEST(!r);
47     return boost::report_errors();
48 }
49 
50