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