pass_container3.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  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. // compilation test only
  6. #include <boost/config/warning_disable.hpp>
  7. #include <boost/detail/lightweight_test.hpp>
  8. #include <string>
  9. #include <vector>
  10. #include <boost/spirit/include/qi.hpp>
  11. #include <boost/fusion/include/adapt_struct.hpp>
  12. #include <boost/variant.hpp>
  13. #include "test.hpp"
  14. using namespace spirit_test;
  15. //////////////////////////////////////////////////////////////////////////////
  16. struct ast; // Forward declaration
  17. typedef boost::variant<
  18. double, char, int, std::string, boost::recursive_wrapper<ast>
  19. > ast_element;
  20. struct ast
  21. {
  22. int op;
  23. std::vector<ast_element> children;
  24. ast() {}
  25. };
  26. BOOST_FUSION_ADAPT_STRUCT(
  27. ast,
  28. (int, op)
  29. (std::vector<ast_element>, children)
  30. )
  31. ///////////////////////////////////////////////////////////////////////////////
  32. int main()
  33. {
  34. namespace qi = boost::spirit::qi;
  35. {
  36. qi::rule<char const*, ast()> num_expr;
  37. num_expr = (*(qi::char_ >> num_expr))[ qi::_1 ];
  38. }
  39. // doesn't currently work
  40. // {
  41. // qi::rule<char const*, std::string()> str = "abc";
  42. // qi::rule<char const*, std::string()> r =
  43. // '"' >> *('\\' >> qi::char_ | str) >> "'";
  44. //
  45. // std::string s;
  46. // BOOST_TEST(test_attr("\"abc\\a\"", r, s) && s == "abca");
  47. // }
  48. return boost::report_errors();
  49. }