Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:01:57

0001 /*=============================================================================
0002     Copyright (c) 2001-2003 Joel de Guzman
0003     http://spirit.sourceforge.net/
0004 
0005     Use, modification and distribution is subject to the Boost Software
0006     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007     http://www.boost.org/LICENSE_1_0.txt)
0008 =============================================================================*/
0009 #ifndef BOOST_SPIRIT_EXCEPTIONS_IPP
0010 #define BOOST_SPIRIT_EXCEPTIONS_IPP
0011 
0012 namespace boost { namespace spirit { 
0013 
0014 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0015 
0016 namespace impl {
0017 
0018 #ifdef __BORLANDC__
0019     template <typename ParserT, typename ScannerT>
0020     typename parser_result<ParserT, ScannerT>::type
0021     fallback_parser_helper(ParserT const& subject, ScannerT const& scan);
0022 #endif
0023 
0024     template <typename RT, typename ParserT, typename ScannerT>
0025     RT fallback_parser_parse(ParserT const& p, ScannerT const& scan)
0026     {
0027         typedef typename ScannerT::iterator_t iterator_t;
0028         typedef typename RT::attr_t attr_t;
0029         typedef error_status<attr_t> error_status_t;
0030         typedef typename ParserT::error_descr_t error_descr_t;
0031 
0032         iterator_t save = scan.first;
0033         error_status_t hr(error_status_t::retry);
0034 
0035         while (hr.result == error_status_t::retry)
0036         {
0037             try
0038             {
0039             #ifndef __BORLANDC__
0040                 return p.subject().parse(scan);
0041             #else
0042                 return impl::fallback_parser_helper(p, scan);
0043             #endif
0044             }
0045 
0046             catch (parser_error<error_descr_t, iterator_t>& error)
0047             {
0048                 scan.first = save;
0049                 hr = p.handler(scan, error);
0050                 switch (hr.result)
0051                 {
0052                     case error_status_t::fail:
0053                         return scan.no_match();
0054                     case error_status_t::accept:
0055                         return scan.create_match
0056                             (std::size_t(hr.length), hr.value, save, scan.first);
0057                     case error_status_t::rethrow:
0058                          boost::throw_exception(error);
0059                     default:
0060                         continue;
0061                 }
0062             }
0063         }
0064         return scan.no_match();
0065     }
0066 
0067 ///////////////////////////////////////////////////////////////////////////
0068 //
0069 //  Borland does not like calling the subject directly in the try block.
0070 //  Removing the #ifdef __BORLANDC__ code makes Borland complain that
0071 //  some variables and types cannot be found in the catch block. Weird!
0072 //
0073 ///////////////////////////////////////////////////////////////////////////
0074 #ifdef __BORLANDC__
0075 
0076     template <typename ParserT, typename ScannerT>
0077     typename parser_result<ParserT, ScannerT>::type
0078     fallback_parser_helper(ParserT const& p, ScannerT const& scan)
0079     {
0080         return p.subject().parse(scan);
0081     }
0082 
0083 #endif
0084 
0085 }
0086 
0087 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0088 
0089 }} // namespace boost::spirit::impl
0090 
0091 ///////////////////////////////////////////////////////////////////////////////
0092 #endif
0093