]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/example/techniques/dynamic_rule.cpp
1 /*=============================================================================
2 Copyright (c) 2003 Jonathan de Halleux (dehalleux@pelikhan.com)
3 http://spirit.sourceforge.net/
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 shows how the assign operator can be used to modify
11 // rules with semantic actions
13 // First we show the basic spirit without (without any dynamic feature),
14 // then we show how to use assign_a to make it dynamic,
16 // the grammar has to parse abcabc... sequences
17 ///////////////////////////////////////////////////////////////////////////////
20 #define BOOST_SPIRIT_DEBUG
21 #include <boost/spirit.hpp>
23 #include <boost/spirit/include/classic_assign_actor.hpp>
25 int main(int argc
, char* argv
[])
27 using namespace BOOST_SPIRIT_CLASSIC_NS
;
31 const char* str
="abcabc";
33 BOOST_SPIRIT_DEBUG_NODE(next
);
34 BOOST_SPIRIT_DEBUG_NODE(a
);
35 BOOST_SPIRIT_DEBUG_NODE(b
);
36 BOOST_SPIRIT_DEBUG_NODE(c
);
44 cout
<<"hit :"<<( hit
.hit
? "yes" : "no")<<", "
45 <<(hit
.full
? "full": "not full")
49 a
= ch_p('a')[ assign_a( next
, b
)] >> !next
;
50 b
= ch_p('b')[ assign_a( next
, c
)] >> !next
;
51 c
= ch_p('c')[ assign_a( next
, a
)] >> !next
;
53 cout
<<"hit :"<<( hit
.hit
? "yes" : "no")<<", "
54 <<(hit
.full
? "full": "not full")