Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/spirit/example/techniques/multiple_scanners.cpp @ 33

Last change on this file since 33 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.4 KB
Line 
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
19using namespace boost::spirit;
20
21struct 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
44int
45main()
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}
Note: See TracBrowser for help on using the repository browser.