]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/lex/set_token_value_phoenix.cpp
1 // Copyright (c) 2009 Carl Barron
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/detail/lightweight_test.hpp>
10 #include <boost/spirit/include/lex.hpp>
11 #include <boost/spirit/include/lex_lexertl.hpp>
12 #include <boost/spirit/include/phoenix.hpp>
14 namespace lex
= boost::spirit::lex
;
15 namespace phoenix
= boost::phoenix
;
17 ///////////////////////////////////////////////////////////////////////////////
21 struct result
{ typedef int type
; };
24 int operator () (const A
&x
) const
28 phoenix::function
<square_impl
> const square
= square_impl();
30 ///////////////////////////////////////////////////////////////////////////////
31 template <class Lexer
>
32 struct test_tokens
: lex::lexer
<Lexer
>
37 this->self
= a
[lex::_val
= square(*lex::_start
)];
40 lex::token_def
<int> a
;
45 template <class Token
>
46 bool operator() (Token
const& x
) const
48 BOOST_TEST(x
.value().which() == 1);
49 BOOST_TEST(boost::get
<int>(x
.value()) == 9409); // 9409 == 'a' * 'a'
54 ///////////////////////////////////////////////////////////////////////////////
57 typedef lex::lexertl::token
<std::string::iterator
58 , boost::mpl::vector
<int> > token_type
;
61 std::string::iterator
first(in
.begin());
63 test_tokens
<lex::lexertl::actor_lexer
<token_type
> > the_lexer
;
64 BOOST_TEST(lex::tokenize(first
, in
.end(), the_lexer
, catch_result()));
66 return boost::report_errors();