1 | /*============================================================================= |
---|
2 | Copyright (c) 2002-2003 Joel de Guzman |
---|
3 | http://spirit.sourceforge.net/ |
---|
4 | |
---|
5 | Use, modification and distribution is subject to the Boost Software |
---|
6 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
7 | http://www.boost.org/LICENSE_1_0.txt) |
---|
8 | =============================================================================*/ |
---|
9 | |
---|
10 | // *** See the section "Rule With Multiple Scanners" in |
---|
11 | // *** chapter "Techniques" of the Spirit documentation |
---|
12 | // *** for information regarding this snippet |
---|
13 | |
---|
14 | #define BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT 3 |
---|
15 | |
---|
16 | #include <iostream> |
---|
17 | #include <boost/spirit/core.hpp> |
---|
18 | |
---|
19 | using namespace boost::spirit; |
---|
20 | |
---|
21 | struct my_grammar : grammar<my_grammar> |
---|
22 | { |
---|
23 | template <typename ScannerT> |
---|
24 | struct definition |
---|
25 | { |
---|
26 | definition(my_grammar const& self) |
---|
27 | { |
---|
28 | r = lower_p; |
---|
29 | rr = +(lexeme_d[r] >> as_lower_d[r] >> r); |
---|
30 | } |
---|
31 | |
---|
32 | typedef scanner_list< |
---|
33 | ScannerT |
---|
34 | , typename lexeme_scanner<ScannerT>::type |
---|
35 | , typename as_lower_scanner<ScannerT>::type |
---|
36 | > scanners; |
---|
37 | |
---|
38 | rule<scanners> r; |
---|
39 | rule<ScannerT> rr; |
---|
40 | rule<ScannerT> const& start() const { return rr; } |
---|
41 | }; |
---|
42 | }; |
---|
43 | |
---|
44 | int |
---|
45 | main() |
---|
46 | { |
---|
47 | my_grammar g; |
---|
48 | bool success = parse("abcdef aBc d e f aBc d E f", g, space_p).full; |
---|
49 | assert(success); |
---|
50 | std::cout << "SUCCESS!!!\n"; |
---|
51 | return 0; |
---|
52 | } |
---|