Go to the documentation of this file.
4 #ifndef LEXY_DSL_ERROR_HPP_INCLUDED
5 #define LEXY_DSL_ERROR_HPP_INCLUDED
13 template <
typename Rule>
16 static constexpr
auto name =
"<error>";
18 static constexpr
auto rule = Rule{};
21 template <
typename Tag,
typename Rule>
24 template <
typename NextParser>
27 template <
typename Context,
typename Reader,
typename... Args>
30 auto begin = reader.position();
31 auto end = reader.position();
32 if constexpr (!std::is_same_v<Rule, void>)
34 auto backtrack = reader.current();
43 end = reader.position();
52 template <
typename Reader>
64 template <
typename Tag>
70 template <
typename Branch,
typename Error>
73 template <
typename NextParser>
76 template <
typename Context,
typename Reader,
typename... Args>
81 if (branch.try_parse(context.control_block, reader))
82 return branch.template finish<NextParser>(context, reader,
LEXY_FWD(args)...);
83 branch.cancel(context);
94 template <
typename Reader>
98 template <
typename Branch>
101 template <
typename Tag>
104 template <
typename Rule>
107 auto err = lexyd::error<Tag>(rule);
108 return _must<Branch, decltype(err)>{};
112 template <
typename Tag>
118 template <
typename Branch>
122 static_assert(!lexy::is_unconditional_branch_rule<Branch>);
127 #endif // LEXY_DSL_ERROR_HPP_INCLUDED
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&...)
typename BranchRule::template bp< Reader > branch_parser_for
constexpr auto error
Matches nothing, produces an error with the given tag.
constexpr auto end(const C &c) -> decltype(c.end())
#define LEXY_REQUIRE_BRANCH_RULE(Rule, Name)
constexpr auto operator()(Rule rule) const
lexy::branch_parser_for< Branch, Reader > bp
A branch parser that takes a branch unconditionally and forwards to the regular parser.
static constexpr auto rule
static constexpr auto max_recursion_depth
constexpr auto operator()(R) const
Adds a rule whose match will be part of the error location.
constexpr auto begin(const C &c) -> decltype(c.begin())
static constexpr _err< Tag > error
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
static constexpr auto name
typename Rule::template p< NextParser > parser_for
constexpr auto do_action(Handler &&handler, State *state, Reader &reader)
#define LEXY_ASSERT(Expr, Msg)
constexpr auto must(Branch)