sl@0: /*============================================================================= sl@0: Copyright (c) 2003 Joel de Guzman sl@0: Copyright (c) 2003 Vaclav Vesely sl@0: http://spirit.sourceforge.net/ sl@0: sl@0: Use, modification and distribution is subject to the Boost Software sl@0: License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at sl@0: http://www.boost.org/LICENSE_1_0.txt) sl@0: =============================================================================*/ sl@0: #ifndef BOOST_SPIRIT_LAZY_HPP sl@0: #define BOOST_SPIRIT_LAZY_HPP sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////// sl@0: #include sl@0: #include sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: namespace boost { namespace spirit sl@0: { sl@0: //////////////////////////////////////////////////////////////////////////// sl@0: // sl@0: // lazy_parser, holds phoenix actor which returns a spirit parser. sl@0: // sl@0: //////////////////////////////////////////////////////////////////////////// sl@0: sl@0: template sl@0: struct lazy_parser : parser > sl@0: { sl@0: typedef lazy_parser self_t; sl@0: typedef typename phoenix::actor_result< sl@0: ActorT, phoenix::tuple<> >::plain_type actor_result_t; sl@0: sl@0: template sl@0: struct result sl@0: { sl@0: typedef typename sl@0: parser_result::type sl@0: type; sl@0: }; sl@0: sl@0: lazy_parser(ActorT const& actor_) sl@0: : actor(actor_) {} sl@0: sl@0: template sl@0: typename parser_result::type sl@0: parse(ScannerT const& scan) const sl@0: { return actor().parse(scan); } sl@0: sl@0: ActorT actor; sl@0: }; sl@0: sl@0: ////////////////////////////// sl@0: // lazy_p, returns lazy_parser sl@0: // Usage: lazy_p(actor) sl@0: template sl@0: lazy_parser lazy_p(ActorT const& actor) sl@0: { return lazy_parser(actor); } sl@0: sl@0: }} // namespace boost::spirit sl@0: sl@0: #endif // BOOST_SPIRIT_LAZY_HPP