]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/switch_problem.cpp
1 /*=============================================================================
2 Copyright (c) 2004 Angus Leeming
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 =============================================================================*/
10 ///////////////////////////////////////////////////////////////////////////////
12 // The switch_p parser was broken sometime during the boost 1.32 development
13 // cycle. This little program tests it, the for_p parser and the limit_d
16 ///////////////////////////////////////////////////////////////////////////////
18 #include <boost/spirit/include/classic_core.hpp>
19 #include <boost/spirit/include/classic_for.hpp>
20 #include <boost/spirit/include/classic_switch.hpp>
21 #include <boost/spirit/include/classic_position_iterator.hpp>
22 #include <boost/spirit/include/classic_confix.hpp>
24 #include <boost/spirit/include/phoenix1.hpp>
29 namespace spirit
= BOOST_SPIRIT_CLASSIC_NS
;
31 typedef unsigned int uint
;
33 struct switch_grammar
: public spirit::grammar
<switch_grammar
> {
34 template <typename ScannerT
>
36 definition(switch_grammar
const & self
);
38 typedef spirit::rule
<ScannerT
> rule_t
;
39 rule_t
const & start() const { return expression
; }
49 template <typename ScannerT
>
50 switch_grammar::definition
<ScannerT
>::definition(switch_grammar
const & /*self*/)
59 using spirit::limit_d
;
61 using spirit::switch_p
;
66 uint_p
[var(nnodes
) = arg1
] >>
69 var(index
) <= var(nnodes
),
72 limit_d(cref(index
), cref(index
))[uint_p
] >>
85 std::string
const data("NNODES 3\n"
88 "3 n 3"); // JDG 10-18-2005 removed trailing \n to
89 // avoid post skip problems
91 typedef spirit::position_iterator
<std::string::const_iterator
>
94 spirit::parse_info
<iterator_t
> const info
=
95 parse(iterator_t(data
.begin(), data
.end(), "switch test"),
101 spirit::file_position
const fp
= info
.stop
.get_position();
102 std::cerr
<< "Parsing failed at line " << fp
.line
103 << ", column " << fp
.column
<< ".\n";
106 return info
.full
? 0 : 1;