Go to the documentation of this file.
4 #ifndef LEXY_ACTION_VALIDATE_HPP_INCLUDED
5 #define LEXY_ACTION_VALIDATE_HPP_INCLUDED
18 template <
typename Callback>
21 if constexpr (std::is_same_v<Callback, lexy::_noop>)
26 else if constexpr (lexy::is_sink<Callback>)
34 std::is_void_v<typename Callback::return_type>,
35 "need to use `lexy::collect()` to create an error callback that can handle multiple errors");
41 template <
typename Callback>
44 template <
typename ErrorCallback>
52 static_assert(!std::is_void_v<error_type>,
"ErrorCallback must not be a void returning sink");
54 constexpr
explicit operator bool() const noexcept
78 if constexpr (std::is_same_v<error_type, std::size_t>)
86 constexpr
const auto&
errors() const& noexcept
90 constexpr
auto&&
errors() && noexcept
101 else if (did_recover)
115 template <
typename Reader>
122 template <
typename Reader>
135 typename Reader::iterator
begin,
138 template <
typename Input,
typename Sink>
153 typename Reader::iterator
begin,
const error<Reader, expected_keyword>& error) {
158 typename Reader::iterator
begin,
159 const error<Reader, expected_char_class>& error) {
166 template <
typename Reader>
170 template <
typename Input,
typename Sink>
199 template <
typename R,
typename Tag>
204 template <
typename R>
209 template <
typename R>
215 template <
typename R>
221 template <
typename R>
228 template <
typename Event,
typename... Args>
229 constexpr
auto on(
_vh&, Event,
const Args&...)
242 while (cur->_info.is_transparent && cur->_prev !=
nullptr)
253 template <
typename Production,
typename State>
256 template <
typename Result>
260 return Result(rule_parse_result,
LEXY_MOV(
_cb.sink->template get<sink_t>()).finish());
268 template <
typename State,
typename Input,
typename ErrorCallback>
282 template <
typename U = State>
287 template <
typename Production>
292 auto reader =
input.reader();
293 return lexy::do_action<Production, result_type>(
handler(input_holder, sink),
_state,
298 template <
typename Production,
typename Input,
typename ErrorCallback>
305 template <
typename Production,
typename Input,
typename State,
typename ErrorCallback>
311 template <
typename Production,
typename Input,
typename State,
typename ErrorCallback>
312 constexpr
auto validate(
const Input& input,
const State& state,
const ErrorCallback&
callback)
319 #endif // LEXY_ACTION_VALIDATE_HPP_INCLUDED
ErrorCallback error_callback
enum lexy::validate_result::@4 _status
constexpr _validate_callbacks(const _detail::any_holder< const Input * > &input, _detail::any_holder< Sink > &sink)
_error_sink_t< ErrorCallback > _sink_t
constexpr auto collect(Callback &&callback)
void(* keyword)(_detail::any_ref sink, production_info info, _detail::any_cref input, typename Reader::iterator begin, const error< Reader, expected_keyword > &error)
constexpr auto on(_vh &, Event, const Args &...)
constexpr event_handler(production_info info)
Contains information about the context of an error, production is type-erased.
constexpr production_info get_info() const
decltype(_get_error_sink(LEXY_DECLVAL(Callback))) _error_sink_t
constexpr bool is_fatal_error() const noexcept
_vh< lexy::input_reader< Input > > handler
const any_base * any_cref
constexpr auto callback(Fns &&... fns)
Creates a callback.
constexpr std::size_t error_count() const noexcept
constexpr iterator production_begin() const
constexpr void on(_vh &handler, parse_events::error, const error< R, expected_keyword > &error)
constexpr auto _get_error_sink(const Callback &callback)
Type erased generic failure.
constexpr auto get_result(bool rule_parse_result) &&
constexpr _vh(const _detail::any_holder< const Input * > &input, _detail::any_holder< Sink > &sink)
constexpr validate_action(U &state, const ErrorCallback &callback)
constexpr bool is_success() const noexcept
constexpr void on(_vh &handler, parse_events::error, const error< R, expected_literal > &error)
constexpr const auto & errors() const &noexcept
constexpr validate_action(const ErrorCallback &callback)
constexpr void on(_vh &handler, parse_events::error, const error< R, Tag > &error)
constexpr void on(_vh &handler, parse_events::production_finish, iterator)
constexpr void on(_vh &handler, parse_events::error, const error< R, void > &error)
constexpr auto validate(const Input &input, const ErrorCallback &callback) -> validate_result< ErrorCallback >
constexpr auto begin(const C &c) -> decltype(c.begin())
constexpr bool is_error() const noexcept
constexpr validate_result(bool did_recover, error_type &&error)
constexpr void on(_vh &handler, parse_events::production_cancel, iterator)
const ErrorCallback * _callback
void(* literal)(_detail::any_ref sink, production_info info, _detail::any_cref input, typename Reader::iterator begin, const error< Reader, expected_literal > &error)
constexpr void on(_vh &handler, parse_events::error, const error< R, expected_char_class > &error)
constexpr bool is_recovered_error() const noexcept
constexpr void on(_vh &handler, parse_events::production_start, iterator pos)
Expected< std::monostate > Result
typename Reader::iterator iterator
void(* generic)(_detail::any_ref sink, production_info info, _detail::any_cref input, typename Reader::iterator begin, const error< Reader, void > &error)
void(* char_class)(_detail::any_ref sink, production_info info, _detail::any_cref input, typename Reader::iterator begin, const error< Reader, expected_char_class > &error)
#define LEXY_DECLVAL(...)
typename _sink_t::return_type error_type
constexpr auto operator()(Production, const Input &input) const
constexpr auto && errors() &&noexcept
_validate_callbacks< Reader > _cb