| /*============================================================================= |
| Copyright (c) 2001-2010 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(SPIRIT_NOT_PREDICATE_MARCH_23_2007_0618PM) |
| #define SPIRIT_NOT_PREDICATE_MARCH_23_2007_0618PM |
| |
| #if defined(_MSC_VER) |
| #pragma once |
| #endif |
| |
| #include <boost/spirit/home/qi/domain.hpp> |
| #include <boost/spirit/home/qi/meta_compiler.hpp> |
| #include <boost/spirit/home/qi/parser.hpp> |
| #include <boost/spirit/home/qi/detail/attributes.hpp> |
| #include <boost/spirit/home/support/info.hpp> |
| |
| namespace boost { namespace spirit |
| { |
| /////////////////////////////////////////////////////////////////////////// |
| // Enablers |
| /////////////////////////////////////////////////////////////////////////// |
| template <> |
| struct use_operator<qi::domain, proto::tag::logical_not> // enables !p |
| : mpl::true_ {}; |
| }} |
| |
| namespace boost { namespace spirit { namespace qi |
| { |
| template <typename Subject> |
| struct not_predicate : unary_parser<not_predicate<Subject> > |
| { |
| typedef Subject subject_type; |
| |
| template <typename Context, typename Iterator> |
| struct attribute |
| { |
| typedef unused_type type; |
| }; |
| |
| not_predicate(Subject const& subject) |
| : subject(subject) {} |
| |
| template <typename Iterator, typename Context |
| , typename Skipper, typename Attribute> |
| bool parse(Iterator& first, Iterator const& last |
| , Context& context, Skipper const& skipper |
| , Attribute& /*attr*/) const |
| { |
| Iterator i = first; |
| return !subject.parse(i, last, context, skipper, unused); |
| } |
| |
| template <typename Context> |
| info what(Context& context) const |
| { |
| return info("not-predicate", subject.what(context)); |
| } |
| |
| Subject subject; |
| }; |
| |
| /////////////////////////////////////////////////////////////////////////// |
| // Parser generators: make_xxx function (objects) |
| /////////////////////////////////////////////////////////////////////////// |
| template <typename Elements, typename Modifiers> |
| struct make_composite<proto::tag::logical_not, Elements, Modifiers> |
| : make_unary_composite<Elements, not_predicate> |
| {}; |
| }}} |
| |
| namespace boost { namespace spirit { namespace traits |
| { |
| template <typename Subject> |
| struct has_semantic_action<qi::not_predicate<Subject> > |
| : unary_has_semantic_action<Subject> {}; |
| }}} |
| |
| #endif |