// Copyright (c) 2001-2010 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM) #define BOOST_SPIRIT_KARMA_EPS_APRIL_21_2007_0246PM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// // enables eps template <> struct use_terminal : mpl::true_ {}; // enables eps(bool-condition) template struct use_terminal > > : is_convertible {}; // enables lazy eps(f) template <> struct use_lazy_terminal : mpl::true_ {}; }} /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace karma { using boost::spirit::eps; using boost::spirit::eps_type; struct eps_generator : primitive_generator { template struct attribute { typedef unused_type type; }; template < typename OutputIterator, typename Context, typename Delimiter , typename Attribute> static bool generate(OutputIterator& sink, Context&, Delimiter const& d , Attribute const& /*attr*/) { return karma::delimit_out(sink, d); // always do post-delimiting } template info what(Context const& /*context*/) const { return info("eps"); } }; struct semantic_predicate : primitive_generator { template struct attribute { typedef unused_type type; }; semantic_predicate(bool predicate) : predicate_(predicate) {} template < typename OutputIterator, typename Context, typename Delimiter , typename Attribute> bool generate(OutputIterator& sink, Context&, Delimiter const& d , Attribute const& /*attr*/) const { // only do post-delimiting when predicate is true return predicate_ && karma::delimit_out(sink, d); } template info what(Context const& /*context*/) const { return info("semantic-predicate"); } bool predicate_; }; /////////////////////////////////////////////////////////////////////////// // Generator generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// template struct make_primitive { typedef eps_generator result_type; result_type operator()(unused_type, unused_type) const { return result_type(); } }; template struct make_primitive< terminal_ex > , Modifiers> { typedef semantic_predicate result_type; template result_type operator()(Terminal const& term, unused_type) const { return result_type(fusion::at_c<0>(term.args)); } }; }}} #endif