Back to home page

EIC code displayed by LXR

 
 

    


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

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_EPS_MARCH_23_2007_0454PM)
0008 #define BOOST_SPIRIT_X3_EPS_MARCH_23_2007_0454PM
0009 
0010 #include <boost/spirit/home/x3/core/skip_over.hpp>
0011 #include <boost/spirit/home/x3/core/parser.hpp>
0012 #include <boost/spirit/home/x3/support/unused.hpp>
0013 
0014 namespace boost { namespace spirit { namespace x3
0015 {
0016     struct rule_context_tag;
0017 
0018     struct semantic_predicate : parser<semantic_predicate>
0019     {
0020         typedef unused_type attribute_type;
0021         static bool const has_attribute = false;
0022 
0023         constexpr semantic_predicate(bool predicate)
0024           : predicate(predicate) {}
0025 
0026         template <typename Iterator, typename Context, typename Attribute>
0027         bool parse(Iterator& first, Iterator const& last
0028           , Context const& context, unused_type, Attribute&) const
0029         {
0030             x3::skip_over(first, last, context);
0031             return predicate;
0032         }
0033 
0034         bool predicate;
0035     };
0036 
0037     template <typename F>
0038     struct lazy_semantic_predicate : parser<lazy_semantic_predicate<F>>
0039     {
0040         typedef unused_type attribute_type;
0041         static bool const has_attribute = false;
0042 
0043         constexpr lazy_semantic_predicate(F f)
0044           : f(f) {}
0045 
0046         template <typename Iterator, typename Context, typename Attribute>
0047         bool parse(Iterator& first, Iterator const& last
0048           , Context const& context, unused_type, Attribute& /* attr */) const
0049         {
0050             x3::skip_over(first, last, context);
0051             return f(x3::get<rule_context_tag>(context));
0052         }
0053 
0054         F f;
0055     };
0056 
0057     struct eps_parser : parser<eps_parser>
0058     {
0059         typedef unused_type attribute_type;
0060         static bool const has_attribute = false;
0061 
0062         template <typename Iterator, typename Context
0063           , typename RuleContext, typename Attribute>
0064         bool parse(Iterator& first, Iterator const& last
0065           , Context const& context, RuleContext&, Attribute&) const
0066         {
0067             x3::skip_over(first, last, context);
0068             return true;
0069         }
0070 
0071         constexpr semantic_predicate operator()(bool predicate) const
0072         {
0073             return { predicate };
0074         }
0075 
0076         template <typename F>
0077         constexpr lazy_semantic_predicate<F> operator()(F f) const
0078         {
0079             return { f };
0080         }
0081     };
0082 
0083     constexpr auto eps = eps_parser{};
0084 }}}
0085 
0086 #endif