Back to home page

EIC code displayed by LXR

 
 

    


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

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_ALTERNATIVE_JAN_07_2013_1131AM)
0008 #define BOOST_SPIRIT_X3_ALTERNATIVE_JAN_07_2013_1131AM
0009 
0010 #include <boost/spirit/home/x3/support/traits/attribute_of_binary.hpp>
0011 #include <boost/spirit/home/x3/core/parser.hpp>
0012 #include <boost/spirit/home/x3/operator/detail/alternative.hpp>
0013 
0014 #include <boost/variant/variant_fwd.hpp>
0015 
0016 namespace boost { namespace spirit { namespace x3
0017 {
0018     template <typename Left, typename Right>
0019     struct alternative : binary_parser<Left, Right, alternative<Left, Right>>
0020     {
0021         typedef binary_parser<Left, Right, alternative<Left, Right>> base_type;
0022 
0023         constexpr alternative(Left const& left, Right const& right)
0024             : base_type(left, right) {}
0025 
0026         template <typename Iterator, typename Context, typename RContext>
0027         bool parse(
0028             Iterator& first, Iterator const& last
0029           , Context const& context, RContext& rcontext, unused_type) const
0030         {
0031             return this->left.parse(first, last, context, rcontext, unused)
0032                || this->right.parse(first, last, context, rcontext, unused);
0033         }
0034 
0035         template <typename Iterator, typename Context
0036           , typename RContext, typename Attribute>
0037         bool parse(
0038             Iterator& first, Iterator const& last
0039           , Context const& context, RContext& rcontext, Attribute& attr) const
0040         {
0041             return detail::parse_alternative(this->left, first, last, context, rcontext, attr)
0042                || detail::parse_alternative(this->right, first, last, context, rcontext, attr);
0043         }
0044     };
0045 
0046     template <typename Left, typename Right>
0047     constexpr alternative<
0048         typename extension::as_parser<Left>::value_type
0049       , typename extension::as_parser<Right>::value_type>
0050     operator|(Left const& left, Right const& right)
0051     {
0052         return { as_parser(left), as_parser(right) };
0053     }
0054 }}}
0055 
0056 namespace boost { namespace spirit { namespace x3 { namespace traits
0057 {
0058     template <typename Left, typename Right, typename Context>
0059     struct attribute_of<x3::alternative<Left, Right>, Context>
0060         : x3::detail::attribute_of_binary<boost::variant, x3::alternative, Left, Right, Context> {};
0061 }}}}
0062 
0063 #endif