1 /*=============================================================================
2 Copyright (c) 2003 Joel de Guzman
3 Copyright (c) 2003 Vaclav Vesely
4 http://spirit.sourceforge.net/
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #ifndef BOOST_SPIRIT_LAZY_HPP
10 #define BOOST_SPIRIT_LAZY_HPP
12 ////////////////////////////////////////////////////////////////////////////////
13 #include <boost/spirit/home/classic/namespace.hpp>
14 #include <boost/spirit/home/classic/core/parser.hpp>
15 #include <boost/spirit/home/classic/phoenix/actor.hpp>
17 ////////////////////////////////////////////////////////////////////////////////
19 namespace boost { namespace spirit {
21 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
23 ////////////////////////////////////////////////////////////////////////////
25 // lazy_parser, holds phoenix actor which returns a spirit parser.
27 ////////////////////////////////////////////////////////////////////////////
29 template<class ActorT>
30 struct lazy_parser : parser<lazy_parser<ActorT> >
32 typedef lazy_parser<ActorT> self_t;
33 typedef typename ::phoenix::actor_result<
34 ActorT, ::phoenix::tuple<> >::plain_type actor_result_t;
36 template<typename ScannerT>
40 parser_result<actor_result_t, ScannerT>::type
44 lazy_parser(ActorT const& actor_)
47 template<typename ScannerT>
48 typename parser_result<self_t, ScannerT>::type
49 parse(ScannerT const& scan) const
50 { return actor().parse(scan); }
55 //////////////////////////////
56 // lazy_p, returns lazy_parser
57 // Usage: lazy_p(actor)
58 template<class ActorT>
59 lazy_parser<ActorT> lazy_p(ActorT const& actor)
60 { return lazy_parser<ActorT>(actor); }
62 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
64 }} // namespace BOOST_SPIRIT_CLASSIC_NS
66 #endif // BOOST_SPIRIT_LAZY_HPP