mirror of
https://github.com/boostorg/parser.git
synced 2026-01-19 04:22:13 +00:00
Grooming.
This commit is contained in:
@@ -47,11 +47,9 @@ namespace boost::parser::detail { namespace stl_interfaces {
|
||||
`T`. */
|
||||
template<typename T>
|
||||
#if defined(BOOST_STL_INTERFACES_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
|
||||
// clang-format off
|
||||
requires std::is_object_v<T>
|
||||
#endif
|
||||
struct proxy_arrow_result
|
||||
// clang-format on
|
||||
{
|
||||
constexpr proxy_arrow_result(T const & value) noexcept(
|
||||
noexcept(T(value))) :
|
||||
@@ -619,33 +617,25 @@ namespace boost::parser::detail { namespace stl_interfaces { BOOST_PARSER_DETAIL
|
||||
using iter_concept_t = typename iter_concept<Iterator>::type;
|
||||
|
||||
template<typename D, typename DifferenceType>
|
||||
// clang-format off
|
||||
concept plus_eq = requires (D d) { d += DifferenceType(1); };
|
||||
// clang-format on
|
||||
concept plus_eq = requires(D d) { d += DifferenceType(1); };
|
||||
|
||||
template<typename D, typename D2 = D>
|
||||
// clang-format off
|
||||
concept base_3way =
|
||||
#if defined(__cpp_impl_three_way_comparison)
|
||||
requires (D d, D2 d2) { access::base(d) <=> access::base(d2); };
|
||||
requires(D d, D2 d2) { access::base(d) <=> access::base(d2); };
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
template<typename D1, typename D2 = D1>
|
||||
// clang-format off
|
||||
concept base_eq =
|
||||
requires (D1 d1, D2 d2) { access::base(d1) == access::base(d2); };
|
||||
// clang-format on
|
||||
requires(D1 d1, D2 d2) { access::base(d1) == access::base(d2); };
|
||||
|
||||
template<typename D, typename D2 = D>
|
||||
// clang-format off
|
||||
concept iter_sub = requires (D d, D2 d2) {
|
||||
concept iter_sub = requires(D d, D2 d2) {
|
||||
typename D::difference_type;
|
||||
{d - d2} -> std::convertible_to<typename D::difference_type>;
|
||||
{ d - d2 } -> std::convertible_to<typename D::difference_type>;
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
// This iterator concept -> category mapping scheme follows the one
|
||||
// from zip_transform_view; see
|
||||
|
||||
@@ -328,23 +328,20 @@ namespace boost::parser::detail { namespace stl_interfaces {
|
||||
{
|
||||
constexpr adaptor(F f) : f_(f) {}
|
||||
|
||||
// clang-format off
|
||||
template<typename... Args>
|
||||
constexpr auto operator()(Args &&... args) const
|
||||
// clang-format on
|
||||
{
|
||||
#if BOOST_PARSER_DETAIL_STL_INTERFACES_USE_CONCEPTS
|
||||
if constexpr (std::is_invocable_v<F const &, Args...>) {
|
||||
return f_((Args &&) args...);
|
||||
return f_((Args &&)args...);
|
||||
} else {
|
||||
return closure(
|
||||
stl_interfaces::bind_back(f_, (Args &&) args...));
|
||||
return closure(stl_interfaces::bind_back(f_, (Args &&)args...));
|
||||
}
|
||||
#else
|
||||
return detail::adaptor_impl<
|
||||
F const &,
|
||||
detail::is_invocable_v<F const &, Args...>,
|
||||
Args...>::call(f_, (Args &&) args...);
|
||||
Args...>::call(f_, (Args &&)args...);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -97,17 +97,14 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
|
||||
template<typename T>
|
||||
concept grapheme_iter =
|
||||
// clang-format off
|
||||
std::input_iterator<T> &&
|
||||
code_point_range<std::iter_reference_t<T>> &&
|
||||
std::input_iterator<T> && code_point_range<std::iter_reference_t<T>> &&
|
||||
requires(T t) {
|
||||
{ t.base() } -> code_point_iter;
|
||||
// clang-format on
|
||||
};
|
||||
{ t.base() } -> code_point_iter;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
concept grapheme_range = std::ranges::input_range<T> &&
|
||||
grapheme_iter<std::ranges::iterator_t<T>>;
|
||||
grapheme_iter<std::ranges::iterator_t<T>>;
|
||||
|
||||
template<typename R>
|
||||
using code_point_iterator_t = decltype(std::declval<R>().begin().base());
|
||||
@@ -116,75 +113,63 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
using code_point_sentinel_t = decltype(std::declval<R>().end().base());
|
||||
|
||||
template<typename T, format F>
|
||||
concept grapheme_iter_code_unit =
|
||||
// clang-format off
|
||||
grapheme_iter<T> &&
|
||||
requires(T t) {
|
||||
concept grapheme_iter_code_unit = grapheme_iter<T> && requires(T t) {
|
||||
{ t.base().base() } -> code_unit_iter<F>;
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
template<typename T, format F>
|
||||
concept grapheme_range_code_unit = grapheme_range<T> &&
|
||||
concept grapheme_range_code_unit =
|
||||
grapheme_range<T> &&
|
||||
grapheme_iter_code_unit<std::ranges::iterator_t<T>, F>;
|
||||
|
||||
|
||||
namespace dtl {
|
||||
template<typename T, class CodeUnit>
|
||||
concept eraseable_insertable_sized_bidi_range =
|
||||
// clang-format off
|
||||
std::ranges::sized_range<T> &&
|
||||
std::ranges::input_range<T> &&
|
||||
std::ranges::sized_range<T> && std::ranges::input_range<T> &&
|
||||
requires(T t, CodeUnit const * it) {
|
||||
{ t.erase(t.begin(), t.end()) } ->
|
||||
std::same_as<std::ranges::iterator_t<T>>;
|
||||
{ t.insert(t.end(), it, it) } ->
|
||||
std::same_as<std::ranges::iterator_t<T>>;
|
||||
{
|
||||
t.erase(t.begin(), t.end())
|
||||
} -> std::same_as<std::ranges::iterator_t<T>>;
|
||||
{
|
||||
t.insert(t.end(), it, it)
|
||||
} -> std::same_as<std::ranges::iterator_t<T>>;
|
||||
};
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
concept utf8_string =
|
||||
// clang-format off
|
||||
utf8_code_unit<std::ranges::range_value_t<T>> &&
|
||||
dtl::eraseable_insertable_sized_bidi_range<
|
||||
T, std::ranges::range_value_t<T>>;
|
||||
// clang-format on
|
||||
concept utf8_string = utf8_code_unit<std::ranges::range_value_t<T>> &&
|
||||
dtl::eraseable_insertable_sized_bidi_range<
|
||||
T,
|
||||
std::ranges::range_value_t<T>>;
|
||||
|
||||
template<typename T>
|
||||
concept utf16_string =
|
||||
// clang-format off
|
||||
utf16_code_unit<std::ranges::range_value_t<T>> &&
|
||||
dtl::eraseable_insertable_sized_bidi_range<
|
||||
T, std::ranges::range_value_t<T>>;
|
||||
// clang-format on
|
||||
concept utf16_string = utf16_code_unit<std::ranges::range_value_t<T>> &&
|
||||
dtl::eraseable_insertable_sized_bidi_range<
|
||||
T,
|
||||
std::ranges::range_value_t<T>>;
|
||||
|
||||
template<typename T>
|
||||
concept utf_string = utf8_string<T> || utf16_string<T>;
|
||||
|
||||
template<typename T>
|
||||
// clang-format off
|
||||
concept transcoding_error_handler = requires(T t, std::string_view msg) {
|
||||
concept transcoding_error_handler = requires(T t, std::string_view msg) {
|
||||
{ t(msg) } -> std::same_as<char32_t>;
|
||||
// clang-format on
|
||||
};
|
||||
//]
|
||||
|
||||
// Clang 13 defines __cpp_lib_concepts but not std::indirectly copyable.
|
||||
#if defined(__clang_major__) && __clang_major__ <= 13
|
||||
template<typename In, typename Out>
|
||||
// clang-format off
|
||||
concept indirectly_copyable =
|
||||
std::indirectly_readable<In> &&
|
||||
std::indirectly_writable<Out, std::iter_reference_t<In>>;
|
||||
// clang-format on
|
||||
#else
|
||||
template<typename In, typename Out>
|
||||
concept indirectly_copyable = std::indirectly_copyable<In, Out>;
|
||||
#endif
|
||||
|
||||
}}}
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -51,13 +51,10 @@ namespace boost::parser::detail { namespace text { namespace detail {
|
||||
// that is comparable with T's interator type.
|
||||
template<typename T>
|
||||
concept cp_sentinel_gr_rng =
|
||||
// clang-format off
|
||||
grapheme_range<T> &&
|
||||
!grapheme_iter<sentinel_t<T>> &&
|
||||
grapheme_range<T> && !grapheme_iter<sentinel_t<T>> &&
|
||||
requires(iterator_t<T> first, sentinel_t<T> last) {
|
||||
{ first.base() == last } -> std::convertible_to<bool>;
|
||||
// clang-format on
|
||||
};
|
||||
{ first.base() == last } -> std::convertible_to<bool>;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using gr_rng_cp_iter_t = decltype(std::declval<iterator_t<T>>().base());
|
||||
|
||||
@@ -2350,11 +2350,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf8_inserter(Cont & c, typename Cont::iterator it)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return std::insert_iterator<Cont>(c, it);
|
||||
@@ -2366,11 +2364,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf16_inserter(Cont & c, typename Cont::iterator it)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return utf_16_to_8_insert_iterator<Cont>(c, it);
|
||||
@@ -2382,11 +2378,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf32_inserter(Cont & c, typename Cont::iterator it)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return utf_32_to_8_insert_iterator<Cont>(c, it);
|
||||
@@ -2398,11 +2392,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf8_back_inserter(Cont & c)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return std::back_insert_iterator<Cont>(c);
|
||||
@@ -2414,11 +2406,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf16_back_inserter(Cont & c)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return utf_16_to_8_back_insert_iterator<Cont>(c);
|
||||
@@ -2430,11 +2420,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf32_back_inserter(Cont & c)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return utf_32_to_8_back_insert_iterator<Cont>(c);
|
||||
@@ -2446,11 +2434,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf8_front_inserter(Cont & c)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return std::front_insert_iterator<Cont>(c);
|
||||
@@ -2462,11 +2448,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf16_front_inserter(Cont & c)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return utf_16_to_8_front_insert_iterator<Cont>(c);
|
||||
@@ -2478,11 +2462,9 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
}
|
||||
|
||||
template<typename Cont>
|
||||
// clang-format off
|
||||
requires requires { typename Cont::value_type; } &&
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
utf_code_unit<typename Cont::value_type>
|
||||
constexpr auto from_utf32_front_inserter(Cont & c)
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (sizeof(typename Cont::value_type) == 1) {
|
||||
return utf_32_to_8_front_insert_iterator<Cont>(c);
|
||||
@@ -2492,7 +2474,6 @@ namespace boost::parser::detail { namespace text { BOOST_PARSER_DETAIL_TEXT_NAME
|
||||
return std::front_insert_iterator<Cont>(c);
|
||||
}
|
||||
}
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -423,49 +423,57 @@ namespace boost::parser::detail { namespace text {
|
||||
#if defined(__cpp_char8_t)
|
||||
inline constexpr detail::as_charn_impl<char8_view, format::utf8> as_char8_t;
|
||||
#endif
|
||||
inline constexpr detail::as_charn_impl<char16_view, format::utf16> as_char16_t;
|
||||
inline constexpr detail::as_charn_impl<char32_view, format::utf32> as_char32_t;
|
||||
inline constexpr detail::as_charn_impl<char16_view, format::utf16>
|
||||
as_char16_t;
|
||||
inline constexpr detail::as_charn_impl<char32_view, format::utf32>
|
||||
as_char32_t;
|
||||
|
||||
// clang-format off
|
||||
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
|
||||
template<utf_range V>
|
||||
requires std::ranges::view<V> && std::ranges::forward_range<V>
|
||||
requires std::ranges::view<V> && std::ranges::forward_range<V>
|
||||
#else
|
||||
template<typename V>
|
||||
#endif
|
||||
class unpacking_view : public stl_interfaces::view_interface<unpacking_view<V>> {
|
||||
V base_ = V();
|
||||
class unpacking_view
|
||||
: public stl_interfaces::view_interface<unpacking_view<V>>
|
||||
{
|
||||
V base_ = V();
|
||||
|
||||
public:
|
||||
constexpr unpacking_view()
|
||||
constexpr unpacking_view()
|
||||
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
|
||||
requires std::default_initializable<V>
|
||||
requires std::default_initializable<V>
|
||||
#endif
|
||||
= default;
|
||||
constexpr unpacking_view(V base) : base_(std::move(base)) {}
|
||||
= default;
|
||||
constexpr unpacking_view(V base) : base_(std::move(base)) {}
|
||||
|
||||
constexpr V base() const &
|
||||
constexpr V base() const &
|
||||
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
|
||||
requires std::copy_constructible<V>
|
||||
requires std::copy_constructible<V>
|
||||
#endif
|
||||
{ return base_; }
|
||||
constexpr V base() && { return std::move(base_); }
|
||||
{
|
||||
return base_;
|
||||
}
|
||||
constexpr V base() && { return std::move(base_); }
|
||||
|
||||
constexpr auto code_units() const noexcept {
|
||||
auto unpacked = boost::parser::detail::text::unpack_iterator_and_sentinel(detail::begin(base_), detail::end(base_));
|
||||
return BOOST_PARSER_DETAIL_TEXT_SUBRANGE(unpacked.first, unpacked.last);
|
||||
}
|
||||
constexpr auto code_units() const noexcept
|
||||
{
|
||||
auto unpacked =
|
||||
boost::parser::detail::text::unpack_iterator_and_sentinel(
|
||||
detail::begin(base_), detail::end(base_));
|
||||
return BOOST_PARSER_DETAIL_TEXT_SUBRANGE(
|
||||
unpacked.first, unpacked.last);
|
||||
}
|
||||
|
||||
constexpr auto begin() { return code_units().begin(); }
|
||||
constexpr auto begin() const { return code_units().begin(); }
|
||||
constexpr auto begin() { return code_units().begin(); }
|
||||
constexpr auto begin() const { return code_units().begin(); }
|
||||
|
||||
constexpr auto end() { return code_units().end(); }
|
||||
constexpr auto end() const { return code_units().end(); }
|
||||
constexpr auto end() { return code_units().end(); }
|
||||
constexpr auto end() const { return code_units().end(); }
|
||||
};
|
||||
|
||||
template<class R>
|
||||
unpacking_view(R &&) -> unpacking_view<detail::all_t<R>>;
|
||||
// clang-format on
|
||||
|
||||
#if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS
|
||||
template<format Format, utf_range V>
|
||||
|
||||
@@ -4434,22 +4434,18 @@ namespace boost { namespace parser {
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
// clang-format off
|
||||
template<typename Action, typename Attribute>
|
||||
using action_direct_call_expr =
|
||||
decltype(std::declval<Action>()(std::declval<Attribute>()));
|
||||
template<typename Action, typename Attribute>
|
||||
using action_apply_call_expr =
|
||||
decltype(hl::apply(std::declval<Action>(), std::declval<Attribute>()));
|
||||
using action_apply_call_expr = decltype(hl::apply(
|
||||
std::declval<Action>(), std::declval<Attribute>()));
|
||||
template<typename Action, typename Attribute, typename Context>
|
||||
using action_assignable_to_val_direct_expr =
|
||||
decltype(_val(std::declval<Context>()) =
|
||||
std::declval<Action>()(std::declval<Attribute>()));
|
||||
decltype(_val(std::declval<Context>()) = std::declval<Action>()(std::declval<Attribute>()));
|
||||
template<typename Action, typename Attribute, typename Context>
|
||||
using action_assignable_to_val_apply_expr =
|
||||
decltype(_val(std::declval<Context>()) =
|
||||
hl::apply(std::declval<Action>(), std::declval<Attribute>()));
|
||||
// clang-format on
|
||||
decltype(_val(std::declval<Context>()) = hl::apply(std::declval<Action>(), std::declval<Attribute>()));
|
||||
|
||||
template<typename Action, typename Attribute, typename Context>
|
||||
constexpr auto action_assignable_to_val_direct()
|
||||
@@ -6684,8 +6680,7 @@ namespace boost { namespace parser {
|
||||
\tparam T Constrained by `!parsable_range_like<T>`. */
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
template<typename T>
|
||||
// clang-format off
|
||||
requires (!parsable_range_like<T>)
|
||||
requires(!parsable_range_like<T>)
|
||||
#else
|
||||
template<
|
||||
typename T,
|
||||
@@ -6693,7 +6688,6 @@ namespace boost { namespace parser {
|
||||
std::enable_if_t<!detail::is_parsable_range_like_v<T>>>
|
||||
#endif
|
||||
constexpr auto operator()(T x) const noexcept
|
||||
// clang-format on
|
||||
{
|
||||
BOOST_PARSER_ASSERT(
|
||||
(detail::is_nope_v<Expected> &&
|
||||
@@ -6758,10 +6752,9 @@ namespace boost { namespace parser {
|
||||
|
||||
\tparam R Additionally constrained by
|
||||
`std::same_as<std::ranges::range_value_t<R>, char32_t>`. */
|
||||
// clang-format off
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
template<parsable_range_like R>
|
||||
requires std::same_as<std::ranges::range_value_t<R>, char32_t>
|
||||
requires std::same_as<std::ranges::range_value_t<R>, char32_t>
|
||||
#else
|
||||
template<
|
||||
typename R,
|
||||
@@ -6770,14 +6763,13 @@ namespace boost { namespace parser {
|
||||
std::is_same_v<detail::range_value_t<R>, char32_t>>>
|
||||
#endif
|
||||
constexpr auto operator()(sorted_t, R && r) const noexcept
|
||||
// clang-format on
|
||||
{
|
||||
BOOST_PARSER_ASSERT(
|
||||
((!std::is_rvalue_reference_v<R &&> ||
|
||||
!detail::is_range<detail::remove_cv_ref_t<R>>) &&
|
||||
"It looks like you tried to pass an rvalue range to "
|
||||
"char_(). Don't do that, or you'll end up with dangling "
|
||||
"references."));
|
||||
"It looks like you tried to pass an rvalue range to "
|
||||
"char_(). Don't do that, or you'll end up with dangling "
|
||||
"references."));
|
||||
BOOST_PARSER_ASSERT(
|
||||
(detail::is_nope_v<Expected> &&
|
||||
"If you're seeing this, you tried to chain calls on char_, "
|
||||
@@ -7411,8 +7403,7 @@ namespace boost { namespace parser {
|
||||
that uses `x` as its quotation marks. */
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
template<typename T>
|
||||
// clang-format off
|
||||
requires (!parsable_range_like<T>)
|
||||
requires(!parsable_range_like<T>)
|
||||
#else
|
||||
template<
|
||||
typename T,
|
||||
@@ -7420,7 +7411,6 @@ namespace boost { namespace parser {
|
||||
std::enable_if_t<!detail::is_parsable_range_like_v<T>>>
|
||||
#endif
|
||||
constexpr auto operator()(T x) const noexcept
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (!detail::is_nope_v<Quotes>) {
|
||||
BOOST_PARSER_ASSERT(
|
||||
@@ -7476,8 +7466,7 @@ namespace boost { namespace parser {
|
||||
Note that `"\\"` and `"\ch"` are always valid escape sequences. */
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
template<typename T, typename U>
|
||||
// clang-format off
|
||||
requires (!parsable_range_like<T>)
|
||||
requires(!parsable_range_like<T>)
|
||||
#else
|
||||
template<
|
||||
typename T,
|
||||
@@ -7486,7 +7475,6 @@ namespace boost { namespace parser {
|
||||
std::enable_if_t<!detail::is_parsable_range_like_v<T>>>
|
||||
#endif
|
||||
auto operator()(T x, symbols<U> const & escapes) const noexcept
|
||||
// clang-format on
|
||||
{
|
||||
if constexpr (!detail::is_nope_v<Quotes>) {
|
||||
BOOST_PARSER_ASSERT(
|
||||
@@ -7496,9 +7484,8 @@ namespace boost { namespace parser {
|
||||
"it!'"));
|
||||
}
|
||||
auto symbols = symbol_parser(escapes.parser_);
|
||||
auto parser =
|
||||
quoted_string_parser<detail::nope, decltype(symbols)>(
|
||||
char32_t(x), symbols);
|
||||
auto parser = quoted_string_parser<detail::nope, decltype(symbols)>(
|
||||
char32_t(x), symbols);
|
||||
return parser_interface(parser);
|
||||
}
|
||||
|
||||
@@ -8638,10 +8625,8 @@ namespace boost { namespace parser {
|
||||
Attr & attr,
|
||||
trace trace_mode = trace::off)
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
// clang-format off
|
||||
requires (
|
||||
requires(
|
||||
!detail::derived_from_parser_interface_v<std::remove_cvref_t<Attr>>)
|
||||
// clang-format on
|
||||
#endif
|
||||
{
|
||||
detail::attr_reset reset(attr);
|
||||
|
||||
@@ -77,22 +77,16 @@ namespace boost::parser {
|
||||
range_rvalue_reference_t<V2>>;
|
||||
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
// clang-format off
|
||||
template<typename ReplacementV, typename V>
|
||||
concept concatable = requires {
|
||||
typename detail::concat_reference_t<ReplacementV, V>;
|
||||
typename detail::concat_value_t<ReplacementV, V>;
|
||||
typename detail::concat_rvalue_reference_t<ReplacementV, V>;
|
||||
};
|
||||
// clang-format on
|
||||
#else
|
||||
template<typename ReplacementV, typename V>
|
||||
// clang-format off
|
||||
using concatable_expr = decltype(
|
||||
std::declval<concat_reference_t<ReplacementV, V>>(),
|
||||
std::declval<concat_value_t<ReplacementV, V>>(),
|
||||
std::declval<concat_rvalue_reference_t<ReplacementV, V>>());
|
||||
// clang-format on
|
||||
using concatable_expr =
|
||||
decltype(std::declval<concat_reference_t<ReplacementV, V>>(), std::declval<concat_value_t<ReplacementV, V>>(), std::declval<concat_rvalue_reference_t<ReplacementV, V>>());
|
||||
template<typename ReplacementV, typename V>
|
||||
constexpr bool concatable =
|
||||
is_detected_v<concatable_expr, ReplacementV, V>;
|
||||
@@ -107,7 +101,7 @@ namespace boost::parser {
|
||||
#endif
|
||||
>
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
requires concatable<V1, V2>
|
||||
requires concatable<V1, V2>
|
||||
#endif
|
||||
struct either_iterator_impl
|
||||
: detail::stl_interfaces::iterator_interface<
|
||||
@@ -169,14 +163,12 @@ namespace boost::parser {
|
||||
either_iterator_impl<V1, V2>>;
|
||||
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
// clang-format off
|
||||
template<typename ReplacementV, typename V>
|
||||
concept replacement_for = requires (ReplacementV replacement, V base) {
|
||||
concept replacement_for = requires(ReplacementV replacement, V base) {
|
||||
{ either_iterator<V, ReplacementV>(replacement.begin()) };
|
||||
{ either_iterator<V, ReplacementV>(replacement.end()) };
|
||||
{ either_iterator<V, ReplacementV>(base.begin()) };
|
||||
};
|
||||
// clang-format on
|
||||
#else
|
||||
template<typename ReplacementV, typename V>
|
||||
using replacement_for_expr = decltype(
|
||||
@@ -528,23 +520,19 @@ namespace boost::parser {
|
||||
typename GlobalState,
|
||||
typename ErrorHandler,
|
||||
typename SkipParser>
|
||||
requires
|
||||
// clang-format off
|
||||
std::ranges::viewable_range<R> &&
|
||||
std::ranges::viewable_range<ReplacementR> &&
|
||||
// clang-format on
|
||||
can_replace_view<
|
||||
to_range_t<R>,
|
||||
decltype(to_range<
|
||||
ReplacementR,
|
||||
true,
|
||||
detail::range_utf_format_v<R>>::
|
||||
call(std::declval<ReplacementR>())),
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
// clang-format off
|
||||
requires std::ranges::viewable_range<R> &&
|
||||
std::ranges::viewable_range<ReplacementR> &&
|
||||
can_replace_view<
|
||||
to_range_t<R>,
|
||||
decltype(to_range<
|
||||
ReplacementR,
|
||||
true,
|
||||
detail::range_utf_format_v<R>>::
|
||||
call(std::declval<ReplacementR>())),
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
@@ -552,10 +540,9 @@ namespace boost::parser {
|
||||
parser_interface<SkipParser> const & skip,
|
||||
ReplacementR && replacement,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return replace_view(
|
||||
to_range<R>::call((R &&) r),
|
||||
to_range<R>::call((R &&)r),
|
||||
parser,
|
||||
skip,
|
||||
to_range<
|
||||
@@ -572,36 +559,31 @@ namespace boost::parser {
|
||||
typename Parser,
|
||||
typename GlobalState,
|
||||
typename ErrorHandler>
|
||||
requires
|
||||
// clang-format off
|
||||
std::ranges::viewable_range<R> &&
|
||||
std::ranges::viewable_range<ReplacementR> &&
|
||||
// clang-format on
|
||||
can_replace_view<
|
||||
to_range_t<R>,
|
||||
decltype(to_range<
|
||||
ReplacementR,
|
||||
true,
|
||||
detail::range_utf_format_v<R>>::
|
||||
call(std::declval<ReplacementR>())),
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
// clang-format off
|
||||
requires std::ranges::viewable_range<R> &&
|
||||
std::ranges::viewable_range<ReplacementR> &&
|
||||
can_replace_view<
|
||||
to_range_t<R>,
|
||||
decltype(to_range<
|
||||
ReplacementR,
|
||||
true,
|
||||
detail::range_utf_format_v<R>>::
|
||||
call(std::declval<ReplacementR>())),
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
parser,
|
||||
ReplacementR && replacement,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return (*this)(
|
||||
(R &&) r,
|
||||
(R &&)r,
|
||||
parser,
|
||||
parser_interface<eps_parser<detail::phony>>{},
|
||||
(ReplacementR &&) replacement,
|
||||
(ReplacementR &&)replacement,
|
||||
trace_mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -541,25 +541,21 @@ namespace boost::parser {
|
||||
typename GlobalState,
|
||||
typename ErrorHandler,
|
||||
typename SkipParser>
|
||||
requires(
|
||||
std::ranges::viewable_range<R>) &&
|
||||
can_search_all_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
// clang-format off
|
||||
requires(std::ranges::viewable_range<R>) && can_search_all_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
parser,
|
||||
parser_interface<SkipParser> const & skip,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return search_all_view(
|
||||
to_range<R>::call((R &&) r), parser, skip, trace_mode);
|
||||
to_range<R>::call((R &&)r), parser, skip, trace_mode);
|
||||
}
|
||||
|
||||
template<
|
||||
@@ -567,24 +563,21 @@ namespace boost::parser {
|
||||
typename Parser,
|
||||
typename GlobalState,
|
||||
typename ErrorHandler>
|
||||
requires(
|
||||
std::ranges::viewable_range<R>) &&
|
||||
can_search_all_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
// clang-format off
|
||||
requires(std::ranges::viewable_range<R>) &&
|
||||
can_search_all_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
parser,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return (*this)(
|
||||
(R &&) r,
|
||||
(R &&)r,
|
||||
parser,
|
||||
parser_interface<eps_parser<detail::phony>>{},
|
||||
trace_mode);
|
||||
|
||||
@@ -258,25 +258,21 @@ namespace boost::parser {
|
||||
typename GlobalState,
|
||||
typename ErrorHandler,
|
||||
typename SkipParser>
|
||||
requires(
|
||||
std::ranges::viewable_range<R>) &&
|
||||
can_split_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
// clang-format off
|
||||
requires(std::ranges::viewable_range<R>) && can_split_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
parser,
|
||||
parser_interface<SkipParser> const & skip,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return split_view(
|
||||
to_range<R>::call((R &&) r), parser, skip, trace_mode);
|
||||
to_range<R>::call((R &&)r), parser, skip, trace_mode);
|
||||
}
|
||||
|
||||
template<
|
||||
@@ -284,24 +280,21 @@ namespace boost::parser {
|
||||
typename Parser,
|
||||
typename GlobalState,
|
||||
typename ErrorHandler>
|
||||
requires(
|
||||
std::ranges::viewable_range<R>) &&
|
||||
can_split_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
// clang-format off
|
||||
requires(std::ranges::viewable_range<R>) &&
|
||||
can_split_view<
|
||||
to_range_t<R>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
parser,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return (*this)(
|
||||
(R &&) r,
|
||||
(R &&)r,
|
||||
parser,
|
||||
parser_interface<eps_parser<detail::phony>>{},
|
||||
trace_mode);
|
||||
|
||||
@@ -28,16 +28,15 @@ namespace boost::parser {
|
||||
using range_attr_t = attr_type<iterator_t<R>, sentinel_t<R>, Parser>;
|
||||
|
||||
#if BOOST_PARSER_USE_CONCEPTS
|
||||
// clang-format off
|
||||
template<typename F, typename V, typename Parser>
|
||||
concept transform_replacement_for =
|
||||
std::regular_invocable<F &, range_attr_t<V, Parser>> &&
|
||||
detail::replacement_for<
|
||||
std::invoke_result_t<F &, range_attr_t<V, Parser>>, V> &&
|
||||
std::invoke_result_t<F &, range_attr_t<V, Parser>>,
|
||||
V> &&
|
||||
(detail::range_utf_format_v<V> ==
|
||||
detail::range_utf_format_v<
|
||||
std::invoke_result_t<F &, range_attr_t<V, Parser>>>);
|
||||
// clang-format on
|
||||
#else
|
||||
template<typename F, typename V, typename Parser>
|
||||
using transform_replacement_for_expr = decltype(std::declval<F &>()(
|
||||
@@ -646,24 +645,20 @@ namespace boost::parser {
|
||||
typename GlobalState,
|
||||
typename ErrorHandler,
|
||||
typename SkipParser>
|
||||
requires
|
||||
// clang-format off
|
||||
std::ranges::viewable_range<R> &&
|
||||
std::regular_invocable<
|
||||
F &,
|
||||
range_attr_t<to_range_t<R>, Parser>> &&
|
||||
// clang-format on
|
||||
can_transform_replace_view<
|
||||
to_range_t<R>,
|
||||
utf_rvalue_shim<
|
||||
to_range_t<R>,
|
||||
std::remove_cvref_t<F>,
|
||||
range_attr_t<to_range_t<R>, Parser>>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
// clang-format off
|
||||
requires std::ranges::viewable_range<R> &&
|
||||
std::regular_invocable<
|
||||
F &,
|
||||
range_attr_t<to_range_t<R>, Parser>> &&
|
||||
can_transform_replace_view<
|
||||
to_range_t<R>,
|
||||
utf_rvalue_shim<
|
||||
to_range_t<R>,
|
||||
std::remove_cvref_t<F>,
|
||||
range_attr_t<to_range_t<R>, Parser>>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
SkipParser>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
@@ -671,16 +666,15 @@ namespace boost::parser {
|
||||
parser_interface<SkipParser> const & skip,
|
||||
F && f,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return transform_replace_view(
|
||||
to_range<R>::call((R &&) r),
|
||||
to_range<R>::call((R &&)r),
|
||||
parser,
|
||||
skip,
|
||||
utf_rvalue_shim<
|
||||
to_range_t<R>,
|
||||
std::remove_cvref_t<F>,
|
||||
range_attr_t<to_range_t<R>, Parser>>((F &&) f),
|
||||
range_attr_t<to_range_t<R>, Parser>>((F &&)f),
|
||||
trace_mode);
|
||||
}
|
||||
|
||||
@@ -690,37 +684,32 @@ namespace boost::parser {
|
||||
typename Parser,
|
||||
typename GlobalState,
|
||||
typename ErrorHandler>
|
||||
requires
|
||||
// clang-format off
|
||||
std::ranges::viewable_range<R> &&
|
||||
std::regular_invocable<
|
||||
F &,
|
||||
range_attr_t<to_range_t<R>, Parser>> &&
|
||||
// clang-format on
|
||||
can_transform_replace_view<
|
||||
to_range_t<R>,
|
||||
utf_rvalue_shim<
|
||||
to_range_t<R>,
|
||||
std::remove_cvref_t<F>,
|
||||
range_attr_t<to_range_t<R>, Parser>>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
// clang-format off
|
||||
requires std::ranges::viewable_range<R> &&
|
||||
std::regular_invocable<
|
||||
F &,
|
||||
range_attr_t<to_range_t<R>, Parser>> &&
|
||||
can_transform_replace_view<
|
||||
to_range_t<R>,
|
||||
utf_rvalue_shim<
|
||||
to_range_t<R>,
|
||||
std::remove_cvref_t<F>,
|
||||
range_attr_t<to_range_t<R>, Parser>>,
|
||||
Parser,
|
||||
GlobalState,
|
||||
ErrorHandler,
|
||||
parser_interface<eps_parser<detail::phony>>>
|
||||
[[nodiscard]] constexpr auto operator()(
|
||||
R && r,
|
||||
parser_interface<Parser, GlobalState, ErrorHandler> const &
|
||||
parser,
|
||||
F && f,
|
||||
trace trace_mode = trace::off) const
|
||||
// clang-format on
|
||||
{
|
||||
return (*this)(
|
||||
(R &&) r,
|
||||
(R &&)r,
|
||||
parser,
|
||||
parser_interface<eps_parser<detail::phony>>{},
|
||||
(F &&) f,
|
||||
(F &&)f,
|
||||
trace_mode);
|
||||
}
|
||||
|
||||
|
||||
2527
test/parser.cpp
2527
test/parser.cpp
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user