Go to the documentation of this file.
4 #ifndef LEXY_DSL_CONTEXT_COUNTER_HPP_INCLUDED
5 #define LEXY_DSL_CONTEXT_COUNTER_HPP_INCLUDED
18 return "unequal counts";
25 template <
typename Id>
28 template <
typename Id,
int InitialValue>
31 template <
typename NextParser>
34 template <
typename Context,
typename Reader,
typename... Args>
46 template <
typename Id,
int Delta>
49 template <
typename NextParser>
52 template <
typename Context,
typename Reader,
typename... Args>
61 template <
typename Id,
typename Rule,
int Sign>
64 template <
typename NextParser>
67 template <
typename Context,
typename Reader,
typename... Args>
69 typename Reader::iterator
begin, Args&&... args)
71 auto end = reader.position();
80 template <
typename Reader>
85 template <
typename ControlBlock>
86 constexpr
auto try_parse(
const ControlBlock* cb,
const Reader& reader)
88 return rule.try_parse(cb, reader);
91 template <
typename Context>
92 constexpr
void cancel(Context& context)
97 template <
typename NextParser,
typename Context,
typename... Args>
101 return rule.template finish<_pc<NextParser>>(context, reader, reader.position(),
106 template <
typename NextParser>
109 template <
typename Context,
typename Reader,
typename... Args>
119 template <
typename Id,
int Value>
122 template <
typename Reader>
125 template <
typename ControlBlock>
126 constexpr
bool try_parse(
const ControlBlock* cb,
const Reader&)
131 template <
typename Context>
135 template <
typename NextParser,
typename Context,
typename... Args>
142 template <
typename NextParser>
143 using p = NextParser;
146 template <
typename Id>
149 template <
typename NextParser>
152 template <
typename Context,
typename Reader,
typename... Args>
161 template <
typename... Ids>
163 template <
typename H,
typename... T>
166 template <
typename Reader>
169 template <
typename ControlBlock>
170 constexpr
bool try_parse(
const ControlBlock* cb,
const Reader&)
176 template <
typename Context>
180 template <
typename NextParser,
typename Context,
typename... Args>
187 template <
typename NextParser>
190 template <
typename Context,
typename Reader,
typename... Args>
209 template <
typename Id>
212 template <
int InitialValue = 0>
218 constexpr
auto inc()
const
222 constexpr
auto dec()
const
227 template <
typename Rule>
228 constexpr
auto push(Rule)
const
232 template <
typename Rule>
233 constexpr
auto pop(Rule)
const
239 constexpr
auto is()
const
255 template <
typename Id>
259 template <
typename... Ids>
262 static_assert(
sizeof...(Ids) > 1);
267 #endif // LEXY_DSL_CONTEXT_COUNTER_HPP_INCLUDED
lexy::branch_parser_for< Rule, Reader > rule
constexpr void cancel(Context &)
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
LEXY_PARSER_FUNC auto finish(Context &context, Reader &reader, Args &&... args)
static constexpr T & get(const ControlBlock *cb)
typename BranchRule::template bp< Reader > branch_parser_for
constexpr auto inc() const
constexpr void cancel(Context &)
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
constexpr auto end(const C &c) -> decltype(c.end())
constexpr bool try_parse(const ControlBlock *cb, const Reader &)
constexpr auto parse(const Input &input, const ErrorCallback &callback)
Parses the production into a value, invoking the callback on error.
constexpr auto is() const
constexpr auto create() const
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
constexpr void link(Context &context)
constexpr void cancel(Context &context)
static LEXY_CONSTEVAL auto name()
constexpr auto is_zero() const
constexpr std::size_t range_size(Iterator begin, Sentinel end)
LEXY_PARSER_FUNC bool finish(Context &context, Reader &reader, Args &&... args)
constexpr auto equal_counts(_ctx_counter_dsl< Ids >...)
Takes a branch only if all counters are equal.
constexpr auto pop(Rule) const
constexpr auto begin(const C &c) -> decltype(c.begin())
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, typename Reader::iterator begin, Args &&... args)
constexpr auto context_counter
Declares an integer counter that is added to the parsing context.
constexpr auto push(Rule) const
constexpr auto dec() const
constexpr auto try_parse(const ControlBlock *cb, const Reader &reader)
static LEXY_PARSER_FUNC bool parse(Context &context, Reader &reader, Args &&... args)
constexpr auto value() const
typename Rule::template p< NextParser > parser_for
constexpr bool try_parse(const ControlBlock *cb, const Reader &)
constexpr void unlink(Context &context)
constexpr auto p
Parses the production.
LEXY_PARSER_FUNC bool finish(Context &context, Reader &reader, Args &&... args)
decltype(_copy_base_impl< Rule >()) _copy_base