]>
Commit | Line | Data |
---|---|---|
1 | /*============================================================================= | |
2 | Copyright (c) 2001-2011 Hartmut Kaiser | |
3 | Copyright (c) 2001-2011 Joel de Guzman | |
4 | ||
5 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ==============================================================================*/ | |
8 | #if !defined(BOOST_PP_IS_ITERATING) | |
9 | ||
10 | #if !defined(BOOST_SPIRIT_MATCH_MANIP_ATTR_MAY_05_2007_1202PM) | |
11 | #define BOOST_SPIRIT_MATCH_MANIP_ATTR_MAY_05_2007_1202PM | |
12 | ||
13 | #include <boost/spirit/home/qi/stream/match_manip.hpp> | |
14 | ||
15 | #include <boost/fusion/include/vector.hpp> | |
16 | #include <boost/preprocessor/iterate.hpp> | |
17 | #include <boost/preprocessor/repetition/enum.hpp> | |
18 | #include <boost/preprocessor/repetition/enum_params.hpp> | |
19 | #include <boost/preprocessor/repetition/enum_binary_params.hpp> | |
20 | ||
21 | #define BOOST_PP_FILENAME_1 \ | |
22 | <boost/spirit/home/qi/stream/match_manip_attr.hpp> | |
23 | #define BOOST_PP_ITERATION_LIMITS (2, SPIRIT_ARGUMENTS_LIMIT) | |
24 | #include BOOST_PP_ITERATE() | |
25 | ||
26 | #endif | |
27 | ||
28 | /////////////////////////////////////////////////////////////////////////////// | |
29 | // | |
30 | // Preprocessor vertical repetition code | |
31 | // | |
32 | /////////////////////////////////////////////////////////////////////////////// | |
33 | #else // defined(BOOST_PP_IS_ITERATING) | |
34 | ||
35 | #define N BOOST_PP_ITERATION() | |
36 | #define BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE(z, n, A) BOOST_PP_CAT(A, n) & | |
37 | ||
38 | /////////////////////////////////////////////////////////////////////////////// | |
39 | namespace boost { namespace spirit { namespace qi | |
40 | { | |
41 | /////////////////////////////////////////////////////////////////////////// | |
42 | template <typename Expr, BOOST_PP_ENUM_PARAMS(N, typename A)> | |
43 | inline detail::match_manip<Expr, mpl::false_, mpl::true_, unused_type | |
44 | , fusion::vector< | |
45 | BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) | |
46 | > > | |
47 | match( | |
48 | Expr const& xpr | |
49 | , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr)) | |
50 | { | |
51 | using qi::detail::match_manip; | |
52 | ||
53 | // Report invalid expression error as early as possible. | |
54 | // If you got an error_invalid_expression error message here, | |
55 | // then the expression (expr) is not a valid spirit qi expression. | |
56 | BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr); | |
57 | ||
58 | typedef fusion::vector< | |
59 | BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) | |
60 | > vector_type; | |
61 | ||
62 | vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr)); | |
63 | return match_manip<Expr, mpl::false_, mpl::true_, unused_type, vector_type>( | |
64 | xpr, unused, attr); | |
65 | } | |
66 | ||
67 | /////////////////////////////////////////////////////////////////////////// | |
68 | template <typename Expr, typename Skipper | |
69 | , BOOST_PP_ENUM_PARAMS(N, typename A)> | |
70 | inline detail::match_manip<Expr, mpl::false_, mpl::true_, Skipper | |
71 | , fusion::vector< | |
72 | BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) | |
73 | > > | |
74 | phrase_match( | |
75 | Expr const& xpr | |
76 | , Skipper const& s | |
77 | , BOOST_SCOPED_ENUM(skip_flag) post_skip | |
78 | , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr)) | |
79 | { | |
80 | using qi::detail::match_manip; | |
81 | ||
82 | // Report invalid expression error as early as possible. | |
83 | // If you got an error_invalid_expression error message here, | |
84 | // then either the expression (expr) or skipper is not a valid | |
85 | // spirit qi expression. | |
86 | BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr); | |
87 | BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper); | |
88 | ||
89 | typedef fusion::vector< | |
90 | BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) | |
91 | > vector_type; | |
92 | ||
93 | vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr)); | |
94 | return match_manip<Expr, mpl::false_, mpl::true_, Skipper, vector_type>( | |
95 | xpr, s, post_skip, attr); | |
96 | } | |
97 | ||
98 | template <typename Expr, typename Skipper | |
99 | , BOOST_PP_ENUM_PARAMS(N, typename A)> | |
100 | inline detail::match_manip<Expr, mpl::false_, mpl::true_, Skipper | |
101 | , fusion::vector< | |
102 | BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) | |
103 | > > | |
104 | phrase_match( | |
105 | Expr const& xpr | |
106 | , Skipper const& s | |
107 | , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr)) | |
108 | { | |
109 | using qi::detail::match_manip; | |
110 | ||
111 | // Report invalid expression error as early as possible. | |
112 | // If you got an error_invalid_expression error message here, | |
113 | // then either the expression (expr) or skipper is not a valid | |
114 | // spirit qi expression. | |
115 | BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Expr); | |
116 | BOOST_SPIRIT_ASSERT_MATCH(qi::domain, Skipper); | |
117 | ||
118 | typedef fusion::vector< | |
119 | BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) | |
120 | > vector_type; | |
121 | ||
122 | vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr)); | |
123 | return match_manip<Expr, mpl::false_, mpl::true_, Skipper, vector_type>( | |
124 | xpr, s, attr); | |
125 | } | |
126 | ||
127 | }}} | |
128 | ||
129 | #undef BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE | |
130 | #undef N | |
131 | ||
132 | #endif | |
133 |