blob: 588f60dec3263009eec50d31fdf545fa04050f32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*=============================================================================
Copyright (c) 2019 Nikita Kniazev
Use, modification and distribution is subject to 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(BOOST_SPIRIT_TEST_X3_UTILS_HPP)
#define BOOST_SPIRIT_TEST_X3_UTILS_HPP
#include <boost/spirit/home/x3/core/parser.hpp>
struct move_only
{
move_only() = default;
move_only(move_only&&) = default;
move_only& operator=(move_only&&) = default;
};
template <typename T>
struct synth_parser : boost::spirit::x3::parser<synth_parser<T>>
{
typedef T attribute_type;
static bool const has_attribute = true;
static bool const handles_container = false;
template <typename Iterator, typename Context,
typename RuleContext, typename Attribute>
bool parse(Iterator& iter, Iterator const& last, Context const&,
RuleContext&, Attribute& attr) const
{
if (iter != last && *iter == 's') {
++iter;
boost::spirit::x3::traits::move_to(attribute_type{}, attr);
return true;
}
return false;
}
};
template <typename T>
synth_parser<T> synth{};
synth_parser<move_only> const synth_move_only{};
#endif
|