4 #ifndef LEXY_DSL_PRODUCTION_HPP_INCLUDED
5 #define LEXY_DSL_PRODUCTION_HPP_INCLUDED
15 template <
typename Production>
21 template <
typename Production,
typename Context,
typename Reader>
27 template <
typename ProductionParser,
typename Context,
typename Reader>
31 return parser.template finish<lexy::_detail::final_parser>(context, reader);
34 template <
typename Production>
37 : std::conditional_t<lexy::_production_defines_whitespace<Production>, rule_base,
38 _copy_base<lexy::production_rule<Production>>>
40 template <
typename NextParser>
43 template <
typename Context,
typename Reader,
typename... Args>
47 auto sub_context = context.sub_context(Production{});
51 if constexpr (lexy::_production_defines_whitespace<Production>)
61 if (_parse_production<Production>(sub_context, reader))
77 template <
typename Reader>
81 typename Reader::iterator
begin;
83 template <
typename ControlBlock>
84 constexpr
auto try_parse(
const ControlBlock* cb,
const Reader& reader)
86 begin = reader.position();
87 return parser.try_parse(cb, reader);
90 template <
typename Context>
91 constexpr
void cancel(Context& context)
94 auto sub_context = context.sub_context(Production{});
96 parser.cancel(sub_context);
100 template <
typename NextParser,
typename Context,
typename... Args>
103 static_assert(!lexy::_production_defines_whitespace<Production>);
106 auto sub_context = context.sub_context(Production{});
126 template <
typename Production>
136 return "maximum recursion depth exceeded";
143 template <
typename Production,
typename DepthError =
void>
146 template <
typename NextParser>
149 template <
typename Context,
typename Reader>
152 auto control_block = context.control_block;
154 "dsl::recurse_branch<P> is disabled in this context");
157 if (control_block->cur_depth >= control_block->max_depth)
166 ++control_block->cur_depth;
170 template <
typename Context,
typename Reader,
typename... Args>
173 auto control_block = context.control_block;
174 --control_block->cur_depth;
179 template <
typename Reader>
187 template <
typename ControlBlock>
188 constexpr
auto try_parse(
const ControlBlock* cb,
const Reader& reader)
190 return _impl.try_parse(cb, reader);
193 template <
typename Context>
196 _impl.cancel(context);
199 template <
typename NextParser,
typename Context,
typename... Args>
203 if (!depth::increment_depth(context, reader))
205 return _impl.template finish<depth>(context, reader,
LEXY_FWD(args)...);
209 template <
typename NextParser>
212 template <
typename Context,
typename Reader,
typename... Args>
216 if (!depth::increment_depth(context, reader))
224 template <
typename Tag>
228 template <
typename Production,
typename DepthError =
void>
231 template <
typename NextParser>
234 template <
typename Tag>
241 template <
typename Production>
244 template <
typename Production>
248 #endif // LEXY_DSL_PRODUCTION_HPP_INCLUDED