Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::proto::external_transforms<> Struct Template Reference

For defining a map of Rule/Transform pairs for use with when<T, external_transform> to make transforms external to the grammar. More...

#include <when.hpp>

Classes

struct  when
 

Public Types

typedef mpl::map
< BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_MAP_SIZE,
T)> 
map_type
 

Detailed Description

template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_MPL_LIMIT_MAP_SIZE, typename T, mpl::na)>
struct boost::proto::external_transforms<>

For defining a map of Rule/Transform pairs for use with when<T, external_transform> to make transforms external to the grammar.

The following code defines a grammar with a couple of external transforms. It also defines an action_map that maps from rules to transforms. It then passes that transforms map at the Data parameter to the grammar. In this way, the behavior of the grammar can be modified post-hoc by passing a different action_map.

struct int_terminal
{};
struct char_terminal
{};
struct my_grammar
proto::when< int_terminal, proto::external_transform >
, proto::when< char_terminal, proto::external_transform >
, proto::when<
proto::plus< my_grammar, my_grammar >
, proto::fold< _, int(), my_grammar >
>
>
{};
struct my_transforms
proto::when<int_terminal, print(proto::_value)>
, proto::when<char_terminal, print(proto::_value)>
>
{};
proto::literal<int> i(1);
proto::literal<char> c('a');
my_transforms trx;
// Evaluate "i+c" using my_grammar with the specified transforms:
my_grammar()(i + c, 0, trx);

Member Typedef Documentation

template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_MPL_LIMIT_MAP_SIZE, typename T, mpl::na) >
typedef mpl::map<BOOST_PP_ENUM_PARAMS(BOOST_MPL_LIMIT_MAP_SIZE, T)> boost::proto::external_transforms<>::map_type

The documentation for this struct was generated from the following file: