rule_separate_tu_grammar.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*=============================================================================
  2. Copyright (c) 2019 Nikita Kniazev
  3. Use, modification and distribution is subject to the Boost Software
  4. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. =============================================================================*/
  7. #include <boost/spirit/home/x3.hpp>
  8. // Check that `BOOST_SPIRIT_INSTANTIATE` instantiates `parse_rule` with proper
  9. // types when a rule has no attribute.
  10. namespace unused_attr {
  11. namespace x3 = boost::spirit::x3;
  12. // skipper must has no attribute, checks `parse` and `skip_over`
  13. using skipper_type = x3::rule<class skipper_r>;
  14. const skipper_type skipper;
  15. BOOST_SPIRIT_DECLARE(skipper_type)
  16. // the `unused_type const` must have the same effect as no attribute
  17. using skipper2_type = x3::rule<class skipper2_r, x3::unused_type const>;
  18. const skipper2_type skipper2;
  19. BOOST_SPIRIT_DECLARE(skipper2_type)
  20. // grammar must has no attribute, checks `parse` and `phrase_parse`
  21. using grammar_type = x3::rule<class grammar_r>;
  22. const grammar_type grammar;
  23. BOOST_SPIRIT_DECLARE(grammar_type)
  24. }
  25. // Check instantiation when rule has an attribute.
  26. namespace used_attr {
  27. namespace x3 = boost::spirit::x3;
  28. using skipper_type = x3::rule<class skipper_r>;
  29. const skipper_type skipper;
  30. BOOST_SPIRIT_DECLARE(skipper_type)
  31. using grammar_type = x3::rule<class grammar_r, int>;
  32. const grammar_type grammar;
  33. BOOST_SPIRIT_DECLARE(grammar_type)
  34. }