]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/example/fundamental/error_handling.cpp
1 /*=============================================================================
2 Copyright (c) 1998-2003 Joel de Guzman
3 http://spirit.sourceforge.net/
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 ///////////////////////////////////////////////////////////////////////////////
11 // This sample demonstrates error handling as seen in the
12 // Error Handling" chapter in the User's Guide.
14 ///////////////////////////////////////////////////////////////////////////////
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/spirit/include/classic_exceptions.hpp>
18 #include <boost/assert.hpp>
21 using namespace BOOST_SPIRIT_CLASSIC_NS
;
25 template <typename ScannerT
, typename ErrorT
>
27 operator()(ScannerT
const& /*scan*/, ErrorT
const& /*error*/) const
29 cout
<< "exception caught...Test concluded successfully" << endl
;
30 return error_status
<>(error_status
<>::fail
);
37 cout
<< "/////////////////////////////////////////////////////////\n\n";
38 cout
<< "\t\tExceptions Test...\n\n";
39 cout
<< "/////////////////////////////////////////////////////////\n\n";
41 assertion
<int> expect(0);
45 my_guard(ch_p('a') >> 'b' >> 'c' >> expect( ch_p('d') ))
50 bool r
= parse("abcx", start
).full
;