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_NOT_PREDICATE_MARCH_23_2007_0618PM)
8
#define SPIRIT_NOT_PREDICATE_MARCH_23_2007_0618PM
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/has_semantic_action.hpp>
19
#include <boost/spirit/home/support/handles_container.hpp>
20
#include <boost/spirit/home/support/info.hpp>
22
namespace boost { namespace spirit
24
///////////////////////////////////////////////////////////////////////////
26
///////////////////////////////////////////////////////////////////////////
28
struct use_operator<qi::domain, proto::tag::logical_not> // enables !p
32
namespace boost { namespace spirit { namespace qi
34
template <typename Subject>
35
struct not_predicate : unary_parser<not_predicate<Subject> >
37
typedef Subject subject_type;
39
template <typename Context, typename Iterator>
42
typedef unused_type type;
45
not_predicate(Subject const& subject)
48
template <typename Iterator, typename Context
49
, typename Skipper, typename Attribute>
50
bool parse(Iterator& first, Iterator const& last
51
, Context& context, Skipper const& skipper
52
, Attribute& /*attr*/) const
55
return !subject.parse(i, last, context, skipper, unused);
58
template <typename Context>
59
info what(Context& context) const
61
return info("not-predicate", subject.what(context));
67
///////////////////////////////////////////////////////////////////////////
68
// Parser generators: make_xxx function (objects)
69
///////////////////////////////////////////////////////////////////////////
70
template <typename Elements, typename Modifiers>
71
struct make_composite<proto::tag::logical_not, Elements, Modifiers>
72
: make_unary_composite<Elements, not_predicate>
76
namespace boost { namespace spirit { namespace traits
78
///////////////////////////////////////////////////////////////////////////
79
template <typename Subject>
80
struct has_semantic_action<qi::not_predicate<Subject> >
81
: unary_has_semantic_action<Subject> {};
83
///////////////////////////////////////////////////////////////////////////
84
template <typename Subject, typename Attribute, typename Context
86
struct handles_container<qi::not_predicate<Subject>, Attribute
88
: unary_handles_container<Subject, Attribute, Context, Iterator> {};