Chris@16
|
1 // Copyright 2008 Christophe Henry
|
Chris@16
|
2 // henry UNDERSCORE christophe AT hotmail DOT com
|
Chris@16
|
3 // This is an extended version of the state machine available in the boost::mpl library
|
Chris@16
|
4 // Distributed under the same license as the original.
|
Chris@16
|
5 // Copyright for the original version:
|
Chris@16
|
6 // Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed
|
Chris@16
|
7 // under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
8 // file LICENSE_1_0.txt or copy at
|
Chris@16
|
9 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_MSM_GRAMMAR_H
|
Chris@16
|
12 #define BOOST_MSM_GRAMMAR_H
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/proto/core.hpp>
|
Chris@16
|
15 #include <boost/msm/common.hpp>
|
Chris@16
|
16
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost { namespace msm
|
Chris@16
|
19 {
|
Chris@16
|
20 // base grammar for all of msm's proto-based grammars
|
Chris@16
|
21 struct basic_grammar : proto::_
|
Chris@16
|
22 {};
|
Chris@16
|
23
|
Chris@16
|
24 // Forward-declare an expression wrapper
|
Chris@16
|
25 template<typename Expr>
|
Chris@16
|
26 struct msm_terminal;
|
Chris@16
|
27
|
Chris@16
|
28 struct msm_domain
|
Chris@16
|
29 : proto::domain< proto::generator<msm_terminal>, basic_grammar >
|
Chris@16
|
30 {};
|
Chris@16
|
31
|
Chris@16
|
32 template<typename Expr>
|
Chris@16
|
33 struct msm_terminal
|
Chris@16
|
34 : proto::extends<Expr, msm_terminal<Expr>, msm_domain>
|
Chris@16
|
35 {
|
Chris@16
|
36 typedef
|
Chris@16
|
37 proto::extends<Expr, msm_terminal<Expr>, msm_domain>
|
Chris@16
|
38 base_type;
|
Chris@16
|
39 // Needs a constructor
|
Chris@16
|
40 msm_terminal(Expr const &e = Expr())
|
Chris@16
|
41 : base_type(e)
|
Chris@16
|
42 {}
|
Chris@16
|
43 };
|
Chris@16
|
44
|
Chris@16
|
45 // grammar forbidding address of for terminals
|
Chris@16
|
46 struct terminal_grammar : proto::not_<proto::address_of<proto::_> >
|
Chris@16
|
47 {};
|
Chris@16
|
48
|
Chris@16
|
49 // Forward-declare an expression wrapper
|
Chris@16
|
50 template<typename Expr>
|
Chris@16
|
51 struct euml_terminal;
|
Chris@16
|
52
|
Chris@16
|
53 struct sm_domain
|
Chris@16
|
54 : proto::domain< proto::generator<euml_terminal>, terminal_grammar, boost::msm::msm_domain >
|
Chris@16
|
55 {};
|
Chris@16
|
56
|
Chris@16
|
57 struct state_grammar :
|
Chris@16
|
58 proto::and_<
|
Chris@16
|
59 proto::not_<proto::address_of<proto::_> >,
|
Chris@16
|
60 proto::not_<proto::shift_right<proto::_,proto::_> >,
|
Chris@16
|
61 proto::not_<proto::shift_left<proto::_,proto::_> >,
|
Chris@16
|
62 proto::not_<proto::bitwise_and<proto::_,proto::_> >
|
Chris@16
|
63 >
|
Chris@16
|
64 {};
|
Chris@16
|
65 struct state_domain
|
Chris@16
|
66 : proto::domain< proto::generator<euml_terminal>, boost::msm::state_grammar,boost::msm::sm_domain >
|
Chris@16
|
67 {};
|
Chris@16
|
68
|
Chris@16
|
69 template<typename Expr>
|
Chris@16
|
70 struct euml_terminal
|
Chris@16
|
71 : proto::extends<Expr, euml_terminal<Expr>, boost::msm::sm_domain>
|
Chris@16
|
72 {
|
Chris@16
|
73 typedef
|
Chris@16
|
74 proto::extends<Expr, euml_terminal<Expr>, boost::msm::sm_domain>
|
Chris@16
|
75 base_type;
|
Chris@16
|
76 // Needs a constructor
|
Chris@16
|
77 euml_terminal(Expr const &e = Expr())
|
Chris@16
|
78 : base_type(e)
|
Chris@16
|
79 {}
|
Chris@16
|
80 // Unhide Proto's overloaded assignment operator
|
Chris@16
|
81 using base_type::operator=;
|
Chris@16
|
82 };
|
Chris@16
|
83
|
Chris@16
|
84 } } // boost::msm
|
Chris@16
|
85 #endif //BOOST_MSM_GRAMMAR_H
|
Chris@16
|
86
|