Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/spirit/example/techniques/typeof.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.2 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 "typeof" in chapter "Techniques" of
11// *** the Spirit documentation for information regarding
12// *** this snippet.
13
14#ifdef __MWERKS__
15#define typeof __typeof__
16#endif
17
18#if !defined(__MWERKS__) && !defined(__GNUC__)
19#error "typeof not supported by your compiler"
20#endif
21
22#include <iostream>
23#include <boost/spirit/core.hpp>
24
25using namespace boost::spirit;
26
27#define RULE(name, definition) typeof(definition) name = definition
28
29int
30main()
31{
32    RULE(
33        skipper,
34        (       space_p
35            |   "//" >> *(anychar_p - '\n') >> '\n'
36            |   "/*" >> *(anychar_p - "*/") >> "*/"
37        )
38    );
39
40    bool success = parse(
41        "/*this is a comment*/\n//this is a c++ comment\n\n",
42        *skipper).full;
43    assert(success);
44    std::cout << "SUCCESS!!!\n";
45    return 0;
46}
47
Note: See TracBrowser for help on using the repository browser.