]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | { | |
19 | 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 | |
29 | int main() | |
30 | { | |
31 | char const* input = "some input, it doesn't matter"; | |
11fdf7f2 | 32 | char const* end = &input[strlen(input)]; |
7c673cae FG |
33 | |
34 | num_list g; | |
11fdf7f2 | 35 | qi::phrase_parse(input, end, g, |
7c673cae FG |
36 | qi::space | ('%' >> *~qi::char_('\n') >> '\n')); |
37 | ||
38 | return 0; | |
39 | } |