4 #ifndef LEXY_DSL_BASE_HPP_INCLUDED
5 #define LEXY_DSL_BASE_HPP_INCLUDED
93 template <
typename Rule>
96 if constexpr (lexy::is_unconditional_branch_rule<Rule>)
98 else if constexpr (lexy::is_branch_rule<Rule>)
103 template <
typename Rule>
108 #define LEXY_PARSER_FUNC LEXY_FORCE_INLINE constexpr
112 template <
typename Rule,
typename NextParser>
115 template <
typename BranchRule,
typename Reader>
118 template <
typename Production,
typename Reader>
122 template <
typename Production,
typename Reader>
126 template <
typename Rule,
typename Reader>
129 constexpr std::true_type
try_parse(
const void*,
const Reader&)
134 template <
typename Context>
138 template <
typename NextParser,
typename Context,
typename... Args>
146 template <
typename BranchRule,
typename Reader,
template <
typename>
typename Continuation>
151 template <
typename ControlBlock>
152 constexpr
auto try_parse(
const ControlBlock* cb,
const Reader& reader)
154 return impl.try_parse(cb, reader);
157 template <
typename Context>
160 impl.cancel(context);
163 template <
typename NextParser,
typename Context,
typename... Args>
166 return impl.template finish<Continuation<NextParser>>(context, reader,
LEXY_FWD(args)...);
171 template <
typename... PrevArgs>
174 template <
typename Context,
typename Reader,
typename... Args>
179 static_assert(
sizeof...(Args) == 0,
"pattern rule must not produce any values");
187 template <
typename Context,
typename Reader,
typename Sink,
typename... Args>
190 if constexpr (
sizeof...(Args) > 0)
198 template <
typename NextParser>
201 template <
typename Context,
typename Reader,
typename Sink,
typename... Args>
204 if constexpr (std::is_same_v<typename Sink::return_type, void>)
220 template <
typename NextParser>
226 template <
typename Context,
typename NextParser,
228 typename Context::whitespace_production>>
233 template <
typename Context,
typename NextParser>
241 template <
typename TokenRule,
typename Reader>
244 template <
typename TokenRule,
typename Reader>
249 using try_parse_result = decltype(parser.try_parse(reader));
250 if constexpr (std::is_same_v<try_parse_result, std::true_type>)
252 parser.try_parse(reader);
253 reader.reset(parser.end);
254 return std::true_type{};
256 else if constexpr (std::is_same_v<try_parse_result, std::false_type>)
259 return std::false_type{};
263 if (!parser.try_parse(reader))
266 reader.reset(parser.end);
272 #endif // LEXY_DSL_BASE_HPP_INCLUDED