os/ossrv/ossrv_pub/boost_apis/boost/spirit/dynamic/lazy.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*=============================================================================
sl@0
     2
    Copyright (c) 2003 Joel de Guzman
sl@0
     3
    Copyright (c) 2003 Vaclav Vesely
sl@0
     4
    http://spirit.sourceforge.net/
sl@0
     5
sl@0
     6
    Use, modification and distribution is subject to the Boost Software
sl@0
     7
    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
sl@0
     8
    http://www.boost.org/LICENSE_1_0.txt)
sl@0
     9
=============================================================================*/
sl@0
    10
#ifndef BOOST_SPIRIT_LAZY_HPP
sl@0
    11
#define BOOST_SPIRIT_LAZY_HPP
sl@0
    12
sl@0
    13
////////////////////////////////////////////////////////////////////////////////
sl@0
    14
#include <boost/spirit/core/parser.hpp>
sl@0
    15
#include <boost/spirit/phoenix/actor.hpp>
sl@0
    16
sl@0
    17
////////////////////////////////////////////////////////////////////////////////
sl@0
    18
sl@0
    19
namespace boost { namespace spirit
sl@0
    20
{
sl@0
    21
    ////////////////////////////////////////////////////////////////////////////
sl@0
    22
    //
sl@0
    23
    // lazy_parser, holds phoenix actor which returns a spirit parser.
sl@0
    24
    //
sl@0
    25
    ////////////////////////////////////////////////////////////////////////////
sl@0
    26
sl@0
    27
    template<class ActorT>
sl@0
    28
    struct lazy_parser : parser<lazy_parser<ActorT> >
sl@0
    29
    {
sl@0
    30
        typedef lazy_parser<ActorT> self_t;
sl@0
    31
        typedef typename phoenix::actor_result<
sl@0
    32
            ActorT, phoenix::tuple<> >::plain_type actor_result_t;
sl@0
    33
sl@0
    34
        template<typename ScannerT>
sl@0
    35
        struct result
sl@0
    36
        {
sl@0
    37
            typedef typename
sl@0
    38
                parser_result<actor_result_t, ScannerT>::type
sl@0
    39
            type;
sl@0
    40
        };
sl@0
    41
sl@0
    42
        lazy_parser(ActorT const& actor_)
sl@0
    43
        : actor(actor_) {}
sl@0
    44
sl@0
    45
        template<typename ScannerT>
sl@0
    46
        typename parser_result<self_t, ScannerT>::type
sl@0
    47
        parse(ScannerT const& scan) const
sl@0
    48
        { return actor().parse(scan); }
sl@0
    49
sl@0
    50
        ActorT actor;
sl@0
    51
    };
sl@0
    52
sl@0
    53
    //////////////////////////////
sl@0
    54
    // lazy_p, returns lazy_parser
sl@0
    55
    // Usage: lazy_p(actor)
sl@0
    56
    template<class ActorT>
sl@0
    57
    lazy_parser<ActorT> lazy_p(ActorT const& actor)
sl@0
    58
    { return lazy_parser<ActorT>(actor); }
sl@0
    59
sl@0
    60
}} // namespace boost::spirit
sl@0
    61
sl@0
    62
#endif // BOOST_SPIRIT_LAZY_HPP