diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 833b484f..aabb023d 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -24,6 +24,7 @@ doxygen parser_reference # note that there is no detail::unspecified -- this is a hack to get all # the SFINAE code out of the API docs. "PREDEFINED=\"BOOST_PARSER_DOXYGEN=1\" \\ + \"BOOST_PARSER_USE_CONCEPTS=1\" \\ \"enable_if=detail::unspecified\"" HIDE_UNDOC_MEMBERS=NO EXTRACT_PRIVATE=NO diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index cf1ce665..eb5444e8 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -2648,9 +2648,10 @@ namespace boost { namespace parser { }; } +#ifndef BOOST_PARSER_DOXYGEN // This constraint is only here to allow the alternate-call semantic - // action metaprogramming logic function on MSVC. + // action metaprogramming logic to function on MSVC. template auto _val(Context const & context) -> std::conditional_t< detail::is_nope_v, @@ -2773,6 +2774,8 @@ namespace boost { namespace parser { diagnostic_kind::warning, message, context); } +#endif + /** An invocable that returns the `I`th parameter to the bottommost rule. This is useful for forwarding parameters to sub-rules. */ template @@ -6038,7 +6041,9 @@ namespace boost { namespace parser { } /** Returns a `parser_interface` containing a `char_parser` that - matches `x`. */ + matches `x`. + + \tparam T Constrained by `!parsable_range_like`. */ #if BOOST_PARSER_USE_CONCEPTS template // clang-format off @@ -6111,7 +6116,10 @@ namespace boost { namespace parser { matches one of the values in `r`. `r` must be a sorted, random-access sequence of `char32_t`. The character begin matched is directly compared to the elements of `r`. The match is found - via binary search. No case folding is performed. */ + via binary search. No case folding is performed. + + \tparam R Additionally constrained by + `std::same_as, char32_t>`. */ // clang-format off #if BOOST_PARSER_USE_CONCEPTS template @@ -7648,7 +7656,10 @@ namespace boost { namespace parser { /** Parses `[first, last)` using `parser`, and returns whether the parse was successful. On success, `attr` will be assigned the value of the attribute produced by `parser`. If `trace_mode == trace::on`, a - verbose trace of the parse will be streamed to `std::cout`. */ + verbose trace of the parse will be streamed to `std::cout`. + + \tparam Attr Constrained by + `!detail::derived_from_parser_interface_v`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_iter I, @@ -7724,7 +7735,15 @@ namespace boost { namespace parser { to be considered successful. On success, `attr` will be assigned the value of the attribute produced by `parser`. If `trace_mode == trace::on`, a verbose trace of the parse will be streamed to - `std::cout`. */ + `std::cout`. + + \tparam ErrorHandler Constrained by `error_handler, std::ranges::sentinel_t, GlobalState>`, + where `subrange_of` is an implementation detail that: creates + subranges out of pointers; trims trailing zeros off of bounded + arrays (such as string literals); and transcodes to UTF-32 if the + input is non-`char`. + \tparam Attr Constrained by + `!detail::derived_from_parser_interface_v`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_range_like R, @@ -7755,7 +7774,7 @@ namespace boost { namespace parser { ErrorHandler, std::ranges::iterator_t, std::ranges::sentinel_t, - GlobalState> && + GlobalState> && (!detail::derived_from_parser_interface_v>) // clang-format on #endif @@ -7773,7 +7792,10 @@ namespace boost { namespace parser { /** Parses `[first, last)` using `parser`. Returns a `std::optional` containing the attribute produced by `parser` on parse success, and `std::nullopt` on parse failure. If `trace_mode == trace::on`, a - verbose trace of the parse will be streamed to `std::cout`. */ + verbose trace of the parse will be streamed to `std::cout`. + + \tparam Attr Constrained by + `!detail::derived_from_parser_interface_v`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_iter I, @@ -7826,7 +7848,15 @@ namespace boost { namespace parser { attribute produced by `parser` on parse success, and `std::nullopt` on parse failure. The entire input range `r` must be consumed for the parse to be considered successful. If `trace_mode == trace::on`, a - verbose trace of the parse will be streamed to `std::cout`. */ + verbose trace of the parse will be streamed to `std::cout`. + + \tparam ErrorHandler Constrained by `error_handler, std::ranges::sentinel_t, GlobalState>`, + where `subrange_of` is an implementation detail that: creates + subranges out of pointers; trims trailing zeros off of bounded + arrays (such as string literals); and transcodes to UTF-32 if the + input is non-`char`. + \tparam Attr Constrained by + `!detail::derived_from_parser_interface_v`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_range_like R, @@ -7949,7 +7979,13 @@ namespace boost { namespace parser { the parse to be considered successful. On success, `attr` will be assigned the value of the attribute produced by `parser`. If `trace_mode == trace::on`, a verbose trace of the parse will be - streamed to `std::cout`. */ + streamed to `std::cout`. + + \tparam ErrorHandler Constrained by `error_handler, std::ranges::sentinel_t, GlobalState>`, + where `subrange_of` is an implementation detail that: creates + subranges out of pointers; trims trailing zeros off of bounded + arrays (such as string literals); and transcodes to UTF-32 if the + input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_range_like R, @@ -8058,7 +8094,13 @@ namespace boost { namespace parser { `std::nullopt` on parse failure. The entire input range `r` must be consumed for the parse to be considered successful. If `trace_mode == trace::on`, a verbose trace of the parse will be streamed to - `std::cout`. */ + `std::cout`. + + \tparam ErrorHandler Constrained by `error_handler, std::ranges::sentinel_t, GlobalState>`, + where `subrange_of` is an implementation detail that: creates + subranges out of pointers; trims trailing zeros off of bounded + arrays (such as string literals); and transcodes to UTF-32 if the + input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_range_like R, @@ -8170,7 +8212,13 @@ namespace boost { namespace parser { `Callbacks` is expected to be an invocable with the correct overloads required to support all successful rule parses that might occur. If `trace_mode == trace::on`, a verbose trace of the parse will be - streamed to `std::cout`. */ + streamed to `std::cout`. + + \tparam ErrorHandler Constrained by `error_handler, std::ranges::sentinel_t, GlobalState>`, + where `subrange_of` is an implementation detail that: creates + subranges out of pointers; trims trailing zeros off of bounded + arrays (such as string literals); and transcodes to UTF-32 if the + input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_range_like R, @@ -8297,7 +8345,13 @@ namespace boost { namespace parser { `Callbacks` is expected to be an invocable with the correct overloads required to support all successful rule parses that might occur. If `trace_mode == trace::on`, a verbose trace of the parse will be - streamed to `std::cout`. */ + streamed to `std::cout`. + + \tparam ErrorHandler Constrained by `error_handler, std::ranges::sentinel_t, GlobalState>`, + where `subrange_of` is an implementation detail that: creates + subranges out of pointers; trims trailing zeros off of bounded + arrays (such as string literals); and transcodes to UTF-32 if the + input is non-`char`. */ #if BOOST_PARSER_USE_CONCEPTS template< parsable_range_like R, diff --git a/include/boost/parser/parser_fwd.hpp b/include/boost/parser/parser_fwd.hpp index 34da6fb6..d8a0e276 100644 --- a/include/boost/parser/parser_fwd.hpp +++ b/include/boost/parser/parser_fwd.hpp @@ -495,9 +495,13 @@ namespace boost { namespace parser { /** Report that the error described in `message` occurred at `location`, using the context's error handler. */ - template +#if BOOST_PARSER_USE_CONCEPTS + template +#else + template +#endif void _report_error( - Context const & context, std::string_view message, Iter location); + Context const & context, std::string_view message, I location); /** Report that the error described in `message` occurred at `_where(context).begin()`, using the context's error handler. */ @@ -506,9 +510,13 @@ namespace boost { namespace parser { /** Report that the warning described in `message` occurred at `location`, using the context's error handler. */ - template +#if BOOST_PARSER_USE_CONCEPTS + template +#else + template +#endif void _report_warning( - Context const & context, std::string_view message, Iter location); + Context const & context, std::string_view message, I location); /** Report that the warning described in `message` occurred at `_where(context).begin()`, using the context's error handler. */ diff --git a/include/boost/parser/replace.hpp b/include/boost/parser/replace.hpp index 0aa0ea8f..eb38f876 100644 --- a/include/boost/parser/replace.hpp +++ b/include/boost/parser/replace.hpp @@ -193,7 +193,12 @@ namespace boost::parser { /** Produces a range of subranges of a given range `base`. Each subrange is either a subrange of `base` that does not match the given parser - `parser`, or is the given replacement for a match, `replacement`. */ + `parser`, or is the given replacement for a match, `replacement`. + + In addition to the template parameter constraints, `V` and + `ReplacementV` must be ranges of `char`, or must have the same UTF + format, and `V` and `ReplacementV` must meet the same compatibility + requirements as described in `std::ranges::join_view`. */ template< #if BOOST_PARSER_USE_CONCEPTS std::ranges::viewable_range V, diff --git a/include/boost/parser/search.hpp b/include/boost/parser/search.hpp index aab10373..4b9170fb 100644 --- a/include/boost/parser/search.hpp +++ b/include/boost/parser/search.hpp @@ -289,7 +289,7 @@ namespace boost::parser { /** Produces a sequence of subranges of the underlying sequence of type `V`. Each subrange is a nonoverlapping match of the given parser, - using a skip-parser if provided. */ + using a skip-parser if provided. */ template< #if BOOST_PARSER_USE_CONCEPTS std::ranges::viewable_range V, diff --git a/include/boost/parser/split.hpp b/include/boost/parser/split.hpp index 205858cc..7159c711 100644 --- a/include/boost/parser/split.hpp +++ b/include/boost/parser/split.hpp @@ -8,7 +8,7 @@ namespace boost::parser { /** Produces a sequence of subranges of the underlying sequence of type `V`. the underlying sequence is split into subranges delimited by - matches of the given parser, possibly using a given skip-parser. */ + matches of the given parser, possibly using a given skip-parser. */ template< #if BOOST_PARSER_USE_CONCEPTS std::ranges::viewable_range V, diff --git a/include/boost/parser/transcode_view.hpp b/include/boost/parser/transcode_view.hpp index 369e62ba..2a43b1f2 100644 --- a/include/boost/parser/transcode_view.hpp +++ b/include/boost/parser/transcode_view.hpp @@ -24,7 +24,11 @@ namespace boost::parser { #else - /** A view that produces UTF-8 from an given sequence of UTF. */ + /** A view that produces UTF-8 from an given sequence of UTF. + + \tparam V Constrained by `std::ranges::view`. Additionally, the + value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or + `char32_t`. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) template requires std::ranges::view @@ -44,7 +48,11 @@ namespace boost::parser { {} }; - /** A view that produces UTF-16 from an given sequence of UTF. */ + /** A view that produces UTF-16 from an given sequence of UTF. + + \tparam V Constrained by `std::ranges::view`. Additionally, the + value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or + `char32_t`. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) template requires std::ranges::view @@ -64,7 +72,11 @@ namespace boost::parser { {} }; - /** A view that produces UTF-32 from an given sequence of UTF. */ + /** A view that produces UTF-32 from an given sequence of UTF. + + \tparam V Constrained by `std::ranges::view`. Additionally, the + value type of `V` must be `char`, `wchar_t`, `char8_t`, `char16_t`, or + `char32_t`. */ #if BOOST_PARSER_DETAIL_TEXT_USE_CONCEPTS || defined(BOOST_PARSER_DOXYGEN) template requires std::ranges::view diff --git a/include/boost/parser/transform_replace.hpp b/include/boost/parser/transform_replace.hpp index 3443521f..b146c64d 100644 --- a/include/boost/parser/transform_replace.hpp +++ b/include/boost/parser/transform_replace.hpp @@ -316,7 +316,13 @@ namespace boost::parser { /** Produces a range of subranges of a given range `base`. Each subrange is either a subrange of `base` that does not match the given parser `parser`, or is `f(*boost::parser::parse(match, parser))`, where `f` - is the given invocable and `match` is the matching subrange. */ + is the given invocable and `match` is the matching subrange. + + In addition to the template parameter constraints, `F` must be + invocable with the attribute type of `Parser`; `V` and the range type + produced by `F`, "`Rf`" must be ranges of `char`, or must have the + same UTF format; and `V` and `Rf` must meet the same compatibility + requirements as described in `std::ranges::join_view`. */ template< #if BOOST_PARSER_USE_CONCEPTS std::ranges::viewable_range V,