2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00
Files
spirit/test/qi/actions2.cpp
Nikita Kniazev 4ea7e3a7b7 Deprecate Phoenix transition headers
There is no purpose in these transition headers, Phoenix V2 was removed 8 years ago.
2021-09-28 22:24:57 +03:00

67 lines
1.5 KiB
C++

/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if defined(_MSC_VER)
# pragma warning(disable: 4180) // qualifier applied to function type
// has no meaning; ignored
#endif
// This tests the new behavior allowing attribute compatibility
// to semantic actions
#define BOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT
#include <boost/spirit/include/qi_action.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/phoenix/bind.hpp>
#include <string>
#include "test.hpp"
void f(std::string const& s)
{
std::cout << "parsing got: " << s << std::endl;
}
std::string s;
void b(char c)
{
s += c;
}
int main()
{
namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;
using spirit_test::test_attr;
using spirit_test::test;
{
qi::rule<char const*, std::string()> r;
r %= (+qi::char_)[phoenix::bind(&f, qi::_1)];
std::string attr;
BOOST_TEST(test_attr("abcdef", r, attr));
BOOST_TEST(attr == "abcdef");
}
{ // chaining
using namespace boost::spirit::ascii;
s = "";
BOOST_TEST(test("a", char_[b][b]));
BOOST_TEST(s == "aa");
}
return boost::report_errors();
}