/usr/include/boost/phoenix/core
Edit: /usr/include/boost/phoenix/core/meta_grammar.hpp (4867B)
/*=============================================================================
Copyright (c) 2005-2010 Joel de Guzman
Copyright (c) 2010 Eric Niebler
Copyright (c) 2010 Thomas Heller
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)
==============================================================================*/
#ifndef BOOST_PHOENIX_CORE_META_GRAMMAR_HPP
#define BOOST_PHOENIX_CORE_META_GRAMMAR_HPP
#include
#include
#include
#include
#include
#include
namespace boost { namespace phoenix
{
/////////////////////////////////////////////////////////////////////////////
// The grammar defining valid phoenix expressions
struct meta_grammar
: proto::switch_
{
template
struct case_
: proto::not_
{};
};
struct evaluator
{
BOOST_PROTO_TRANSFORM(evaluator)
template
struct impl
: proto::transform_impl
{
typedef meta_grammar::impl what;
typedef typename what::result_type result_type;
result_type operator()(
typename impl::expr_param e
, typename impl::state_param s
, typename impl::data_param d
) const
{
return what()(e, s, d);
}
};
template
struct impl
: proto::transform_impl
{
typedef
meta_grammar::impl<
Expr
, typename result_of::env::type
, typename result_of::actions::type
>
what;
typedef typename what::result_type result_type;
result_type operator()(
typename impl::expr_param e
, typename impl::state_param s
, typename impl::data_param
) const
{
return what()(e, phoenix::env(s), actions(s));
}
};
template
struct impl
: proto::transform_impl
{
typedef
meta_grammar::impl<
Expr
, typename result_of::env::type
, typename result_of::actions::type
>
what;
typedef typename what::result_type result_type;
result_type operator()(
typename impl::expr_param e
, typename impl::state_param s
, typename impl::data_param
) const
{
return what()(e, phoenix::env(s), actions(s));
}
};
};
/////////////////////////////////////////////////////////////////////////////
// Set of default actions. Extend this whenever you add a new phoenix
// construct
struct default_actions
{
template
struct when
: proto::_default
{};
};
template
struct enable_rule
: proto::when
{};
namespace result_of
{
template
struct eval
: boost::result_of< ::boost::phoenix::evaluator(Expr, Context)>
{};
}
/////////////////////////////////////////////////////////////////////////////
// A function we can call to evaluate our expression
template
inline
typename meta_grammar::template impl<
Expr const&
, typename result_of::env::type
, typename result_of::actions::type
>::result_type
eval(Expr const& expr, Context const & ctx)
{
static evaluator const e = {};
return e(expr, ctx);
}
template
inline
typename meta_grammar::template impl<
Expr &
, typename result_of::env::type
, typename result_of::actions::type
>::result_type
eval(Expr & expr, Context const & ctx)
{
static evaluator const e = {};
return e(expr, ctx);
}
}}
#endif