Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:37

0001 /*=============================================================================
0002     Copyright (c) 2001-2014 Joel de Guzman
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 =============================================================================*/
0007 #if !defined(BOOST_SPIRIT_X3_DIFFERENCE_FEBRUARY_11_2007_1250PM)
0008 #define BOOST_SPIRIT_X3_DIFFERENCE_FEBRUARY_11_2007_1250PM
0009 
0010 #include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
0011 #include <boost/spirit/home/x3/support/traits/has_attribute.hpp>
0012 #include <boost/spirit/home/x3/core/parser.hpp>
0013 
0014 namespace boost { namespace spirit { namespace x3
0015 {
0016     template <typename Left, typename Right>
0017     struct difference : binary_parser<Left, Right, difference<Left, Right>>
0018     {
0019         typedef binary_parser<Left, Right, difference<Left, Right>> base_type;
0020         static bool const handles_container = Left::handles_container;
0021 
0022         constexpr difference(Left const& left, Right const& right)
0023           : base_type(left, right) {}
0024 
0025         template <typename Iterator, typename Context
0026           , typename RContext, typename Attribute>
0027         bool parse(Iterator& first, Iterator const& last
0028           , Context const& context, RContext& rcontext, Attribute& attr) const
0029         {
0030             // Try Right first
0031             Iterator start = first;
0032             if (this->right.parse(first, last, context, rcontext, unused))
0033             {
0034                 // Right succeeds, we fail.
0035                 first = start;
0036                 return false;
0037             }
0038             // Right fails, now try Left
0039             return this->left.parse(first, last, context, rcontext, attr);
0040         }
0041 
0042         template <typename Left_, typename Right_>
0043         constexpr difference<Left_, Right_>
0044         make(Left_ const& left, Right_ const& right) const
0045         {
0046             return { left, right };
0047         }
0048     };
0049 
0050     template <typename Left, typename Right>
0051     constexpr difference<
0052         typename extension::as_parser<Left>::value_type
0053       , typename extension::as_parser<Right>::value_type>
0054     operator-(Left const& left, Right const& right)
0055     {
0056         return { as_parser(left), as_parser(right) };
0057     }
0058 }}}
0059 
0060 namespace boost { namespace spirit { namespace x3 { namespace traits
0061 {
0062     template <typename Left, typename Right, typename Context>
0063     struct attribute_of<x3::difference<Left, Right>, Context>
0064         : attribute_of<Left, Context> {};
0065 
0066     template <typename Left, typename Right, typename Context>
0067     struct has_attribute<x3::difference<Left, Right>, Context>
0068         : has_attribute<Left, Context> {};
0069 }}}}
0070 
0071 #endif