annotate DEPENDENCIES/generic/include/boost/spirit/home/karma/auxiliary/eps.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 2 //
Chris@16 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5
Chris@16 6 #if !defined(BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM)
Chris@16 7 #define BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM
Chris@16 8
Chris@16 9 #if defined(_MSC_VER)
Chris@16 10 #pragma once
Chris@16 11 #endif
Chris@16 12
Chris@16 13 #include <boost/spirit/home/support/common_terminals.hpp>
Chris@16 14 #include <boost/spirit/home/support/info.hpp>
Chris@16 15 #include <boost/spirit/home/karma/domain.hpp>
Chris@16 16 #include <boost/spirit/home/karma/meta_compiler.hpp>
Chris@16 17 #include <boost/spirit/home/karma/delimit_out.hpp>
Chris@16 18 #include <boost/spirit/home/support/unused.hpp>
Chris@16 19 #include <boost/fusion/include/at.hpp>
Chris@16 20
Chris@16 21 namespace boost { namespace spirit
Chris@16 22 {
Chris@16 23 ///////////////////////////////////////////////////////////////////////////
Chris@16 24 // Enablers
Chris@16 25 ///////////////////////////////////////////////////////////////////////////
Chris@16 26
Chris@16 27 // enables eps
Chris@16 28 template <>
Chris@16 29 struct use_terminal<karma::domain, tag::eps>
Chris@16 30 : mpl::true_ {};
Chris@16 31
Chris@16 32 // enables eps(bool-condition)
Chris@16 33 template <typename A0>
Chris@16 34 struct use_terminal<karma::domain
Chris@16 35 , terminal_ex<tag::eps, fusion::vector1<A0> > >
Chris@16 36 : is_convertible<A0, bool> {};
Chris@16 37
Chris@16 38 // enables lazy eps(f)
Chris@16 39 template <>
Chris@16 40 struct use_lazy_terminal<karma::domain, tag::eps, 1>
Chris@16 41 : mpl::true_ {};
Chris@16 42
Chris@16 43 }}
Chris@16 44
Chris@16 45 ///////////////////////////////////////////////////////////////////////////////
Chris@16 46 namespace boost { namespace spirit { namespace karma
Chris@16 47 {
Chris@16 48 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
Chris@16 49 using boost::spirit::eps;
Chris@16 50 #endif
Chris@16 51 using boost::spirit::eps_type;
Chris@16 52
Chris@16 53 struct eps_generator : primitive_generator<eps_generator>
Chris@16 54 {
Chris@16 55 template <typename Context, typename Unused>
Chris@16 56 struct attribute
Chris@16 57 {
Chris@16 58 typedef unused_type type;
Chris@16 59 };
Chris@16 60
Chris@16 61 template <
Chris@16 62 typename OutputIterator, typename Context, typename Delimiter
Chris@16 63 , typename Attribute>
Chris@16 64 static bool generate(OutputIterator& sink, Context&, Delimiter const& d
Chris@16 65 , Attribute const& /*attr*/)
Chris@16 66 {
Chris@16 67 return karma::delimit_out(sink, d); // always do post-delimiting
Chris@16 68 }
Chris@16 69
Chris@16 70 template <typename Context>
Chris@16 71 info what(Context const& /*context*/) const
Chris@16 72 {
Chris@16 73 return info("eps");
Chris@16 74 }
Chris@16 75 };
Chris@16 76
Chris@16 77 struct semantic_predicate : primitive_generator<semantic_predicate>
Chris@16 78 {
Chris@16 79 template <typename Context, typename Unused>
Chris@16 80 struct attribute
Chris@16 81 {
Chris@16 82 typedef unused_type type;
Chris@16 83 };
Chris@16 84
Chris@16 85 semantic_predicate(bool predicate)
Chris@16 86 : predicate_(predicate)
Chris@16 87 {}
Chris@16 88
Chris@16 89 template <
Chris@16 90 typename OutputIterator, typename Context, typename Delimiter
Chris@16 91 , typename Attribute>
Chris@16 92 bool generate(OutputIterator& sink, Context&, Delimiter const& d
Chris@16 93 , Attribute const& /*attr*/) const
Chris@16 94 {
Chris@16 95 // only do post-delimiting when predicate is true
Chris@16 96 return predicate_ && karma::delimit_out(sink, d);
Chris@16 97 }
Chris@16 98
Chris@16 99 template <typename Context>
Chris@16 100 info what(Context const& /*context*/) const
Chris@16 101 {
Chris@16 102 return info("semantic-predicate");
Chris@16 103 }
Chris@16 104
Chris@16 105 bool predicate_;
Chris@16 106 };
Chris@16 107
Chris@16 108 ///////////////////////////////////////////////////////////////////////////
Chris@16 109 // Generator generators: make_xxx function (objects)
Chris@16 110 ///////////////////////////////////////////////////////////////////////////
Chris@16 111 template <typename Modifiers>
Chris@16 112 struct make_primitive<tag::eps, Modifiers>
Chris@16 113 {
Chris@16 114 typedef eps_generator result_type;
Chris@16 115 result_type operator()(unused_type, unused_type) const
Chris@16 116 {
Chris@16 117 return result_type();
Chris@16 118 }
Chris@16 119 };
Chris@16 120
Chris@16 121 template <typename Modifiers, typename A0>
Chris@16 122 struct make_primitive<
Chris@16 123 terminal_ex<tag::eps, fusion::vector1<A0> >
Chris@16 124 , Modifiers>
Chris@16 125 {
Chris@16 126 typedef semantic_predicate result_type;
Chris@16 127
Chris@16 128 template <typename Terminal>
Chris@16 129 result_type operator()(Terminal const& term, unused_type) const
Chris@16 130 {
Chris@16 131 return result_type(fusion::at_c<0>(term.args));
Chris@16 132 }
Chris@16 133 };
Chris@16 134
Chris@16 135 }}}
Chris@16 136
Chris@16 137 #endif