/usr/include/boost/msm/front/euml
Edit: /usr/include/boost/msm/front/euml/stt_grammar.hpp (9269B)
// Copyright 2008 Christophe Henry
// henry UNDERSCORE christophe AT hotmail DOT com
// This is an extended version of the state machine available in the boost::mpl library
// Distributed under the same license as the original.
// Copyright for the original version:
// Copyright 2005 David Abrahams and Aleksey Gurtovoy. 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_MSM_FRONT_EUML_STT_GRAMMAR_H
#define BOOST_MSM_FRONT_EUML_STT_GRAMMAR_H
#include
#include
#include
#include
#include
#include
namespace proto = boost::proto;
namespace boost { namespace msm { namespace front { namespace euml
{
template
struct TempRow
{
typedef SOURCE Source;
typedef EVENT Evt;
typedef TARGET Target;
typedef ACTION Action;
typedef GUARD Guard;
};
template
struct convert_to_row
{
typedef Row type;
};
template
struct convert_to_internal_row
{
typedef Internal type;
};
// explicit + fork + entry point + exit point grammar
struct BuildEntry
: proto::or_<
proto::when<
proto::function,proto::terminal,proto::terminal >,
get_fct,get_state_name() >(),get_state_name() >() >()
>
>
{};
// row grammar
struct BuildNextStates
: proto::or_<
proto::when<
proto::terminal,
get_state_name()
>,
proto::when<
BuildEntry,
BuildEntry
>,
proto::when<
proto::comma,
::boost::mpl::push_back<
make_vector_one_row(),
BuildEntry(proto::_right)>()
>,
proto::when <
proto::comma,
::boost::mpl::push_back<
BuildNextStates(proto::_left),
BuildEntry(proto::_right) >()
>
>
{};
template
struct fusion_event_action_guard
{
typedef TempRow type;
};
template
struct fusion_source_action_guard
{
typedef TempRow type;
};
template
struct fusion_source_event_action_guard
{
typedef TempRow type;
};
template
struct fusion_left_right
{
typedef TempRow type;
};
struct BuildEventPlusGuard
: proto::or_<
proto::when<
proto::subscript, GuardGrammar >,
TempRow(proto::_right)
>
>
{};
struct BuildSourceState
: proto::or_<
proto::when<
proto::terminal,
get_state_name()
>,
proto::when<
BuildEntry,
BuildEntry
>
>
{};
struct BuildSourcePlusGuard
: proto::when<
proto::subscript,
TempRow(proto::_right)
>
{};
struct BuildEvent
: proto::or_<
// just event without guard/action
proto::when<
proto::terminal,
TempRow() >
// event / action
, proto::when<
proto::divides,ActionGrammar >,
TempRow(proto::_right) >
// event [ guard ]
, proto::when<
proto::subscript,GuardGrammar >,
TempRow(proto::_right) >
// event [ guard ] / action
, proto::when<
proto::divides,
fusion_event_action_guard(proto::_right)
>()
>
>
{};
struct BuildSource
: proto::or_<
// after == if just state without event or guard/action
proto::when<
BuildSourceState,
TempRow() >
// == source / action
, proto::when<
proto::divides,
TempRow(proto::_right) >
// == source [ guard ]
, proto::when<
proto::subscript,
TempRow(proto::_right) >
// == source [ guard ] / action
, proto::when<
proto::divides,
fusion_source_action_guard(proto::_right)
>()
>
>
{};
struct BuildRight
: proto::or_<
proto::when<
proto::plus,
fusion_source_event_action_guard()
>,
proto::when<
BuildSource,
BuildSource
>
>
{};
struct BuildRow
: proto::or_<
// grammar 1
proto::when<
proto::equal_to,
convert_to_row<
fusion_left_right,BuildRight(proto::_right)> >()
>,
// internal events
proto::when<
BuildRight,
convert_to_row<
fusion_left_right,BuildRight(proto::_)> >()
>,
// grammar 2
proto::when<
proto::equal_to,
convert_to_row<
fusion_left_right,BuildRight(proto::_left)> >()
>
>
{};
// stt grammar
struct BuildStt
: proto::or_<
proto::when<
proto::comma,
boost::mpl::push_back()
>,
proto::when <
BuildRow,
make_vector_one_row()
>
>
{};
template
typename ::boost::mpl::eval_if<
typename proto::matches::type,
boost::result_of,
make_invalid_type>::type
build_stt(Expr const&)
{
return typename boost::result_of::type();
}
// internal stt grammar
struct BuildInternalRow
: proto::when<
BuildEvent,
convert_to_internal_row<
fusion_left_right,BuildEvent(proto::_)> >()
>
{};
struct BuildInternalStt
: proto::or_<
proto::when<
proto::comma,
boost::mpl::push_back()
>,
proto::when <
BuildInternalRow,
make_vector_one_row()
>
>
{};
template
typename ::boost::mpl::eval_if<
typename proto::matches::type,
boost::result_of,
make_invalid_type>::type
build_internal_stt(Expr const&)
{
return typename boost::result_of::type();
}
}}}}
#endif //BOOST_MSM_FRONT_EUML_STT_GRAMMAR_H