]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/select_p_with_rule.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / 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/
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 #include <iostream>
10
11 #define PHOENIX_LIMIT 2
12 #define BOOST_SPIRIT_SELECT_LIMIT 2
13 #define BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT 2
14
15 #include <boost/spirit/include/classic_core.hpp>
16 #include <boost/spirit/include/classic_lists.hpp>
17 #include <boost/spirit/include/classic_select.hpp>
18
19 using namespace BOOST_SPIRIT_CLASSIC_NS;
20 using namespace std;
21
22 struct format_grammar : public grammar<format_grammar>
23 {
24 template <typename ScannerT>
25 struct definition
26 {
27 definition(format_grammar const& /*self*/)
28 {
29 descriptor_list =
30 list_p(format_descriptor, ch_p(','))
31 ;
32
33 format_descriptor =
34 select_p(E_descriptor, EN_descriptor)
35 ;
36
37 E_descriptor = // E[w[.d][Ee]]
38 lexeme_d
39 [
40 (ch_p('E') - (str_p("EN")))
41 >> !(
42 min_limit_d(1u)[uint_p]
43 >> !(ch_p('.') >> uint_p)
44 >> !(ch_p('E') >> min_limit_d(1u)[uint_p])
45 )
46 ]
47 ;
48
49 EN_descriptor = // EN[w[.d][Ee]]
50 lexeme_d
51 [
52 str_p("EN")
53 >> !(
54 min_limit_d(1u)[uint_p]
55 >> !(ch_p('.') >> uint_p)
56 >> !(ch_p('E') >> min_limit_d(1u)[uint_p])
57 )
58 ]
59 ;
60 }
61
62 rule<ScannerT> descriptor_list;
63 rule<ScannerT> format_descriptor;
64 rule<ScannerT> E_descriptor;
65 rule<ScannerT> EN_descriptor;
66
67 rule<ScannerT> const& start() const
68 {
69 return descriptor_list;
70 }
71 };
72 };
73
74 int main()
75 {
76 format_grammar grammar;
77 const char* format = "E2, EN15.7, E20.10E3, E, EN";
78
79 parse_info<> pi = parse(format, grammar, blank_p);
80
81 if (pi.full) {
82 cout << "Test concluded successful" << endl;
83 return 0;
84 }
85 else {
86 BOOST_SPIRIT_ASSERT(false); // Test fails
87 return -1;
88 }
89 }