Blame view

3rdparty/boost_1_81_0/boost/msm/msm_grammar.hpp 2.35 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  // 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_GRAMMAR_H
  #define BOOST_MSM_GRAMMAR_H
  
  #include <boost/proto/core.hpp>
  #include <boost/msm/common.hpp>
  
  
  namespace boost { namespace msm
  {
  // base grammar for all of msm's proto-based grammars
  struct basic_grammar : proto::_
  {};
  
  // Forward-declare an expression wrapper
  template<typename Expr>
  struct msm_terminal;
  
  struct msm_domain
      : proto::domain< proto::generator<msm_terminal>, basic_grammar >
  {};
  
  template<typename Expr>
  struct msm_terminal
      : proto::extends<Expr, msm_terminal<Expr>, msm_domain>
  {
      typedef
          proto::extends<Expr, msm_terminal<Expr>, msm_domain>
          base_type;
      // Needs a constructor
      msm_terminal(Expr const &e = Expr())
          : base_type(e)
      {}
  };
  
  // grammar forbidding address of for terminals
  struct terminal_grammar : proto::not_<proto::address_of<proto::_> >
  {};
  
  // Forward-declare an expression wrapper
  template<typename Expr>
  struct euml_terminal;
  
  struct sm_domain
      : proto::domain< proto::generator<euml_terminal>, terminal_grammar, boost::msm::msm_domain >
  {};
  
  struct state_grammar : 
      proto::and_<
          proto::not_<proto::address_of<proto::_> >,
          proto::not_<proto::shift_right<proto::_,proto::_> >,
          proto::not_<proto::shift_left<proto::_,proto::_> >,
          proto::not_<proto::bitwise_and<proto::_,proto::_> >
      >
  {};
  struct state_domain
      : proto::domain< proto::generator<euml_terminal>, boost::msm::state_grammar,boost::msm::sm_domain >
  {};
  
  template<typename Expr>
  struct euml_terminal
      : proto::extends<Expr, euml_terminal<Expr>, boost::msm::sm_domain>
  {
      typedef
          proto::extends<Expr, euml_terminal<Expr>, boost::msm::sm_domain>
          base_type;
      // Needs a constructor
      euml_terminal(Expr const &e = Expr())
          : base_type(e)
      {}
      // Unhide Proto's overloaded assignment operator
      using base_type::operator=;
  };
  
  } } // boost::msm
  #endif //BOOST_MSM_GRAMMAR_H