]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/example/techniques/no_rules/no_rule2.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / spirit / classic / example / techniques / no_rules / no_rule2.cpp
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 "Look Ma' No Rules" in
11 // *** chapter "Techniques" of the Spirit documentation
12 // *** for information regarding this snippet
13
14 #include <iostream>
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/assert.hpp>
17
18 using namespace BOOST_SPIRIT_CLASSIC_NS;
19
20 struct skip_grammar : grammar<skip_grammar>
21 {
22 template <typename ScannerT>
23 struct definition
24 {
25 definition(skip_grammar const& /*self*/)
26 : skip
27 ( space_p
28 | "//" >> *(anychar_p - '\n') >> '\n'
29 | "/*" >> *(anychar_p - "*/") >> "*/"
30 )
31 {
32 }
33
34 typedef
35 alternative<alternative<space_parser, sequence<sequence<
36 strlit<const char*>, kleene_star<difference<anychar_parser,
37 chlit<char> > > >, chlit<char> > >, sequence<sequence<
38 strlit<const char*>, kleene_star<difference<anychar_parser,
39 strlit<const char*> > > >, strlit<const char*> > >
40 skip_t;
41 skip_t skip;
42
43 skip_t const&
44 start() const { return skip; }
45 };
46 };
47
48 int
49 main()
50 {
51 skip_grammar g;
52 bool success = parse(
53 "/*this is a comment*/\n//this is a c++ comment\n\n",
54 *g).full;
55 BOOST_ASSERT(success);
56 std::cout << "SUCCESS!!!\n";
57 return 0;
58 }