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/include/classic_core.hpp> 18 #include <boost/assert.hpp> 19 20 using namespace BOOST_SPIRIT_CLASSIC_NS; 21 22 struct my_grammar : grammar<my_grammar> 23 { 24 template <typename ScannerT> 25 struct definition 26 { definitionmy_grammar::definition27 definition(my_grammar const& self) 28 { 29 r = lower_p; 30 rr = +(lexeme_d[r] >> as_lower_d[r] >> r); 31 } 32 33 typedef scanner_list< 34 ScannerT 35 , typename lexeme_scanner<ScannerT>::type 36 , typename as_lower_scanner<ScannerT>::type 37 > scanners; 38 39 rule<scanners> r; 40 rule<ScannerT> rr; startmy_grammar::definition41 rule<ScannerT> const& start() const { return rr; } 42 }; 43 }; 44 45 int main()46main() 47 { 48 my_grammar g; 49 bool success = parse("abcdef aBc d e f aBc d E f", g, space_p).full; 50 BOOST_ASSERT(success); 51 std::cout << "SUCCESS!!!\n"; 52 return 0; 53 } 54