First public contribution.
1 /*=============================================================================
2 Copyright (c) 2003 Joel de Guzman
3 Copyright (c) 2003 Vaclav Vesely
4 http://spirit.sourceforge.net/
6 Use, modification and distribution is subject to the Boost Software
7 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 http://www.boost.org/LICENSE_1_0.txt)
9 =============================================================================*/
10 #ifndef BOOST_SPIRIT_LAZY_HPP
11 #define BOOST_SPIRIT_LAZY_HPP
13 ////////////////////////////////////////////////////////////////////////////////
14 #include <boost/spirit/core/parser.hpp>
15 #include <boost/spirit/phoenix/actor.hpp>
17 ////////////////////////////////////////////////////////////////////////////////
19 namespace boost { namespace spirit
21 ////////////////////////////////////////////////////////////////////////////
23 // lazy_parser, holds phoenix actor which returns a spirit parser.
25 ////////////////////////////////////////////////////////////////////////////
27 template<class ActorT>
28 struct lazy_parser : parser<lazy_parser<ActorT> >
30 typedef lazy_parser<ActorT> self_t;
31 typedef typename phoenix::actor_result<
32 ActorT, phoenix::tuple<> >::plain_type actor_result_t;
34 template<typename ScannerT>
38 parser_result<actor_result_t, ScannerT>::type
42 lazy_parser(ActorT const& actor_)
45 template<typename ScannerT>
46 typename parser_result<self_t, ScannerT>::type
47 parse(ScannerT const& scan) const
48 { return actor().parse(scan); }
53 //////////////////////////////
54 // lazy_p, returns lazy_parser
55 // Usage: lazy_p(actor)
56 template<class ActorT>
57 lazy_parser<ActorT> lazy_p(ActorT const& actor)
58 { return lazy_parser<ActorT>(actor); }
60 }} // namespace boost::spirit
62 #endif // BOOST_SPIRIT_LAZY_HPP