for_p_as_parser_tests.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*=============================================================================
  2. Copyright (c) 2003 Martin Wille
  3. http://spirit.sourceforge.net/
  4. Use, modification and distribution is subject to the Boost Software
  5. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. =============================================================================*/
  8. #include <boost/spirit/include/classic_core.hpp>
  9. #include <boost/spirit/include/classic_for.hpp>
  10. extern bool fun();
  11. struct ftor
  12. {
  13. bool operator ()() const;
  14. };
  15. extern void init_fun();
  16. struct init_ftor
  17. {
  18. void operator()() const;
  19. };
  20. extern void step_fun();
  21. struct step_ftor
  22. {
  23. void operator()() const;
  24. };
  25. extern bool cmp_fun();
  26. struct cmp_ftor
  27. {
  28. bool operator()() const;
  29. };
  30. int
  31. main()
  32. {
  33. //////////////////////////////////
  34. // compile time check wether as_parser<> works for for_p
  35. ::BOOST_SPIRIT_CLASSIC_NS::rule<> r;
  36. r = BOOST_SPIRIT_CLASSIC_NS::for_p(&init_fun, &cmp_fun, &step_fun)['-'];
  37. r = BOOST_SPIRIT_CLASSIC_NS::for_p(init_ftor(), cmp_ftor(), step_ftor())["-"];
  38. r = BOOST_SPIRIT_CLASSIC_NS::for_p(init_ftor(), r, step_ftor())[r];
  39. }