Warning, file /include/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_PARSER_BINDER_DECEMBER_05_2008_0516_PM)
0008 #define BOOST_SPIRIT_PARSER_BINDER_DECEMBER_05_2008_0516_PM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/fusion/include/at.hpp>
0015 #include <boost/mpl/bool.hpp>
0016 #include <boost/spirit/home/support/has_semantic_action.hpp>
0017
0018 namespace boost { namespace spirit { namespace qi { namespace detail
0019 {
0020
0021 template <typename Parser, typename Auto>
0022 struct parser_binder
0023 {
0024 parser_binder(Parser const& p_)
0025 : p(p_) {}
0026
0027 template <typename Iterator, typename Skipper, typename Context>
0028 bool call(Iterator& first, Iterator const& last
0029 , Context& context, Skipper const& skipper, mpl::true_) const
0030 {
0031
0032
0033 return p.parse(first, last, context, skipper, unused);
0034 }
0035
0036 template <typename Iterator, typename Skipper, typename Context>
0037 bool call(Iterator& first, Iterator const& last
0038 , Context& context, Skipper const& skipper, mpl::false_) const
0039 {
0040
0041
0042 return p.parse(first, last, context, skipper
0043 , fusion::at_c<0>(context.attributes));
0044 }
0045
0046 template <typename Iterator, typename Skipper, typename Context>
0047 bool operator()(
0048 Iterator& first, Iterator const& last
0049 , Context& context, Skipper const& skipper) const
0050 {
0051
0052 typedef typename traits::has_semantic_action<Parser>::type auto_rule;
0053 return call(first, last, context, skipper, auto_rule());
0054 }
0055
0056 Parser p;
0057 };
0058
0059
0060 template <typename Parser>
0061 struct parser_binder<Parser, mpl::true_>
0062 {
0063 parser_binder(Parser const& p_)
0064 : p(p_) {}
0065
0066 template <typename Iterator, typename Skipper, typename Context>
0067 bool operator()(
0068 Iterator& first, Iterator const& last
0069 , Context& context, Skipper const& skipper) const
0070 {
0071
0072 return p.parse(first, last, context, skipper
0073 , fusion::at_c<0>(context.attributes));
0074 }
0075
0076 Parser p;
0077 };
0078
0079 template <typename Auto, typename Parser>
0080 inline parser_binder<Parser, Auto>
0081 bind_parser(Parser const& p)
0082 {
0083 return parser_binder<Parser, Auto>(p);
0084 }
0085 }}}}
0086
0087 #endif