grammar_multi_instance_tst.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*=============================================================================
  2. Copyright (c) 2004 Joel de Guzman
  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 <iostream>
  9. #include <boost/detail/lightweight_test.hpp>
  10. #include <boost/spirit/include/classic_core.hpp>
  11. using namespace BOOST_SPIRIT_CLASSIC_NS;
  12. using namespace std;
  13. int g_count = 0;
  14. struct g : public grammar<g>
  15. {
  16. template <typename ScannerT>
  17. struct definition
  18. {
  19. definition(g const& /*self*/)
  20. {
  21. g_count++;
  22. }
  23. rule<ScannerT> r;
  24. rule<ScannerT> const& start() const { return r; }
  25. };
  26. };
  27. void
  28. grammar_tests()
  29. {
  30. g my_g;
  31. parse("", my_g);
  32. }
  33. int
  34. main()
  35. {
  36. grammar_tests();
  37. grammar_tests();
  38. grammar_tests();
  39. BOOST_TEST(g_count == 3);
  40. return boost::report_errors();
  41. }