1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #if !defined(SPIRIT_AND_PREDICATE_MARCH_23_2007_0617PM)
8 #define SPIRIT_AND_PREDICATE_MARCH_23_2007_0617PM
14 #include <boost/spirit/home/qi/domain.hpp>
15 #include <boost/spirit/home/qi/meta_compiler.hpp>
16 #include <boost/spirit/home/qi/parser.hpp>
17 #include <boost/spirit/home/qi/detail/attributes.hpp>
18 #include <boost/spirit/home/support/info.hpp>
19 #include <boost/spirit/home/support/has_semantic_action.hpp>
20 #include <boost/spirit/home/support/handles_container.hpp>
21 #include <boost/fusion/include/at.hpp>
23 namespace boost { namespace spirit
25 ///////////////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////////////
29 struct use_operator<qi::domain, proto::tag::address_of> // enables &p
33 namespace boost { namespace spirit { namespace qi
35 template <typename Subject>
36 struct and_predicate : unary_parser<and_predicate<Subject> >
38 typedef Subject subject_type;
40 template <typename Context, typename Iterator>
43 typedef unused_type type;
46 and_predicate(Subject const& subject_)
47 : subject(subject_) {}
49 template <typename Iterator, typename Context
50 , typename Skipper, typename Attribute>
51 bool parse(Iterator& first, Iterator const& last
52 , Context& context, Skipper const& skipper
53 , Attribute& /*attr*/) const
56 return subject.parse(i, last, context, skipper, unused);
59 template <typename Context>
60 info what(Context& context) const
62 return info("and-predicate", subject.what(context));
68 ///////////////////////////////////////////////////////////////////////////
69 // Parser generators: make_xxx function (objects)
70 ///////////////////////////////////////////////////////////////////////////
71 template <typename Elements, typename Modifiers>
72 struct make_composite<proto::tag::address_of, Elements, Modifiers>
73 : make_unary_composite<Elements, and_predicate>
77 namespace boost { namespace spirit { namespace traits
79 ///////////////////////////////////////////////////////////////////////////
80 template <typename Subject>
81 struct has_semantic_action<qi::and_predicate<Subject> >
82 : unary_has_semantic_action<Subject> {};
84 ///////////////////////////////////////////////////////////////////////////
85 template <typename Subject, typename Attribute, typename Context
87 struct handles_container<qi::and_predicate<Subject>, Attribute, Context
89 : unary_handles_container<Subject, Attribute, Context, Iterator> {};