grammar_fail.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Hartmut Kaiser
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. =============================================================================*/
  6. #include <boost/config/warning_disable.hpp>
  7. #include <boost/spirit/include/karma_operator.hpp>
  8. #include <boost/spirit/include/karma_char.hpp>
  9. #include <boost/spirit/include/karma_string.hpp>
  10. #include <boost/spirit/include/karma_numeric.hpp>
  11. #include <boost/spirit/include/karma_nonterminal.hpp>
  12. #include <boost/spirit/include/karma_generate.hpp>
  13. #include "test.hpp"
  14. using namespace boost::spirit;
  15. using namespace boost::spirit::ascii;
  16. typedef spirit_test::output_iterator<char>::type outiter_type;
  17. struct num_list : karma::grammar<outiter_type, karma::rule<outiter_type> >
  18. {
  19. num_list() : num_list::base_type(start)
  20. {
  21. start = int_(1) << ',' << int_(0);
  22. }
  23. karma::rule<outiter_type, karma::rule<outiter_type> > start;
  24. };
  25. // this test must fail compiling as the rule is used with an incompatible
  26. // delimiter type
  27. int main()
  28. {
  29. std::string generated;
  30. std::back_insert_iterator<std::string> outit(generated);
  31. num_list def;
  32. generate_delimited(outit, def, char_('%') << '\n');
  33. return 0;
  34. }