liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*=============================================================================
    Copyright (c) 2001-2011 Hartmut Kaiser
    Copyright (c) 2001-2011 Joel de Guzman
 
    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#if !defined(BOOST_SPIRIT_MATCH_MANIP_MAY_05_2007_1202PM)
#define BOOST_SPIRIT_MATCH_MANIP_MAY_05_2007_1202PM
 
#if defined(_MSC_VER)
#pragma once
#endif
 
#include <boost/spirit/home/qi/parse.hpp>
#include <boost/spirit/home/qi/parser.hpp>
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/qi/stream/detail/match_manip.hpp>
 
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace qi
{
    ///////////////////////////////////////////////////////////////////////////
    template <typename Expr>
    inline typename detail::match<Expr>::type
    match(
        Expr const& expr)
    {
        return detail::match<Expr>::call(expr);
    }
 
    template <typename Expr, typename Attribute>
    inline detail::match_manip<
        Expr, mpl::false_, mpl::false_, unused_type, Attribute
    >
    match(
        Expr const& xpr
      , Attribute& p)
    {
        using qi::detail::match_manip;
 
        // Report invalid expression error as early as possible.
        // If you got an error_invalid_expression error message here,
        // then the expression (expr) is not a valid spirit qi expression.
        BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
        return match_manip<Expr, mpl::false_, mpl::false_, unused_type, Attribute>(
            xpr, unused, p);
    }
 
    ///////////////////////////////////////////////////////////////////////////
    template <typename Expr, typename Skipper>
    inline typename detail::phrase_match<Expr, Skipper>::type 
    phrase_match(
        Expr const& expr
      , Skipper const& s
      , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
    {
        return detail::phrase_match<Expr, Skipper>::call(expr, s, post_skip);
    }
 
    template <typename Expr, typename Skipper, typename Attribute>
    inline detail::match_manip<
        Expr, mpl::false_, mpl::false_, Skipper, Attribute
    >
    phrase_match(
        Expr const& xpr
      , Skipper const& s
      , BOOST_SCOPED_ENUM(skip_flag) post_skip
      , Attribute& p)
    {
        using qi::detail::match_manip;
 
        // Report invalid expression error as early as possible.
        // If you got an error_invalid_expression error message here,
        // then either the expression (expr) or skipper is not a valid
        // spirit qi expression.
        BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
        BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
        return match_manip<Expr, mpl::false_, mpl::false_, Skipper, Attribute>(
            xpr, s, post_skip, p);
    }
 
    template <typename Expr, typename Skipper, typename Attribute>
    inline detail::match_manip<
        Expr, mpl::false_, mpl::false_, Skipper, Attribute
    >
    phrase_match(
        Expr const& xpr
      , Skipper const& s
      , Attribute& p)
    {
        using qi::detail::match_manip;
 
        // Report invalid expression error as early as possible.
        // If you got an error_invalid_expression error message here,
        // then either the expression (expr) or skipper is not a valid
        // spirit qi expression.
        BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr);
        BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper);
        return match_manip<Expr, mpl::false_, mpl::false_, Skipper, Attribute>(
            xpr, s, p);
    }
 
    ///////////////////////////////////////////////////////////////////////////
    template<typename Char, typename Traits, typename Derived>
    inline std::basic_istream<Char, Traits>&
    operator>>(std::basic_istream<Char, Traits>& is, parser<Derived> const& p)
    {
        typedef spirit::basic_istream_iterator<Char, Traits> input_iterator;
 
        input_iterator f(is);
        input_iterator l;
        if (!p.derived().parse(f, l, unused, unused, unused))
        {
            is.setstate(std::ios_base::failbit);
        }
        return is;
    }
 
}}}
 
#endif