• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2010 Hartmut Kaiser
3 
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 
8 #include <boost/spirit/include/qi_operator.hpp>
9 #include <boost/spirit/include/qi_char.hpp>
10 #include <boost/spirit/include/qi_string.hpp>
11 #include <boost/spirit/include/qi_numeric.hpp>
12 #include <boost/spirit/include/qi_nonterminal.hpp>
13 #include <boost/spirit/include/qi_parse.hpp>
14 
15 namespace qi = boost::spirit::qi;
16 
17 struct num_list : qi::grammar<char const*, qi::rule<char const*> >
18 {
num_listnum_list19     num_list() : base_type(start)
20     {
21         num = qi::int_;
22         start = num >> *(',' >> num);
23     }
24 
25     qi::rule<char const*, qi::rule<char const*> > start, num;
26 };
27 
28 // this test must fail compiling
main()29 int main()
30 {
31     char const* input = "some input, it doesn't matter";
32     char const* end = &input[strlen(input)];
33 
34     num_list g;
35     qi::phrase_parse(input, end, g,
36         qi::space | ('%' >> *~qi::char_('\n') >> '\n'));
37 
38     return 0;
39 }
40