• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2003 Vaclav Vesely
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 //  This example demonstrates no_actions_d directive.
11 //
12 //  The no_actions_d directive ensures, that semantic actions of the inner
13 //  parser would NOT be invoked. See the no_actions_scanner in the Scanner
14 //  and Parsing chapter in the User's Guide.
15 //
16 //-----------------------------------------------------------------------------
17 
18 #include <boost/assert.hpp>
19 #include <iostream>
20 #include <boost/cstdlib.hpp>
21 #include <boost/spirit/include/classic_core.hpp>
22 
23 using namespace std;
24 using namespace boost;
25 using namespace BOOST_SPIRIT_CLASSIC_NS;
26 
27 //-----------------------------------------------------------------------------
28 
main()29 int main()
30 {
31     // To use the rule in the no_action_d directive we must declare it with
32     // the no_actions_scanner scanner
33     rule<no_actions_scanner<>::type> r;
34 
35     int i(0);
36 
37     // r is the rule with the semantic action
38     r = int_p[assign_a(i)];
39 
40     parse_info<> info = parse(
41         "1",
42 
43         no_actions_d
44         [
45             r
46         ]
47     );
48 
49     BOOST_ASSERT(info.full);
50     // Check, that the action hasn't been invoked
51     BOOST_ASSERT(i == 0);
52 
53     return exit_success;
54 }
55 
56 //-----------------------------------------------------------------------------
57