// 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::when< proto::function,proto::terminal,proto::terminal >, get_fct,proto::_child_c<1>,proto::_child_c<2> >() > {}; // row grammar struct BuildNextStates : proto::or_< proto::when< proto::terminal, proto::_ >, 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::when< proto::subscript,BuildGuards >, TempRow() > {}; struct BuildSourceState : proto::or_< proto::when< proto::terminal, proto::_ >, proto::when< BuildEntry, BuildEntry > > {}; struct BuildSourcePlusGuard : proto::when< proto::subscript, TempRow() > {}; struct BuildEvent : proto::or_< // just event without guard/action proto::when< proto::terminal, TempRow() > // event / action , proto::when< proto::divides,BuildActionSequence >, TempRow() > // event [ guard ] , proto::when< proto::subscript,BuildGuards >, TempRow() > // event [ guard ] / action , proto::when< proto::divides, fusion_event_action_guard() >() > > {}; struct BuildSource : proto::or_< // after == if just state without event or guard/action proto::when< BuildSourceState, TempRow() > // == source / action , proto::when< proto::divides, TempRow() > // == source [ guard ] , proto::when< proto::subscript, TempRow() > // == source [ guard ] / action , proto::when< proto::divides, fusion_source_action_guard() >() > > {}; 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& expr) { 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& expr) { return typename boost::result_of::type(); } }}}} #endif //BOOST_MSM_FRONT_EUML_STT_GRAMMAR_H