Go to the documentation of this file.
4 #ifndef LEXY_ACTION_BASE_HPP_INCLUDED
5 #define LEXY_ACTION_BASE_HPP_INCLUDED
26 template <
typename Context>
27 constexpr
void link(Context& context)
29 auto cb = context.control_block;
34 template <
typename Context>
35 constexpr
void unlink(Context& context)
37 auto cb = context.control_block;
42 template <
typename Id,
typename T>
45 static constexpr
auto type_id = lexy::_detail::type_id<Id>();
53 template <
typename ControlBlock>
54 static constexpr T&
get(
const ControlBlock* cb)
56 for (
auto cur = cb->vars; cur; cur = cur->next)
60 LEXY_ASSERT(
false,
"context variable hasn't been created");
65 template <
typename Handler,
typename State =
void>
86 template <
typename OtherHandler>
94 template <
typename OtherHandler>
107 template <
typename Production>
109 = std::conditional_t<_production_defines_whitespace<Production>, Production,
void>;
111 template <
typename Handler,
typename State,
typename Production>
113 typename Handler::template value_callback<Production, State>::return_type;
115 template <
typename Handler,
typename State,
typename Production,
134 template <
typename ChildProduction>
140 using new_whitespace_production
141 = std::conditional_t<is_token_production<ChildProduction>
142 || _production_defines_whitespace<ChildProduction>,
149 using callback =
typename Handler::template value_callback<Production, State>;
153 template <
typename Event,
typename... Args>
154 constexpr
auto on(Event ev, Args&&... args)
166 template <
typename Context,
typename Reader,
typename... Args>
169 context.value.emplace_result(context.value_callback(),
LEXY_FWD(args)...);
174 template <
typename NextParser>
177 template <
typename Context,
typename Reader,
typename SubContext,
typename... Args>
183 = std::conditional_t<lexy::is_token_production<typename SubContext::production>,
187 if constexpr (std::is_void_v<typename SubContext::value_type>)
200 template <
typename Handler,
typename State,
typename Production,
typename Reader>
226 template <
typename Production,
template <
typename>
typename Result,
typename Handler,
227 typename State,
typename Reader>
228 constexpr
auto do_action(Handler&& handler, State* state, Reader& reader)
230 static_assert(!std::is_reference_v<Handler>,
"need to move handler in");
233 max_recursion_depth<Production>());
236 auto rule_result =
_do_action(context, reader);
238 using value_type =
typename decltype(context)::value_type;
239 if constexpr (std::is_void_v<value_type>)
241 else if (context.
value)
243 .template get_result<Result<value_type>>(rule_result,
LEXY_MOV(*context.
value));
246 .template get_result<Result<value_type>>(rule_result);
256 template <
typename State>
267 template <
typename... Args>
273 #endif // LEXY_ACTION_BASE_HPP_INCLUDED
constexpr void copy_vars_from(parse_context_control_block< OtherHandler, State > *cb)
constexpr auto noop
A callback with sink that does nothing.
constexpr parse_context_var(T &&value)
static constexpr T & get(const ControlBlock *cb)
constexpr void * no_parse_state
constexpr parse_context_control_block(Handler &&handler, State *state, std::size_t max_depth)
parse_context_var_base * next
std::conditional_t< _production_defines_whitespace< Production >, Production, void > _whitespace_production_of
_detail::parse_context_control_block< Handler, State > * control_block
constexpr auto sub_context(ChildProduction)
constexpr void_value_callback(State *)
_whitespace_production_of< lexy::_scp > whitespace_production
constexpr auto callback(Fns &&... fns)
Creates a callback.
constexpr auto parse(const Input &input, const ErrorCallback &callback)
Parses the production into a value, invoking the callback on error.
constexpr auto value_callback()
bool enable_whitespace_skipping
_production_value_type< lexy::_vh, State, lexy::_scp > value_type
constexpr void operator()(Args &&...) const
constexpr auto sink() const
constexpr void link(Context &context)
#define LEXY_DECAY_DECLTYPE(...)
typename Handler::template value_callback< Production, State >::return_type _production_value_type
constexpr parse_context_var_base(const void *id)
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &, Args &&... args)
parse_context_var_base * vars
constexpr _pc(_detail::parse_context_control_block< Handler, State > *cb)
LEXY_EMPTY_MEMBER Handler parse_handler
constexpr auto on(Event ev, Args &&... args)
Handler::event_handler handler
static constexpr auto type_id
typename Rule::template p< NextParser > parser_for
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, SubContext &sub_context, Args &&... args)
Expected< std::monostate > Result
constexpr void_value_callback()=default
constexpr parse_context_control_block(Handler &&handler, parse_context_control_block< OtherHandler, State > *cb)
#define LEXY_EMPTY_MEMBER
constexpr auto _do_action(_pc< Handler, State, Production > &context, Reader &reader)
_detail::lazy_init< value_type > value
constexpr void unlink(Context &context)
constexpr auto do_action(Handler &&handler, State *state, Reader &reader)
#define LEXY_ASSERT(Expr, Msg)