mirror of
https://github.com/boostorg/phoenix.git
synced 2026-02-14 13:02:10 +00:00
start of phoenix-3 core
[SVN r62422]
This commit is contained in:
12
include/boost/phoenix/core.hpp
Normal file
12
include/boost/phoenix/core.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2010 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)
|
||||
==============================================================================*/
|
||||
#ifndef PHOENIX_CORE_HPP
|
||||
#define PHOENIX_CORE_HPP
|
||||
|
||||
#include <boost/spirit/home/phoenix/version.hpp>
|
||||
|
||||
#endif
|
||||
45
include/boost/phoenix/core/actor.hpp
Normal file
45
include/boost/phoenix/core/actor.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2010 Joel de Guzman
|
||||
Copyright (c) 2010 Eric Niebler
|
||||
|
||||
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 PHOENIX_CORE_ACTOR_HPP
|
||||
#define PHOENIX_CORE_ACTOR_HPP
|
||||
|
||||
#include <boost/proto/proto.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// The actor class. The main thing! In phoenix, everything is an actor
|
||||
// This class is responsible for full function evaluation. Partial
|
||||
// function evaluation involves creating a hierarchy of actor objects.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template <class Expr>
|
||||
struct actor
|
||||
{
|
||||
BOOST_PROTO_BASIC_EXTENDS(Expr, actor<Expr>, phoenix_domain)
|
||||
BOOST_PROTO_EXTENDS_ASSIGN()
|
||||
BOOST_PROTO_EXTENDS_SUBSCRIPT()
|
||||
|
||||
template <class Sig>
|
||||
struct result : actor_result<Sig> {};
|
||||
|
||||
typedef actor<Expr> actor_type;
|
||||
|
||||
template <class A0>
|
||||
typename boost::result_of<actor_type(A0 const&)>::type
|
||||
operator()(A0 const& a0) const
|
||||
{
|
||||
BOOST_PROTO_ASSERT_MATCHES(*this, eval_grammar);
|
||||
fusion::vector<A0 const&> args(a0);
|
||||
return eval(*this, args);
|
||||
}
|
||||
|
||||
/*... more...*/
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
30
include/boost/phoenix/core/actor_result.hpp
Normal file
30
include/boost/phoenix/core/actor_result.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2010 Joel de Guzman
|
||||
Copyright (c) 2010 Eric Niebler
|
||||
|
||||
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 PHOENIX_CORE_ACTOR_RESULT_HPP
|
||||
#define PHOENIX_CORE_ACTOR_RESULT_HPP
|
||||
|
||||
#include <boost/phoenix/core/meta_grammar.hpp>
|
||||
#include <boost/fusion/container/vector.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Return type computation
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template<class Sig>
|
||||
struct actor_result;
|
||||
|
||||
template <template Actor, template A0>
|
||||
struct actor_result<Actor(A0)>
|
||||
: boost::result_of<eval_grammar(Actor&, fusion::vector<A0>&)>
|
||||
{};
|
||||
|
||||
/*... more ...*/
|
||||
}}
|
||||
|
||||
#endif
|
||||
25
include/boost/phoenix/core/domain.hpp
Normal file
25
include/boost/phoenix/core/domain.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2010 Joel de Guzman
|
||||
Copyright (c) 2010 Eric Niebler
|
||||
|
||||
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 PHOENIX_CORE_DOMAIN_HPP
|
||||
#define PHOENIX_CORE_DOMAIN_HPP
|
||||
|
||||
#include <boost/proto/proto.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
template <typename Expr>
|
||||
struct actor;
|
||||
|
||||
struct phoenix_domain
|
||||
: proto::domain<
|
||||
proto::pod_generator<actor>,
|
||||
proto::_, proto::default_domain>
|
||||
{};
|
||||
}}
|
||||
|
||||
#endif
|
||||
82
include/boost/phoenix/core/meta_grammar.hpp
Normal file
82
include/boost/phoenix/core/meta_grammar.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2010 Joel de Guzman
|
||||
Copyright (c) 2010 Eric Niebler
|
||||
|
||||
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 PHOENIX_CORE_META_GRAMMAR_HPP
|
||||
#define PHOENIX_CORE_META_GRAMMAR_HPP
|
||||
|
||||
#include <boost/proto/proto.hpp>
|
||||
|
||||
namespace boost { namespace phoenix
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Our meta-grammar and expression evaluator
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
struct eval_grammar
|
||||
: proto::switch_<struct eval_cases>
|
||||
{};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// A function object we can call
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
eval_grammar const eval = eval_grammar();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Open ended grammar dispatch allows us to extend the grammar
|
||||
// without modifying the code
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
struct eval_cases
|
||||
{
|
||||
template <class Tag>
|
||||
struct case_ : proto::_default<eval_grammar> {};
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// A dummy terminal that, when evaluated, returns the current state.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
struct env
|
||||
{};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// wrapper for a Fusion extension evaluator function. Keep this POD.
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template <class Fun>
|
||||
struct funcwrap
|
||||
{
|
||||
typedef Fun type;
|
||||
};
|
||||
|
||||
// Handling for terminals, with the special case for env terminals.
|
||||
struct func_grammar
|
||||
: proto::or_<
|
||||
proto::when<
|
||||
proto::terminal<funcwrap<proto::_> >,
|
||||
mpl::deref<proto::_value>()>
|
||||
, proto::when<proto::terminal<env>, proto::_state>
|
||||
, proto::_
|
||||
>
|
||||
{};
|
||||
|
||||
// Handling for function invocations. When _child0 is a
|
||||
// funcwrap<>, don't evaluate the other child nodes. Just
|
||||
// pass then unevaluated to the function.
|
||||
template <>
|
||||
struct eval_cases::case_<proto::tag::function>
|
||||
: proto::or_<
|
||||
proto::when<
|
||||
proto::function<
|
||||
proto::terminal<funcwrap<proto::_> >
|
||||
, proto::terminal<env>
|
||||
, proto::vararg<eval_grammar>
|
||||
>
|
||||
, proto::_default<func_grammar>
|
||||
>
|
||||
, proto::_default<eval_grammar>
|
||||
>
|
||||
{};
|
||||
}}
|
||||
|
||||
#endif
|
||||
18
include/boost/phoenix/version.hpp
Normal file
18
include/boost/phoenix/version.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005-2008 Hartmut Kaiser
|
||||
Copyright (c) 2005-2010 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)
|
||||
==============================================================================*/
|
||||
#ifndef PHOENIX_VERSION_HPP
|
||||
#define PHOENIX_VERSION_HPP
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This is the version of the library
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define BOOST_PHOENIX_VERSION 0x3000 // 3.0.0
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user