/*============================================================================= Copyright (c) 2001-2014 Joel de Guzman 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_X3_CALL_CONTEXT_MAY_26_2014_0234PM) #define BOOST_SPIRIT_X3_CALL_CONTEXT_MAY_26_2014_0234PM #include #include #include #include namespace boost { namespace spirit { namespace x3 { //////////////////////////////////////////////////////////////////////////// struct rule_val_context_tag; template inline decltype(auto) _val(Context const& context) { return x3::get(context); } //////////////////////////////////////////////////////////////////////////// struct where_context_tag; template inline decltype(auto) _where(Context const& context) { return x3::get(context); } //////////////////////////////////////////////////////////////////////////// struct attr_context_tag; template inline decltype(auto) _attr(Context const& context) { return x3::get(context); } //////////////////////////////////////////////////////////////////////////// namespace detail { template auto call(F f, Context const& context, mpl::true_) { return f(context); } template auto call(F f, Context const& /* context */, mpl::false_) { return f(); } } template < typename F, typename Iterator , typename Context, typename RuleContext, typename Attribute> auto call( F f, Iterator& first, Iterator const& last , Context const& context, RuleContext& rcontext, Attribute& attr) { boost::iterator_range rng(first, last); auto val_context = make_context(rcontext, context); auto where_context = make_context(rng, val_context); auto attr_context = make_context(attr, where_context); return detail::call(f, attr_context, is_callable()); } }}} #endif