Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:09:00

0001 /*=============================================================================
0002     Copyright (c) 2003 Joel de Guzman
0003     Copyright (c) 2003 Vaclav Vesely
0004     http://spirit.sourceforge.net/
0005 
0006   Distributed under the Boost Software License, Version 1.0. (See accompanying
0007   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 =============================================================================*/
0009 #ifndef BOOST_SPIRIT_LAZY_HPP
0010 #define BOOST_SPIRIT_LAZY_HPP
0011 
0012 ////////////////////////////////////////////////////////////////////////////////
0013 #include <boost/spirit/home/classic/namespace.hpp>
0014 #include <boost/spirit/home/classic/core/parser.hpp>
0015 #include <boost/spirit/home/classic/phoenix/actor.hpp>
0016 
0017 ////////////////////////////////////////////////////////////////////////////////
0018 
0019 namespace boost { namespace spirit {
0020 
0021 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0022 
0023     ////////////////////////////////////////////////////////////////////////////
0024     //
0025     // lazy_parser, holds phoenix actor which returns a spirit parser.
0026     //
0027     ////////////////////////////////////////////////////////////////////////////
0028 
0029     template<class ActorT>
0030     struct lazy_parser : parser<lazy_parser<ActorT> >
0031     {
0032         typedef lazy_parser<ActorT> self_t;
0033         typedef typename ::phoenix::actor_result<
0034             ActorT, ::phoenix::tuple<> >::plain_type actor_result_t;
0035 
0036         template<typename ScannerT>
0037         struct result
0038         {
0039             typedef typename
0040                 parser_result<actor_result_t, ScannerT>::type
0041             type;
0042         };
0043 
0044         lazy_parser(ActorT const& actor_)
0045         : actor(actor_) {}
0046 
0047         template<typename ScannerT>
0048         typename parser_result<self_t, ScannerT>::type
0049         parse(ScannerT const& scan) const
0050         { return actor().parse(scan); }
0051 
0052         ActorT actor;
0053     };
0054 
0055     //////////////////////////////
0056     // lazy_p, returns lazy_parser
0057     // Usage: lazy_p(actor)
0058     template<class ActorT>
0059     lazy_parser<ActorT> lazy_p(ActorT const& actor)
0060     { return lazy_parser<ActorT>(actor); }
0061 
0062 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0063 
0064 }} // namespace BOOST_SPIRIT_CLASSIC_NS
0065 
0066 #endif // BOOST_SPIRIT_LAZY_HPP