summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2013-01-12 18:41:34 (GMT)
committerSwift Review <review@swift.im>2013-01-13 10:36:26 (GMT)
commitf3bc816af1b0d61452de973963e453bf3b3f95a2 (patch)
treee895f8afa3580e6cff6f5ad2017d45bf147a17c2 /3rdParty/Boost/src/boost/phoenix/core/meta_grammar.hpp
parent188fc285c6555eadd3c9d50ab8a94adcade78d89 (diff)
downloadswift-f3bc816af1b0d61452de973963e453bf3b3f95a2.zip
swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.tar.bz2
Adding in the spirit Boost stuff
Change-Id: I4f127ce61667243b64081b0aa309028d5077045f
Diffstat (limited to '3rdParty/Boost/src/boost/phoenix/core/meta_grammar.hpp')
-rw-r--r--3rdParty/Boost/src/boost/phoenix/core/meta_grammar.hpp156
1 files changed, 156 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/phoenix/core/meta_grammar.hpp b/3rdParty/Boost/src/boost/phoenix/core/meta_grammar.hpp
new file mode 100644
index 0000000..315419d
--- /dev/null
+++ b/3rdParty/Boost/src/boost/phoenix/core/meta_grammar.hpp
@@ -0,0 +1,156 @@
+/*=============================================================================
+ 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 <boost/phoenix/core/limits.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/phoenix/core/environment.hpp>
+#include <boost/proto/matches.hpp>
+#include <boost/proto/transform/call.hpp>
+#include <boost/proto/transform/default.hpp>
+
+namespace boost { namespace phoenix
+{
+ /////////////////////////////////////////////////////////////////////////////
+ // The grammar defining valid phoenix expressions
+ struct meta_grammar
+ : proto::switch_<meta_grammar>
+ {
+ template <typename Tag, typename Dummy = void>
+ struct case_
+ : proto::not_<proto::_>
+ {};
+ };
+
+ struct evaluator
+ {
+ BOOST_PROTO_TRANSFORM(evaluator)
+
+ template <typename Expr, typename State, typename Data>
+ struct impl
+ : proto::transform_impl<Expr, State, Data>
+ {
+ typedef meta_grammar::impl<Expr, State, Data> 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 <typename Expr, typename State>
+ struct impl<Expr, State, proto::empty_env>
+ : proto::transform_impl<Expr, State, proto::empty_env>
+ {
+ typedef
+ meta_grammar::impl<
+ Expr
+ , typename result_of::env<State>::type
+ , typename result_of::actions<State>::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 <typename Expr, typename State>
+ struct impl<Expr, State, unused>
+ : proto::transform_impl<Expr, State, unused>
+ {
+ typedef
+ meta_grammar::impl<
+ Expr
+ , typename result_of::env<State>::type
+ , typename result_of::actions<State>::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 <typename Rule, typename Dummy = void>
+ struct when
+ : proto::_default<meta_grammar>
+ {};
+ };
+
+ template <typename Rule, typename Dummy = void>
+ struct enable_rule
+ : proto::when<Rule, proto::external_transform>
+ {};
+
+ namespace result_of
+ {
+ template <typename Expr, typename Context>
+ struct eval
+ : boost::result_of< ::boost::phoenix::evaluator(Expr, Context)>
+ {};
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+ // A function we can call to evaluate our expression
+ template <typename Expr, typename Context>
+ inline
+ typename meta_grammar::template impl<
+ Expr const&
+ , typename result_of::env<Context const&>::type
+ , typename result_of::actions<Context const&>::type
+ >::result_type
+ eval(Expr const& expr, Context const & ctx)
+ {
+ static evaluator const e = {};
+ return e(expr, ctx);
+ }
+
+ template <typename Expr, typename Context>
+ inline
+ typename meta_grammar::template impl<
+ Expr &
+ , typename result_of::env<Context const&>::type
+ , typename result_of::actions<Context const&>::type
+ >::result_type
+ eval(Expr & expr, Context const & ctx)
+ {
+ static evaluator const e = {};
+ return e(expr, ctx);
+ }
+}}
+
+#endif