Go to the documentation of this file.
4 #ifndef LEXY_DSL_BRANCH_HPP_INCLUDED
5 #define LEXY_DSL_BRANCH_HPP_INCLUDED
12 template <
typename Condition,
typename... R>
15 static_assert(
sizeof...(R) >= 0);
17 template <
typename NextParser>
22 template <
typename Reader>
25 template <
typename NextParser>
31 template <
typename Condition,
typename Then>
37 template <
typename Condition,
typename... R>
41 return _br<Condition, R...>{};
43 template <
typename Condition,
typename C,
typename... R>
47 return _br<Condition, C, R...>{};
51 template <
typename C,
typename... R,
typename Then>
54 return C{} >>
_seq<R..., Then>{};
56 template <
typename C,
typename... R,
typename... S>
59 return C{} >>
_seq<R..., S...>{};
63 template <
typename C1,
typename... R,
typename C2,
typename... S>
66 return _br<C1, R..., C2, S...>{};
71 template <
typename Rule,
typename Condition,
typename... R>
74 return rule +
_seq<Condition, R...>{};
77 template <
typename... R,
typename Condition,
typename... S>
80 return _seq<R...>{} +
_seq<Condition, S...>{};
84 template <
typename Condition,
typename... R,
typename Rule>
87 return _br<Condition, R..., Rule>{};
90 template <
typename Condition,
typename... R,
typename... S>
93 return _br<Condition, R..., S...>{};
97 template <
typename C1,
typename... R,
typename C2,
typename... S>
100 return _br<C1, R..., C2, S...>{};
103 template <
typename Condition,
typename Then>
106 if constexpr (lexy::is_branch_rule<Condition>)
107 return condition >> then;
109 return condition + then;
117 template <
typename NextParser>
118 using p = NextParser;
120 template <
typename Reader>
125 template <
typename R>
128 return _else{} >> rule;
130 template <
typename... R>
133 return _else{} >> rule;
135 template <
typename C,
typename... R>
138 return _else{} >> rule;
146 #endif // LEXY_DSL_BRANCH_HPP_INCLUDED
constexpr friend auto operator>>(_else_dsl, _seq< R... > rule)
constexpr auto _maybe_branch(Condition condition, Then then)
#define LEXY_REQUIRE_BRANCH_RULE(Rule, Name)
A branch parser that takes a branch unconditionally and forwards to the regular parser.
constexpr auto operator>>(Condition, Then)
Parses Then only after Condition has matched.
constexpr auto else_
Takes the branch unconditionally.
constexpr friend auto operator>>(_else_dsl, R rule)
A branch parser that parses a branch rule but with a special continuation.
typename Rule::template p< NextParser > parser_for
constexpr friend auto operator>>(_else_dsl, _br< C, R... > rule)
constexpr auto operator+(Rule rule, _br< Condition, R... >)
lexy::parser_for< _seq_impl< R... >, NextParser > _pc
lexy::parser_for< _seq_impl< Condition, R... >, NextParser > p
decltype(_copy_base_impl< Rule >()) _copy_base