Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

BOOST_PHOENIX_DEFINE_EXPRESSION_EXT

Description

BOOST_PHOENIX_DEFINE_EXPRESSION_EXT is a macro that can be used to generate all the necessary boilerplate to create Phoenix Expressions

Synopsis
BOOST_PHOENIX_DEFINE_EXPRESSION_EXT(
    actor
  , (namespace_seq)(name)
  , (child_grammar0)
    (child_grammar1)
    ...
    (child_grammarN)
  , N
)
Semantics

The above macro generates the necessary code for an expression name in namespace namespace_seq. The sequence of (child_grammarN) declares how many children the expression will have and what proto::grammar they match.

The macro should be used at global scope. namespace_seq shall be the sequence of namespaces under which the following symbols will be defined:

namespace tag
{
    struct name;
}

namespace expression
{
    template <typename A0, typename A1 ... typename AN>
    struct name
        : boost::phoenix::expr_ext<
            actor
          , tag::name
          , A0
          , A1
            ...
          , AN
        >
}

namespace rule
{
    struct name
        : boost::phoenix::expr<
            child_grammar0
          , child_grammar1
            ...
          , child_grammarN
        >
    {};
}

This macros also adds a specialization for meta_grammar::case_<tag::name>.

Header
#include <boost/phoenix/core/expression.hpp>
Example
BOOST_PHOENIX_DEFINE_EXPRESSION_EXT(
    if_actor
  , (boost)(phoenix)(if_)
  , (meta_grammar) // Cond
    (meta_grammar) // Then
)

This defines the if_ expression. The custom actor defines the else_.


PrevUpHomeNext