File indexing completed on 2025-01-19 09:47:34
0001
0002
0003
0004
0005
0006 #if !defined(BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM)
0007 #define BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM
0008
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012
0013 #include <boost/spirit/home/support/common_terminals.hpp>
0014 #include <boost/spirit/home/support/info.hpp>
0015 #include <boost/spirit/home/karma/domain.hpp>
0016 #include <boost/spirit/home/karma/meta_compiler.hpp>
0017 #include <boost/spirit/home/karma/delimit_out.hpp>
0018 #include <boost/spirit/home/support/unused.hpp>
0019 #include <boost/fusion/include/at.hpp>
0020
0021 namespace boost { namespace spirit
0022 {
0023
0024
0025
0026
0027
0028 template <>
0029 struct use_terminal<karma::domain, tag::eps>
0030 : mpl::true_ {};
0031
0032
0033 template <typename A0>
0034 struct use_terminal<karma::domain
0035 , terminal_ex<tag::eps, fusion::vector1<A0> > >
0036 : is_convertible<A0, bool> {};
0037
0038
0039 template <>
0040 struct use_lazy_terminal<karma::domain, tag::eps, 1>
0041 : mpl::true_ {};
0042
0043 }}
0044
0045
0046 namespace boost { namespace spirit { namespace karma
0047 {
0048 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0049 using boost::spirit::eps;
0050 #endif
0051 using boost::spirit::eps_type;
0052
0053 struct eps_generator : primitive_generator<eps_generator>
0054 {
0055 template <typename Context, typename Unused>
0056 struct attribute
0057 {
0058 typedef unused_type type;
0059 };
0060
0061 template <
0062 typename OutputIterator, typename Context, typename Delimiter
0063 , typename Attribute>
0064 static bool generate(OutputIterator& sink, Context&, Delimiter const& d
0065 , Attribute const& )
0066 {
0067 return karma::delimit_out(sink, d);
0068 }
0069
0070 template <typename Context>
0071 info what(Context const& ) const
0072 {
0073 return info("eps");
0074 }
0075 };
0076
0077 struct semantic_predicate : primitive_generator<semantic_predicate>
0078 {
0079 template <typename Context, typename Unused>
0080 struct attribute
0081 {
0082 typedef unused_type type;
0083 };
0084
0085 semantic_predicate(bool predicate)
0086 : predicate_(predicate)
0087 {}
0088
0089 template <
0090 typename OutputIterator, typename Context, typename Delimiter
0091 , typename Attribute>
0092 bool generate(OutputIterator& sink, Context&, Delimiter const& d
0093 , Attribute const& ) const
0094 {
0095
0096 return predicate_ && karma::delimit_out(sink, d);
0097 }
0098
0099 template <typename Context>
0100 info what(Context const& ) const
0101 {
0102 return info("semantic-predicate");
0103 }
0104
0105 bool predicate_;
0106 };
0107
0108
0109
0110
0111 template <typename Modifiers>
0112 struct make_primitive<tag::eps, Modifiers>
0113 {
0114 typedef eps_generator result_type;
0115 result_type operator()(unused_type, unused_type) const
0116 {
0117 return result_type();
0118 }
0119 };
0120
0121 template <typename Modifiers, typename A0>
0122 struct make_primitive<
0123 terminal_ex<tag::eps, fusion::vector1<A0> >
0124 , Modifiers>
0125 {
0126 typedef semantic_predicate result_type;
0127
0128 template <typename Terminal>
0129 result_type operator()(Terminal const& term, unused_type) const
0130 {
0131 return result_type(fusion::at_c<0>(term.args));
0132 }
0133 };
0134
0135 }}}
0136
0137 #endif