2
0
mirror of https://github.com/boostorg/parser.git synced 2026-01-27 07:02:12 +00:00

Fully internalize Boost.Text headers.

This commit is contained in:
Zach Laine
2020-09-19 22:27:47 -05:00
parent c8b5554fa3
commit 111efe1eb3
25 changed files with 328 additions and 561 deletions

View File

@@ -9,8 +9,8 @@
#include "json_fwd.hpp"
#include <boost/assert.hpp>
#include <boost/text/algorithm.hpp>
#include <boost/text/transcode_view.hpp>
#include <boost/parser/detail/text/algorithm.hpp>
#include <boost/parser/detail/text/transcode_view.hpp>
#include <functional>
#include <iomanip>

View File

@@ -8,7 +8,7 @@
#include <boost/parser/config.hpp>
#include <boost/parser/parser_fwd.hpp>
#include <boost/text/transcode_view.hpp>
#include <boost/parser/detail/text/transcode_view.hpp>
// Silence very verbose warnings about std::is_pod being deprecated. TODO:
// Remove this if/when Hana accepts releases the fix for this (already on

View File

@@ -6,6 +6,8 @@
#ifndef BOOST_PARSER_CONFIG_HPP
#define BOOST_PARSER_CONFIG_HPP
#include <boost/parser/detail/debug_assert.hpp>
// Included for definition of __cpp_lib_concepts.
#include <iterator>

View File

@@ -0,0 +1,17 @@
// Copyright (C) 2020 T. Zachary Laine
//
// 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)
#ifndef BOOST_PARSER_DETAIL_DEBUG_ASSERT_HPP
#define BOOST_PARSER_DETAIL_DEBUG_ASSERT_HPP
#if defined(BOOST_PARSER_STANDALONE)
#include <cassert>
#define BOOST_PARSER_DEBUG_ASSERT(condition) assert(condition)
#else
#include <boost/assert.hpp>
#define BOOST_PARSER_DEBUG_ASSERT(condition) BOOST_ASSERT(condition)
#endif
#endif

View File

@@ -450,7 +450,7 @@ namespace boost { namespace parser { namespace detail_spirit_x3 {
inline bool extract_sign(Iterator & first, Sentinel last)
{
(void)last; // silence unused warnings
BOOST_ASSERT(first != last); // precondition
BOOST_PARSER_DEBUG_ASSERT(first != last); // precondition
// Extract the sign
bool neg = *first == '-';
@@ -705,7 +705,7 @@ namespace boost { namespace parser { namespace detail_spirit_x3 {
if (!std::is_same_v<T, unused_type>)
frac_digits =
static_cast<int>(std::distance(savef, first));
BOOST_ASSERT(frac_digits >= 0);
BOOST_PARSER_DEBUG_ASSERT(frac_digits >= 0);
}
else if (!got_a_number || !p.allow_trailing_dot)
{

View File

@@ -5,7 +5,7 @@
#include <boost/parser/detail/detection.hpp>
#include <boost/hana.hpp>
#include <boost/text/transcode_view.hpp>
#include <boost/parser/detail/text/transcode_view.hpp>
#include <iomanip>
#include <iostream>

View File

@@ -3,10 +3,10 @@
// 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)
#ifndef BOOST_TEXT_ALGORITHM_HPP
#define BOOST_TEXT_ALGORITHM_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_ALGORITHM_HPP
#define BOOST_PARSER_DETAIL_TEXT_ALGORITHM_HPP
#include <boost/text/detail/sentinel_tag.hpp>
#include <boost/parser/detail/text/detail/sentinel_tag.hpp>
#include <boost/stl_interfaces/view_interface.hpp>
@@ -403,7 +403,7 @@ namespace boost { namespace text {
}}
#if BOOST_TEXT_USE_CONCEPTS
#if BOOST_PARSER_USE_CONCEPTS
namespace std::ranges {
template<typename Iter, typename Sentinel>

View File

@@ -3,18 +3,18 @@
// 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)
#ifndef BOOST_TEXT_CONCEPTS_HPP
#define BOOST_TEXT_CONCEPTS_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_CONCEPTS_HPP
#define BOOST_PARSER_DETAIL_TEXT_CONCEPTS_HPP
#include <boost/text/config.hpp>
#include <boost/text/utf.hpp>
#include <boost/parser/detail/text/config.hpp>
#include <boost/parser/detail/text/utf.hpp>
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
#include <ranges>
namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 {
namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 {
template<typename T, format F>
concept code_unit = std::integral<T> && sizeof(T) == (int)F;

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2020 T. Zachary Laine
//
// 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)
#ifndef BOOST_PARSER_DETAIL_TEXT_CONFIG_HPP
#define BOOST_PARSER_DETAIL_TEXT_CONFIG_HPP
// Included for definition of __cpp_lib_concepts.
#include <iterator>
// The inline namespaces v1 and v2 represent pre- and post-C++20. v1 is
// inline for standards before C++20, and v2 is inline for C++20 and later.
// Note that this only applies to code for which a v2 namespace alternative
// exists. Some instances of the v1 namespace may still be inline, if there
// is no v2 version of its contents.
#if BOOST_PARSER_USE_CONCEPTS
# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 namespace v1
# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 inline namespace v2
#else
# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 inline namespace v1
# define BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 namespace v2
#endif
#endif

View File

@@ -3,13 +3,13 @@
// 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)
#ifndef BOOST_TEXT_DANGLING_HPP
#define BOOST_TEXT_DANGLING_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_DANGLING_HPP
#define BOOST_PARSER_DETAIL_TEXT_DANGLING_HPP
#include <boost/text/config.hpp>
#include <boost/parser/detail/text/config.hpp>
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
namespace boost::text {
template<std::ranges::range R, std::ranges::view V>

View File

@@ -3,12 +3,10 @@
// 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)
#ifndef BOOST_TEXT_DETAIL_ALGORITHM_HPP
#define BOOST_TEXT_DETAIL_ALGORITHM_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_ALGORITHM_HPP
#define BOOST_PARSER_DETAIL_TEXT_DETAIL_ALGORITHM_HPP
#include <boost/text/detail/iterator.hpp>
#include <boost/assert.hpp>
#include <boost/parser/detail/text/detail/iterator.hpp>
#include <numeric>
#include <type_traits>
@@ -23,7 +21,7 @@ namespace boost { namespace text { namespace detail {
using remove_cv_ref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
#if BOOST_TEXT_USE_CONCEPTS
#if BOOST_PARSER_USE_CONCEPTS
template<typename T>
using iterator_t = std::ranges::iterator_t<T>;

View File

@@ -3,10 +3,10 @@
// 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)
#ifndef BOOST_TEXT_DETAIL_ITERATOR_HPP
#define BOOST_TEXT_DETAIL_ITERATOR_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_ITERATOR_HPP
#define BOOST_PARSER_DETAIL_TEXT_DETAIL_ITERATOR_HPP
#include <boost/text/config.hpp>
#include <boost/parser/detail/text/config.hpp>
#include <boost/stl_interfaces/reverse_iterator.hpp>
#include <iterator>

View File

@@ -3,10 +3,10 @@
// 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)
#ifndef BOOST_TEXT_DETAIL_SENTINEL_TAG_HPP
#define BOOST_TEXT_DETAIL_SENTINEL_TAG_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_SENTINEL_TAG_HPP
#define BOOST_PARSER_DETAIL_TEXT_DETAIL_SENTINEL_TAG_HPP
#include <boost/text/config.hpp>
#include <boost/parser/detail/text/config.hpp>
namespace boost { namespace text { namespace detail {

View File

@@ -3,10 +3,10 @@
// 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)
#ifndef BOOST_TEXT_DETAIL_UNPACK_HPP
#define BOOST_TEXT_DETAIL_UNPACK_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_DETAIL_UNPACK_HPP
#define BOOST_PARSER_DETAIL_TEXT_DETAIL_UNPACK_HPP
#include <boost/text/transcode_iterator.hpp>
#include <boost/parser/detail/text/transcode_iterator.hpp>
namespace boost { namespace text { namespace detail {

View File

@@ -4,29 +4,13 @@
// 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)
#ifndef BOOST_TEXT_TRANSCODE_ALGORITHM_HPP
#define BOOST_TEXT_TRANSCODE_ALGORITHM_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_TRANSCODE_ALGORITHM_HPP
#define BOOST_PARSER_DETAIL_TEXT_TRANSCODE_ALGORITHM_HPP
#include <boost/text/transcode_iterator.hpp>
#include <boost/text/detail/unpack.hpp>
#include <boost/parser/detail/text/transcode_iterator.hpp>
#include <boost/parser/detail/text/detail/unpack.hpp>
#include <boost/config.hpp>
#include <boost/predef/hardware/simd.h>
#if !defined(BOOST_TEXT_USE_SIMD) || BOOST_TEXT_USE_SIMD == 1
#if BOOST_HW_SIMD_X86_SSE2_VERSION <= BOOST_HW_SIMD_X86
#if defined(BOOST_GCC) || defined(BOOST_CLANG)
#include <x86intrin.h>
#define BOOST_TEXT_USE_SIMD 1
#elif defined(BOOST_MSVC)
#include <intrin.h>
#define BOOST_TEXT_USE_SIMD 1
#else
#define BOOST_TEXT_USE_SIMD 0
#endif
#endif
#endif
namespace boost { namespace text {
@@ -42,7 +26,7 @@ namespace boost { namespace text {
namespace detail {
template<typename OutIter>
BOOST_TEXT_CXX14_CONSTEXPR OutIter
constexpr OutIter
read_into_utf8_iter(uint32_t cp, OutIter out)
{
if (cp < 0x80) {
@@ -74,7 +58,7 @@ namespace boost { namespace text {
}
template<typename OutIter>
BOOST_TEXT_CXX14_CONSTEXPR OutIter
constexpr OutIter
read_into_utf16_iter(uint32_t cp, OutIter out)
{
uint16_t const high_surrogate_base = 0xd7c0;
@@ -92,85 +76,6 @@ namespace boost { namespace text {
return out;
}
#if BOOST_TEXT_USE_SIMD
template<typename Iter>
__m128i load_chars_for_sse(Iter it) noexcept
{
std::array<char, 16> chars;
std::copy(it, it + 16, chars.begin());
return _mm_loadu_si128((__m128i const *)chars.data());
}
inline __m128i load_chars_for_sse(char const * it) noexcept
{
return _mm_loadu_si128((__m128i const *)it);
}
#if defined(BOOST_GCC) || defined(BOOST_CLANG)
inline int trailing_zeros(uint32_t x) noexcept
{
return __builtin_ctz(x);
}
#elif defined(BOOST_MSVC)
inline int trailing_zeros(uint32_t x) noexcept
{
unsigned long retval;
_BitScanForward(&retval, (unsigned long)x);
return (int)retval;
}
#else
// Table taken from
// https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup
inline int trailing_zeros(uint32_t x) noexcept
{
constexpr int debruijn_bit_position[32] = {
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9,
};
return debruijn_bit_position
[((uint32_t)((x & -x) * 0x077CB531U)) >> 27];
}
#endif
// TODO: Overload based on contiguous iterators in C++20 and later.
template<typename OutIter>
int32_t * sse_out_ptr(OutIter out, std::array<int32_t, 16> & tmp)
{
return tmp.data();
}
inline int32_t *
sse_out_ptr(int32_t * out, std::array<int32_t, 16> & tmp)
{
return out;
}
inline int32_t *
sse_out_ptr(uint32_t * out, std::array<int32_t, 16> & tmp)
{
return (int32_t *)out;
}
template<typename OutIter>
void finalize_sse_out(
OutIter & out, std::array<int32_t, 16> const & tmp, int incr)
{
out = std::copy(tmp.begin(), tmp.begin() + incr, out);
}
inline void finalize_sse_out(
int32_t *& out, std::array<int32_t, 16> const & tmp, int incr)
{
out += incr;
}
inline void finalize_sse_out(
uint32_t *& out, std::array<int32_t, 16> const & tmp, int incr)
{
out += incr;
}
#endif
template<
bool UseN,
typename InputIter,
@@ -205,31 +110,6 @@ namespace boost { namespace text {
OutIter out,
std::random_access_iterator_tag)
{
#if BOOST_TEXT_USE_SIMD
while ((int)sizeof(__m128i) <= last - first &&
(!UseN || (int)sizeof(__m128i) <= n)) {
if ((unsigned char)*first < 0x80) {
__m128i chunk = load_chars_for_sse(first);
int32_t mask = _mm_movemask_epi8(chunk);
__m128i half = _mm_unpacklo_epi8(chunk, _mm_set1_epi8(0));
std::array<int32_t, 16> temp;
int32_t * out_ptr = sse_out_ptr(out, temp);
_mm_storeu_si128((__m128i *)out_ptr, half);
half = _mm_unpackhi_epi8(chunk, _mm_set1_epi8(0));
_mm_storeu_si128((__m128i *)(out_ptr + 8), half);
int const incr = mask == 0 ? 16 : trailing_zeros(mask);
first += incr;
n -= incr;
finalize_sse_out(out, temp, incr);
} else {
auto const cp = detail::advance(first, last);
out = detail::read_into_utf16_iter(cp, out);
--n;
}
}
#endif
return transcode_utf_8_to_16<UseN>(
first, last, n, out, std::input_iterator_tag{});
}
@@ -268,40 +148,6 @@ namespace boost { namespace text {
OutIter out,
std::random_access_iterator_tag)
{
#if BOOST_TEXT_USE_SIMD
while ((int)sizeof(__m128i) <= last - first &&
(!UseN || (int)sizeof(__m128i) <= n)) {
if ((unsigned char)*first < 0x80) {
__m128i zero = _mm_set1_epi8(0);
__m128i chunk = load_chars_for_sse(first);
int32_t const mask = _mm_movemask_epi8(chunk);
__m128i half = _mm_unpacklo_epi8(chunk, zero);
__m128i qrtr = _mm_unpacklo_epi16(half, zero);
std::array<int32_t, 16> temp;
int32_t * out_ptr = sse_out_ptr(out, temp);
_mm_storeu_si128((__m128i *)out_ptr, qrtr);
qrtr = _mm_unpackhi_epi16(half, zero);
_mm_storeu_si128((__m128i *)(out_ptr + 4), qrtr);
half = _mm_unpackhi_epi8(chunk, zero);
qrtr = _mm_unpacklo_epi16(half, zero);
_mm_storeu_si128((__m128i *)(out_ptr + 8), qrtr);
qrtr = _mm_unpackhi_epi16(half, zero);
_mm_storeu_si128((__m128i *)(out_ptr + 12), qrtr);
int const incr = mask == 0 ? 16 : trailing_zeros(mask);
first += incr;
n -= incr;
finalize_sse_out(out, temp, incr);
} else {
*out = detail::advance(first, last);
++out;
--n;
}
}
#endif
return transcode_utf_8_to_32<UseN>(
first, last, n, out, std::input_iterator_tag{});
}
@@ -494,7 +340,7 @@ namespace boost { namespace text {
}}
namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 {
namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 {
namespace dtl {
template<
@@ -674,9 +520,9 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 {
}}}
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 {
namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 {
/** Copies the code points in the range `[first, last)` to `out`, changing
the encoding to UTF-8. */

View File

@@ -3,13 +3,13 @@
// 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)
#ifndef BOOST_TEXT_TRANSCODE_VIEW_HPP
#define BOOST_TEXT_TRANSCODE_VIEW_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_TRANSCODE_VIEW_HPP
#define BOOST_PARSER_DETAIL_TEXT_TRANSCODE_VIEW_HPP
#include <boost/text/transcode_algorithm.hpp>
#include <boost/text/concepts.hpp>
#include <boost/text/dangling.hpp>
#include <boost/text/detail/unpack.hpp>
#include <boost/parser/detail/text/transcode_algorithm.hpp>
#include <boost/parser/detail/text/concepts.hpp>
#include <boost/parser/detail/text/dangling.hpp>
#include <boost/parser/detail/text/detail/unpack.hpp>
#include <boost/stl_interfaces/view_interface.hpp>
@@ -150,7 +150,7 @@ namespace boost { namespace text {
}
/** A view over UTF-8 code units. */
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
template<utf8_iter I, std::sentinel_for<I> S = I>
#else
template<typename I, typename S = I>
@@ -218,7 +218,7 @@ namespace boost { namespace text {
};
/** A view over UTF-16 code units. */
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
template<utf16_iter I, std::sentinel_for<I> S = I>
#else
template<typename I, typename S = I>
@@ -286,7 +286,7 @@ namespace boost { namespace text {
};
/** A view over UTF-32 code units. */
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
template<utf32_iter I, std::sentinel_for<I> S = I>
#else
template<typename I, typename S = I>
@@ -353,7 +353,7 @@ namespace boost { namespace text {
}}
namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 {
namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V1 {
/** Returns a `utf8_view` over the data in `[first, last)`. The view will
transcode the data if necessary. */
@@ -504,9 +504,9 @@ namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V1 {
}}}
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_TEXT_USE_CONCEPTS
#if defined(BOOST_TEXT_DOXYGEN) || BOOST_PARSER_USE_CONCEPTS
namespace boost { namespace text { BOOST_TEXT_NAMESPACE_V2 {
namespace boost { namespace text { BOOST_PARSER_DETAIL_TEXT_NAMESPACE_V2 {
/** Returns a `utf8_view` over the data in `[first, last)`. The view will
transcode the data if necessary. */

View File

@@ -3,11 +3,11 @@
// 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)
#ifndef BOOST_TEXT_TRIE_HPP
#define BOOST_TEXT_TRIE_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_TRIE_HPP
#define BOOST_PARSER_DETAIL_TEXT_TRIE_HPP
#include <boost/text/trie_fwd.hpp>
#include <boost/text/algorithm.hpp>
#include <boost/parser/detail/text/trie_fwd.hpp>
#include <boost/parser/detail/text/algorithm.hpp>
#include <algorithm>
#include <memory>
@@ -35,7 +35,7 @@ namespace boost { namespace text {
auto operator=(U && u)
-> decltype(*this->t_ = static_cast<U &&>(u), *this)
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
*t_ = static_cast<U &&>(u);
return *this;
}
@@ -46,48 +46,48 @@ namespace boost { namespace text {
T const & operator*() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
T const * operator->() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return t_;
}
operator T const &() const & noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
operator T const &() const && noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
T & operator*() noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
T * operator->() noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return t_;
}
operator T &() & noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
operator T &() && noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
};
@@ -108,24 +108,24 @@ namespace boost { namespace text {
T & operator*() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
T * operator->() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return t_;
}
operator T &() const & noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
operator T &() const && noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
};
@@ -144,7 +144,7 @@ namespace boost { namespace text {
auto operator=(U && u)
-> decltype(*this->t_ = static_cast<U &&>(u), *this)
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
*t_ = static_cast<U &&>(u);
return *this;
}
@@ -154,24 +154,24 @@ namespace boost { namespace text {
bool const & operator*() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
bool const * operator->() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return t_;
}
bool & operator*() noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
bool * operator->() noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return t_;
}
};
@@ -191,12 +191,12 @@ namespace boost { namespace text {
bool const & operator*() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return *t_;
}
bool const * operator->() const noexcept
{
BOOST_ASSERT(t_);
BOOST_PARSER_DEBUG_ASSERT(t_);
return t_;
}
};
@@ -214,7 +214,7 @@ namespace boost { namespace text {
{
std::size_t value() const noexcept
{
BOOST_ASSERT(!"This should never be called.");
BOOST_PARSER_DEBUG_ASSERT(!"This should never be called.");
return 0;
}
@@ -536,7 +536,7 @@ namespace boost { namespace text {
match_result extend_match(match_result prev, KeyElementT e) const
noexcept
{
BOOST_ASSERT(prev.match);
BOOST_PARSER_DEBUG_ASSERT(prev.match);
auto e_ptr = &e;
return extend_subsequence_impl<true>(prev, e_ptr, e_ptr + 1);
}
@@ -549,7 +549,7 @@ namespace boost { namespace text {
extend_match(match_result prev, KeyIter first, Sentinel last) const
noexcept
{
BOOST_ASSERT(prev.match);
BOOST_PARSER_DEBUG_ASSERT(prev.match);
return extend_subsequence_impl<true>(prev, first, last);
}
@@ -908,7 +908,7 @@ namespace boost { namespace text {
}
trie_node_t & operator=(trie_node_t const & rhs)
{
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
parent_ == nullptr &&
"Assignment of trie_node_ts are defined only for the "
"header node.");
@@ -918,7 +918,7 @@ namespace boost { namespace text {
}
trie_node_t & operator=(trie_node_t && rhs)
{
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
parent_ == nullptr &&
"Move assignments of trie_node_ts are defined only for the "
"header node.");
@@ -981,7 +981,7 @@ namespace boost { namespace text {
key_element const & key(std::size_t i) const noexcept
{
BOOST_ASSERT(key_element(i) == i);
BOOST_PARSER_DEBUG_ASSERT(key_element(i) == i);
return key_element(i);
}
@@ -1001,7 +1001,7 @@ namespace boost { namespace text {
void swap(trie_node_t & other)
{
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
parent_ == nullptr &&
"Swaps of trie_node_ts are defined only for the header "
"node.");
@@ -1055,7 +1055,7 @@ namespace boost { namespace text {
[child](std::unique_ptr<trie_node_t> const & ptr) {
return child == ptr.get();
});
BOOST_ASSERT(it != children_.end());
BOOST_PARSER_DEBUG_ASSERT(it != children_.end());
erase(it - children_.begin());
}
@@ -1159,7 +1159,7 @@ namespace boost { namespace text {
}
trie_node_t & operator=(trie_node_t const & rhs)
{
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
parent_ == nullptr &&
"Assignment of trie_node_ts are defined only for the "
"header node.");
@@ -1169,7 +1169,7 @@ namespace boost { namespace text {
}
trie_node_t & operator=(trie_node_t && rhs)
{
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
parent_ == nullptr &&
"Move assignments of trie_node_ts are defined only for the "
"header node.");
@@ -1270,7 +1270,7 @@ namespace boost { namespace text {
void swap(trie_node_t & other)
{
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
parent_ == nullptr &&
"Swaps of trie_node_ts are defined only for the header "
"node.");
@@ -1297,7 +1297,7 @@ namespace boost { namespace text {
Compare const & comp,
std::unique_ptr<trie_node_t> && child)
{
BOOST_ASSERT(child->empty());
BOOST_PARSER_DEBUG_ASSERT(child->empty());
auto it = std::lower_bound(keys_.begin(), keys_.end(), e, comp);
it = keys_.insert(it, e);
auto const offset = it - keys_.begin();
@@ -1308,7 +1308,7 @@ namespace boost { namespace text {
}
iterator insert(std::unique_ptr<trie_node_t> && child)
{
BOOST_ASSERT(empty());
BOOST_PARSER_DEBUG_ASSERT(empty());
index_within_parent_.insert_ptr(child);
return children_.insert(children_.begin(), std::move(child));
}
@@ -1328,7 +1328,7 @@ namespace boost { namespace text {
[child](std::unique_ptr<trie_node_t> const & ptr) {
return child == ptr.get();
});
BOOST_ASSERT(it != children_.end());
BOOST_PARSER_DEBUG_ASSERT(it != children_.end());
erase(it - children_.begin());
}

View File

@@ -3,8 +3,8 @@
// 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)
#ifndef BOOST_TEXT_TRIE_FWD_HPP
#define BOOST_TEXT_TRIE_FWD_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_TRIE_FWD_HPP
#define BOOST_PARSER_DETAIL_TEXT_TRIE_FWD_HPP
namespace boost { namespace text {

View File

@@ -3,10 +3,10 @@
// 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)
#ifndef BOOST_TEXT_UTF_HPP
#define BOOST_TEXT_UTF_HPP
#ifndef BOOST_PARSER_DETAIL_TEXT_UTF_HPP
#define BOOST_PARSER_DETAIL_TEXT_UTF_HPP
#include <boost/text/config.hpp>
#include <boost/parser/detail/text/config.hpp>
#include <type_traits>

View File

@@ -4,8 +4,8 @@
#include <boost/parser/error_handling_fwd.hpp>
#include <boost/parser/detail/printing.hpp>
#include <boost/text/algorithm.hpp>
#include <boost/text/transcode_iterator.hpp>
#include <boost/parser/detail/text/algorithm.hpp>
#include <boost/parser/detail/text/transcode_iterator.hpp>
#include <array>
#include <functional>

View File

@@ -3,7 +3,7 @@
#include <boost/parser/config.hpp>
#include <boost/text/transcode_view.hpp>
#include <boost/parser/detail/text/transcode_view.hpp>
#include <iostream>
#include <string_view>

View File

@@ -12,8 +12,8 @@
#include <boost/preprocessor/variadic/elem.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
#endif
#include <boost/text/algorithm.hpp>
#include <boost/text/trie.hpp>
#include <boost/parser/detail/text/algorithm.hpp>
#include <boost/parser/detail/text/trie.hpp>
#include <type_traits>
#include <variant>
@@ -354,7 +354,7 @@ namespace boost { namespace parser {
// = 0; }` may be fine. If you attach that same semantic action
// to `eps`, you end up here, because `eps` has no attribute, and
// so `_attr(ctx)` produces a `none`.
BOOST_ASSERT(false);
BOOST_PARSER_DEBUG_ASSERT(false);
}
};
#endif
@@ -2492,7 +2492,7 @@ namespace boost { namespace parser {
// It looks like you've created a repeated epsilon parser, by
// writing "*eps", "+eps", "repeat(2, Inf)[eps]", or similar.
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
!detail::is_unconditional_eps<Parser>{} || end < Inf);
for (; count != end; ++count) {
@@ -2570,7 +2570,7 @@ namespace boost { namespace parser {
// It looks like you've created a repeated epsilon parser, by
// writing "*eps", "+eps", "repeat(2, Inf)[eps]", or similar.
BOOST_ASSERT(
BOOST_PARSER_DEBUG_ASSERT(
!detail::is_unconditional_eps<Parser>{} || end < Inf);
for (; count != end; ++count) {

View File

@@ -53,8 +53,8 @@ namespace boost { namespace parser {
template<typename T>
T & cast() const
{
BOOST_ASSERT(impl_);
BOOST_ASSERT(dynamic_cast<holder<T> *>(impl_.get()));
BOOST_PARSER_DEBUG_ASSERT(impl_);
BOOST_PARSER_DEBUG_ASSERT(dynamic_cast<holder<T> *>(impl_.get()));
return static_cast<holder<T> *>(impl_.get())->value_;
}

View File

@@ -1,123 +0,0 @@
// Copyright (C) 2020 T. Zachary Laine
//
// 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)
#ifndef BOOST_TEXT_CONFIG_HPP
#define BOOST_TEXT_CONFIG_HPP
#include <boost/config.hpp>
// Included for definition of __cpp_lib_concepts.
#include <iterator>
/** When you insert into a rope, the incoming sequence may be inserted as a
new segment, or if it falls within an existing string-segment, it may be
inserted into the string object used to represent that segment. This only
happens if the incoming sequence will fit within the existing segment's
capacity, or if the segment is smaller than a certain limit.
BOOST_TEXT_STRING_INSERT_MAX is that limit. */
#ifndef BOOST_TEXT_STRING_INSERT_MAX
# define BOOST_TEXT_STRING_INSERT_MAX 4096
#endif
#if defined(__cpp_lib_concepts) && !defined(BOOST_TEXT_DISABLE_CONCEPTS)
# define BOOST_TEXT_USE_CONCEPTS 1
#else
# define BOOST_TEXT_USE_CONCEPTS 0
#endif
#if defined(__cpp_coroutines) && !defined(BOOST_TEXT_DISABLE_COROUTINES)
# define BOOST_TEXT_USE_COROUTINES 1
#else
# define BOOST_TEXT_USE_COROUTINES 0
#endif
#ifndef BOOST_TEXT_DOXYGEN
// The inline namespaces v1 and v2 represent pre- and post-C++20. v1 is
// inline for standards before C++20, and v2 is inline for C++20 and later.
// Note that this only applies to code for which a v2 namespace alternative
// exists. Some instances of the v1 namespace may still be inline, if there
// is no v2 version of its contents.
#if BOOST_TEXT_USE_CONCEPTS
# define BOOST_TEXT_NAMESPACE_V1 namespace v1
# define BOOST_TEXT_NAMESPACE_V2 inline namespace v2
#else
# define BOOST_TEXT_NAMESPACE_V1 inline namespace v1
# define BOOST_TEXT_NAMESPACE_V2 namespace v2
#endif
// Nothing before GCC 6 has proper C++14 constexpr support.
#if defined(__GNUC__) && __GNUC__ < 6 && !defined(__clang__)
# define BOOST_TEXT_CXX14_CONSTEXPR
# define BOOST_TEXT_NO_CXX14_CONSTEXPR
#elif defined(_MSC_VER) && _MSC_VER <= 1916
# define BOOST_TEXT_CXX14_CONSTEXPR
# define BOOST_TEXT_NO_CXX14_CONSTEXPR
#else
# define BOOST_TEXT_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
# if defined(BOOST_NO_CXX14_CONSTEXPR)
# define BOOST_TEXT_NO_CXX14_CONSTEXPR
# endif
#endif
// Implements separate compilation features as described in
// http://www.boost.org/more/separate_compilation.html
// normalize macros
#if !defined(BOOST_TEXT_DYN_LINK) && !defined(BOOST_TEXT_STATIC_LINK) && \
!defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK)
# define BOOST_TEXT_STATIC_LINK
#endif
#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEXT_DYN_LINK)
# define BOOST_TEXT_DYN_LINK
#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_TEXT_STATIC_LINK)
# define BOOST_TEXT_STATIC_LINK
#endif
#if defined(BOOST_TEXT_DYN_LINK) && defined(BOOST_TEXT_STATIC_LINK)
# error Must not define both BOOST_TEXT_DYN_LINK and BOOST_TEXT_STATIC_LINK
#endif
// enable dynamic or static linking as requested
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEXT_DYN_LINK)
# if defined(BOOST_TEXT_SOURCE)
# define BOOST_TEXT_DECL BOOST_SYMBOL_EXPORT
# else
# define BOOST_TEXT_DECL BOOST_SYMBOL_IMPORT
# endif
#else
# define BOOST_TEXT_DECL
#endif
#if 0 // TODO: Disabled for now.
// enable automatic library variant selection
#if !defined(BOOST_TEXT_SOURCE) && !defined(BOOST_ALL_NO_LIB) && \
!defined(BOOST_TEXT_NO_LIB)
//
// Set the name of our library, this will get undef'ed by auto_link.hpp
// once it's done with it:
//
#define BOOST_LIB_NAME boost_text
//
// If we're importing code from a dll, then tell auto_link.hpp about it:
//
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TEXT_DYN_LINK)
# define BOOST_DYN_LINK
#endif
//
// And include the header that does the work:
//
#include <boost/config/auto_link.hpp>
#endif // auto-linking disabled
#endif
#endif // doxygen
#endif