]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/select_p_with_rule.cpp
1 /*=============================================================================
2 Copyright (c) 2004 Vyacheslav E. Andrejev
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 =============================================================================*/
11 #define PHOENIX_LIMIT 2
12 #define BOOST_SPIRIT_SELECT_LIMIT 2
13 #define BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT 2
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/spirit/include/classic_lists.hpp>
17 #include <boost/spirit/include/classic_select.hpp>
19 using namespace BOOST_SPIRIT_CLASSIC_NS
;
22 struct format_grammar
: public grammar
<format_grammar
>
24 template <typename ScannerT
>
27 definition(format_grammar
const& /*self*/)
30 list_p(format_descriptor
, ch_p(','))
34 select_p(E_descriptor
, EN_descriptor
)
37 E_descriptor
= // E[w[.d][Ee]]
40 (ch_p('E') - (str_p("EN")))
42 min_limit_d(1u)[uint_p
]
43 >> !(ch_p('.') >> uint_p
)
44 >> !(ch_p('E') >> min_limit_d(1u)[uint_p
])
49 EN_descriptor
= // EN[w[.d][Ee]]
54 min_limit_d(1u)[uint_p
]
55 >> !(ch_p('.') >> uint_p
)
56 >> !(ch_p('E') >> min_limit_d(1u)[uint_p
])
62 rule
<ScannerT
> descriptor_list
;
63 rule
<ScannerT
> format_descriptor
;
64 rule
<ScannerT
> E_descriptor
;
65 rule
<ScannerT
> EN_descriptor
;
67 rule
<ScannerT
> const& start() const
69 return descriptor_list
;
76 format_grammar grammar
;
77 const char* format
= "E2, EN15.7, E20.10E3, E, EN";
79 parse_info
<> pi
= parse(format
, grammar
, blank_p
);
82 cout
<< "Test concluded successful" << endl
;
86 BOOST_SPIRIT_ASSERT(false); // Test fails