| 214 | typename ErrorHandler, |
| 215 | typename SkipParser> |
| 216 | auto attr_search_impl( |
| 217 | R && r, |
| 218 | parser_interface<Parser, GlobalState, ErrorHandler> const & parser, |
| 219 | parser_interface<SkipParser> const & skip, |
| 220 | trace trace_mode) |
| 221 | { |
| 222 | auto first = text::detail::begin(r); |
| 223 | auto const last = text::detail::end(r); |
| 224 | |
| 225 | auto match_first = first; |
| 226 | auto match_last = first; |
| 227 | auto before = [&match_first](auto & ctx) { |
| 228 | match_first = _where(ctx).begin(); |
| 229 | }; |
| 230 | auto after = [&match_last](auto & ctx) { |
| 231 | match_last = _where(ctx).begin(); |
| 232 | }; |
| 233 | |
| 234 | auto const search_parser = |
| 235 | omit[*(char_ - parser)] >> |
| 236 | -lexeme[eps[before] >> parser::skip[parser] >> eps[after]]; |
| 237 | |
| 238 | using parse_result_outer = decltype(parser::prefix_parse( |
| 239 | first, last, search_parser, trace_mode)); |
| 240 | |
| 241 | static_assert( |
| 242 | !std::is_same_v<parse_result_outer, bool>, |
| 243 | "If you're seeing this error, you passed a parser to " |
| 244 | "transform_replace() that has no attribute. Please fix."); |
| 245 | |
| 246 | using parse_result = |
| 247 | remove_cv_ref_t<decltype(**std::declval<parse_result_outer>())>; |
| 248 | |
| 249 | using return_tuple = tuple< |
| 250 | decltype(BOOST_PARSER_SUBRANGE(first, first)), |
| 251 | parse_result>; |
| 252 | |
| 253 | if (first == last) { |
| 254 | return return_tuple( |
| 255 | BOOST_PARSER_SUBRANGE(first, first), parse_result{}); |
| 256 | } |
| 257 | |
| 258 | if constexpr (std::is_same_v<SkipParser, eps_parser<phony>>) { |
| 259 | auto result = parser::prefix_parse( |
| 260 | first, last, search_parser, trace_mode); |
| 261 | if (*result) { |
| 262 | return return_tuple( |
| 263 | BOOST_PARSER_SUBRANGE(match_first, match_last), |
| 264 | std::move(**result)); |
| 265 | } |
| 266 | } else { |
| 267 | auto result = parser::prefix_parse( |
| 268 | first, last, search_parser, skip, trace_mode); |
| 269 | if (*result) { |
| 270 | return return_tuple( |
| 271 | BOOST_PARSER_SUBRANGE(match_first, match_last), |
| 272 | std::move(**result)); |
| 273 | } |
no test coverage detected