Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.


    Copyright (c) 2002-2003 Joel de Guzman

    Use, modification and distribution is subject to the Boost Software
    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at

// *** See the section "Rule With Multiple Scanners" in
// *** chapter "Techniques" of the Spirit documentation
// *** for information regarding this snippet


#include <iostream>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/assert.hpp>

using namespace BOOST_SPIRIT_CLASSIC_NS;

struct my_grammar : grammar<my_grammar>
    template <typename ScannerT>
    struct definition
        definition(my_grammar const& self)
            r = lower_p;
            rr = +(lexeme_d[r] >> as_lower_d[r] >> r);

        typedef scanner_list<
          , typename lexeme_scanner<ScannerT>::type
          , typename as_lower_scanner<ScannerT>::type
        > scanners;

        rule<scanners> r;
        rule<ScannerT> rr;
        rule<ScannerT> const& start() const { return rr; }

    my_grammar g;
    bool success = parse("abcdef aBc d e f aBc d E f", g, space_p).full;
    std::cout << "SUCCESS!!!\n";
    return 0;