Go to the documentation of this file.
4 #ifndef LEXY_ACTION_PARSE_AS_TREE_HPP_INCLUDED
5 #define LEXY_ACTION_PARSE_AS_TREE_HPP_INCLUDED
14 template <
typename Tree,
typename Reader>
18 template <
typename Input,
typename Sink>
41 auto begin = reader.position();
43 auto end = reader.position();
51 handler.
_tree->clear();
66 if (handler.
_builder->current_child_count() == 0)
93 return handler.
_builder->start_container();
95 template <
typename Operation>
100 handler.
_builder->set_container_production(
op);
102 template <
typename Marker>
109 template <
typename TokenKind>
115 template <
typename Error>
121 template <
typename Event,
typename... Args>
122 auto on(
_pth& handler, Event ev, Args&&... args)
132 template <
typename Production,
typename State>
135 template <
typename T>
150 template <
typename State,
typename Input,
typename ErrorCallback,
typename TokenKind =
void,
151 typename MemoryResource =
void>
170 template <
typename U = State>
176 template <
typename Production>
181 auto reader =
input.reader();
182 return lexy::do_action<Production, result_type>(
handler(*
_tree, input_holder, sink),
_state,
187 template <
typename Production,
typename TokenKind,
typename MemoryResource,
typename Input,
188 typename ErrorCallback>
190 const Input& input,
const ErrorCallback&
callback)
194 MemoryResource>(tree,
callback)(Production{}, input);
196 template <
typename Production,
typename TokenKind,
typename MemoryResource,
typename Input,
197 typename State,
typename ErrorCallback>
199 const Input& input, State& state,
const ErrorCallback&
callback)
203 MemoryResource>(state, tree,
callback)(Production{}, input);
205 template <
typename Production,
typename TokenKind,
typename MemoryResource,
typename Input,
206 typename State,
typename ErrorCallback>
208 const Input& input,
const State& state,
const ErrorCallback&
callback)
212 MemoryResource>(state, tree,
callback)(Production{}, input);
216 #endif // LEXY_ACTION_PARSE_AS_TREE_HPP_INCLUDED
constexpr parse_as_tree_action(tree_type &tree, const ErrorCallback &callback)
void on(_pth &handler, parse_events::grammar_cancel, Reader &)
lexy::_detail::lazy_init< typename Tree::builder > _builder
void on(_pth &handler, parse_events::production_cancel ev, iterator pos)
auto on(_pth &handler, Event ev, Args &&... args)
void on(_pth &handler, parse_events::grammar_finish, Reader &reader)
constexpr auto operator()(Production, const Input &input) const
void on(_pth &handler, parse_events::error ev, Error &&error)
#define LEXY_PRECONDITION(Expr)
void on(_pth &handler, parse_events::token, TokenKind kind, iterator begin, iterator end)
constexpr parse_as_tree_action(U &state, tree_type &tree, const ErrorCallback &callback)
constexpr auto end(const C &c) -> decltype(c.end())
constexpr auto callback(Fns &&... fns)
Creates a callback.
constexpr auto _get_error_sink(const Callback &callback)
constexpr T & emplace(Args &&... args)
constexpr LEXY_FORCE_INLINE auto try_match_token(TokenRule, Reader &reader)
Tree::builder::marker _marker
typename Reader::iterator iterator
auto parse_as_tree(parse_tree< lexy::input_reader< Input >, TokenKind, MemoryResource > &tree, const Input &input, const ErrorCallback &callback) -> validate_result< ErrorCallback >
void on(_pth &handler, parse_events::production_start ev, iterator pos)
typename LEXY_DECAY_DECLTYPE(Operator)::op_tag_type op
constexpr auto begin(const C &c) -> decltype(c.begin())
event_handler(production_info info)
constexpr auto get_result(bool rule_parse_result) &&
void on(_pth &handler, lexy::parse_events::operation_chain_finish, Marker &&marker, iterator)
void on(_pth &handler, parse_events::grammar_start, iterator)
void on(_pth &handler, parse_events::production_finish ev, iterator pos)
_pth(Tree &tree, const _detail::any_holder< const Input * > &input, _detail::any_holder< Sink > &sink)
_pth< tree_type, lexy::input_reader< Input > > handler
_vh< Reader >::event_handler _validate
const ErrorCallback * _callback
constexpr auto any
Matches anything and consumes all remaining characters.
decltype(LEXY_DECLVAL(Input).reader()) input_reader
void on(_pth &handler, lexy::parse_events::operation_chain_op, Operation op, iterator)
auto on(_pth &handler, lexy::parse_events::operation_chain_start, iterator)