actor.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*=============================================================================
  2. Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
  3. http://spirit.sourceforge.net/
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. =============================================================================*/
  7. #ifndef BOOST_SPIRIT_ACTOR_HPP
  8. #define BOOST_SPIRIT_ACTOR_HPP
  9. #include <boost/spirit/home/classic/version.hpp>
  10. ///////////////////////////////////////////////////////////////////////////////
  11. //
  12. // Actors documentation and convention
  13. //
  14. // Actors
  15. //
  16. // Actors are predefined semantic action functors. They are used to do an
  17. // action on the parse result if the parser has had a successful match. An
  18. // example of actor is the append_actor described in the Spirit
  19. // documentation.
  20. //
  21. // The action takes place through a call to the () operator: single argument
  22. // () operator call for character parsers and two argument (first,last) call
  23. // for phrase parsers. Actors should implement at least one of the two ()
  24. // operator.
  25. //
  26. // Actor instances are not created directly since they usually involve a
  27. // number of template parameters. Instead generator functions ("helper
  28. // functions") are provided to generate actors according to their arguments.
  29. // All helper functions have the "_a" suffix. For example, append_actor is
  30. // created using the append_a function.
  31. //
  32. // Policy holder actors and policy actions
  33. //
  34. // A lot of actors need to store reference to one or more objects. For
  35. // example, actions on container need to store a reference to the container.
  36. // Therefore, this kind of actor have been broken down into
  37. //
  38. // - a action policy that does the action (act method),
  39. // - a policy holder actor that stores the references and feeds the act
  40. // method.
  41. //
  42. // Policy holder actors
  43. //
  44. // Policy holder have the following naming convention:
  45. // <member>_ >> *<member> >> !value >> actor
  46. // where member are the policy stored member, they can be of type:
  47. //
  48. // - ref, a reference,
  49. // - const_ref, a const reference,
  50. // - value, by value,
  51. // - empty, no stored members
  52. // - !value states if the policy uses the parse result or not.
  53. //
  54. // The available policy holder are enumerated below:
  55. //
  56. // - empty_actor, nothing stored, feeds parse result
  57. // - value_actor, 1 object stored by value, feeds value
  58. // - ref_actor, 1 reference stored, feeds ref
  59. // - ref_value_actor, 1 reference stored, feeds ref and parse result
  60. //
  61. // Doc. convention
  62. //
  63. // - ref is a reference to an object stored in a policy holder actor,
  64. // - value_ref,value1_ref, value2_ref are a const reference stored in a
  65. // policy holder actor,
  66. // - value is the parse result in the single argument () operator,
  67. // - first,last are the parse result in the two argument () operator
  68. //
  69. // Actors (generator functions) and quick description
  70. //
  71. // - assign_a(ref) assign parse result to ref
  72. // - assign_a(ref, value_ref) assign value_ref to ref
  73. // - increment_a(ref) increment ref
  74. // - decrement_a(ref) decrement ref
  75. // - push_back_a(ref) push back the parse result in ref
  76. // - push_back_a(ref, value_ref) push back value_ref in ref
  77. // - push_front_a(ref) push front the parse result in ref
  78. // - push_front_a(ref, value_ref) push front value_ref in ref
  79. // - insert_key_a(ref,value_ref) insert value_ref in ref using the
  80. // parse result as key
  81. // - insert_at_a(ref, key_ref) insert the parse result in ref at key_ref
  82. // - insert_at_a(ref, key_ref insert value_ref in ref at key_ref
  83. // , value_ref)
  84. // - assign_key_a(ref, value_ref) assign value_ref in ref using the
  85. // parse result as key
  86. // - erase_a(ref, key) erase data at key from ref
  87. // - clear_a(ref) clears ref
  88. // - swap_a(aref, bref) swaps aref and bref
  89. //
  90. ///////////////////////////////////////////////////////////////////////////////
  91. #include <boost/spirit/home/classic/actor/ref_actor.hpp>
  92. #include <boost/spirit/home/classic/actor/ref_value_actor.hpp>
  93. #include <boost/spirit/home/classic/actor/ref_const_ref_actor.hpp>
  94. #include <boost/spirit/home/classic/actor/ref_const_ref_value_actor.hpp>
  95. #include <boost/spirit/home/classic/actor/ref_const_ref_const_ref_a.hpp>
  96. #include <boost/spirit/home/classic/actor/assign_actor.hpp>
  97. #include <boost/spirit/home/classic/actor/clear_actor.hpp>
  98. #include <boost/spirit/home/classic/actor/increment_actor.hpp>
  99. #include <boost/spirit/home/classic/actor/decrement_actor.hpp>
  100. #include <boost/spirit/home/classic/actor/push_back_actor.hpp>
  101. #include <boost/spirit/home/classic/actor/push_front_actor.hpp>
  102. #include <boost/spirit/home/classic/actor/erase_actor.hpp>
  103. #include <boost/spirit/home/classic/actor/insert_key_actor.hpp>
  104. #include <boost/spirit/home/classic/actor/insert_at_actor.hpp>
  105. #include <boost/spirit/home/classic/actor/assign_key_actor.hpp>
  106. #include <boost/spirit/home/classic/actor/swap_actor.hpp>
  107. #endif