• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "typeof" in chapter "Techniques" of
11 // *** the Spirit documentation for information regarding
12 // *** this snippet.
13 
14 #include <iostream>
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/typeof/typeof.hpp>
17 #include <boost/assert.hpp>
18 
19 using namespace BOOST_SPIRIT_CLASSIC_NS;
20 
21 #define RULE(name, definition) BOOST_TYPEOF(definition) name = definition
22 
23 int
main()24 main()
25 {
26     RULE(
27         skipper,
28         (       space_p
29             |   "//" >> *(anychar_p - '\n') >> '\n'
30             |   "/*" >> *(anychar_p - "*/") >> "*/"
31         )
32     );
33 
34     bool success = parse(
35         "/*this is a comment*/\n//this is a c++ comment\n\n",
36         *skipper).full;
37     BOOST_ASSERT(success);
38     std::cout << "SUCCESS!!!\n";
39     return 0;
40 }
41 
42