digit.hpp
Go to the documentation of this file.
1 // Copyright (C) 2020-2023 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_DSL_DIGIT_HPP_INCLUDED
5 #define LEXY_DSL_DIGIT_HPP_INCLUDED
6 
7 #include <lexy/_detail/swar.hpp>
8 #include <lexy/dsl/base.hpp>
10 #include <lexy/dsl/literal.hpp>
11 #include <lexy/dsl/token.hpp>
12 
13 //=== bases ===//
14 // SWAR matching code adapted from:
15 // https://lemire.me/blog/2018/09/30/quickly-identifying-a-sequence-of-digits-in-a-string-of-characters/
16 namespace lexyd
17 {
18 template <int Radix>
19 struct _d;
20 
21 template <>
22 struct _d<2> : char_class_base<_d<2>>
23 {
25  {
26  return "digit.binary";
27  }
28 
30  {
32  result.insert('0', '1');
33  return result;
34  }
35 
36  static constexpr unsigned digit_radix = 2;
37 
38  template <typename CharT>
39  static constexpr unsigned digit_value(CharT c)
40  {
41  return static_cast<unsigned>(c) - '0';
42  }
43 
44  template <typename CharT>
45  static constexpr bool swar_matches(lexy::_detail::swar_int c)
46  {
47  constexpr auto mask = lexy::_detail::swar_fill_compl(CharT(0xF));
48  constexpr auto expected = lexy::_detail::swar_fill(CharT(0x30));
49  constexpr auto offset = lexy::_detail::swar_fill(CharT(0x0E));
50 
51  return (c & mask) == expected && ((c + offset) & mask) == expected;
52  }
53 };
54 using binary = _d<2>;
55 
56 template <>
57 struct _d<8> : char_class_base<_d<8>>
58 {
60  {
61  return "digit.octal";
62  }
63 
65  {
67  result.insert('0', '7');
68  return result;
69  }
70 
71  static constexpr unsigned digit_radix = 8;
72 
73  template <typename CharT>
74  static constexpr unsigned digit_value(CharT c)
75  {
76  return static_cast<unsigned>(c) - '0';
77  }
78 
79  template <typename CharT>
80  static constexpr bool swar_matches(lexy::_detail::swar_int c)
81  {
82  constexpr auto mask = lexy::_detail::swar_fill_compl(CharT(0xF));
83  constexpr auto expected = lexy::_detail::swar_fill(CharT(0x30));
84  constexpr auto offset = lexy::_detail::swar_fill(CharT(0x08));
85 
86  return (c & mask) == expected && ((c + offset) & mask) == expected;
87  }
88 };
89 using octal = _d<8>;
90 
91 template <>
92 struct _d<10> : char_class_base<_d<10>>
93 {
95  {
96  return "digit.decimal";
97  }
98 
100  {
102  result.insert('0', '9');
103  return result;
104  }
105 
106  static constexpr unsigned digit_radix = 10;
107 
108  template <typename CharT>
109  static constexpr unsigned digit_value(CharT c)
110  {
111  return static_cast<unsigned>(c) - '0';
112  }
113 
114  template <typename CharT>
115  static constexpr bool swar_matches(lexy::_detail::swar_int c)
116  {
117  constexpr auto mask = lexy::_detail::swar_fill_compl(CharT(0xF));
118  constexpr auto expected = lexy::_detail::swar_fill(CharT(0x30));
119  constexpr auto offset = lexy::_detail::swar_fill(CharT(0x06));
120 
121  return (c & mask) == expected && ((c + offset) & mask) == expected;
122  }
123 };
124 using decimal = _d<10>;
125 
126 struct hex_lower : char_class_base<hex_lower>
127 {
129  {
130  return "digit.hex-lower";
131  }
132 
134  {
136  result.insert('0', '9');
137  result.insert('a', 'f');
138  return result;
139  }
140 
141  static constexpr unsigned digit_radix = 16;
142 
143  template <typename CharT>
144  static constexpr unsigned digit_value(CharT c)
145  {
146  if (c >= 'a')
147  return static_cast<unsigned>(c) - 'a' + 10;
148  else if (c <= '9')
149  return static_cast<unsigned>(c) - '0';
150  else
151  return unsigned(-1);
152  }
153 
154  template <typename CharT>
155  static constexpr bool swar_matches(lexy::_detail::swar_int c)
156  {
157  // False negative for hex digits, but that's okay.
158  return _d<10>::swar_matches<CharT>(c);
159  }
160 };
161 
162 struct hex_upper : char_class_base<hex_upper>
163 {
165  {
166  return "digit.hex-upper";
167  }
168 
170  {
172  result.insert('0', '9');
173  result.insert('A', 'F');
174  return result;
175  }
176 
177  static constexpr unsigned digit_radix = 16;
178 
179  template <typename CharT>
180  static constexpr unsigned digit_value(CharT c)
181  {
182  if (c >= 'A')
183  return static_cast<unsigned>(c) - 'A' + 10;
184  else if (c <= '9')
185  return static_cast<unsigned>(c) - '0';
186  else
187  return unsigned(-1);
188  }
189 
190  template <typename CharT>
191  static constexpr bool swar_matches(lexy::_detail::swar_int c)
192  {
193  // False negative for hex digits, but that's okay.
194  return _d<10>::swar_matches<CharT>(c);
195  }
196 };
197 
198 template <>
199 struct _d<16> : char_class_base<_d<16>>
200 {
202  {
203  return "digit.hex";
204  }
205 
207  {
209  result.insert('0', '9');
210  result.insert('a', 'f');
211  result.insert('A', 'F');
212  return result;
213  }
214 
215  static constexpr unsigned digit_radix = 16;
216 
217  template <typename CharT>
218  static constexpr unsigned digit_value(CharT c)
219  {
220  if (c >= 'a')
221  return static_cast<unsigned>(c) - 'a' + 10;
222  else if (c >= 'A')
223  return static_cast<unsigned>(c) - 'A' + 10;
224  else if (c <= '9')
225  return static_cast<unsigned>(c) - '0';
226  else
227  return unsigned(-1);
228  }
229 
230  template <typename CharT>
231  static constexpr bool swar_matches(lexy::_detail::swar_int c)
232  {
233  // False negative for hex digits, but that's okay.
234  return _d<10>::swar_matches<CharT>(c);
235  }
236 };
237 using hex = _d<16>;
238 } // namespace lexyd
239 
240 //=== digit ===//
241 namespace lexyd
242 {
243 struct _zero : char_class_base<_zero>
244 {
246  {
247  return "digit.zero";
248  }
249 
251  {
253  result.insert('0');
254  return result;
255  }
256 };
257 
259 constexpr auto zero = _zero{};
260 
262 template <typename Base = decimal, int = Base::digit_radix>
263 constexpr auto digit = Base{};
264 } // namespace lexyd
265 
266 namespace lexy
267 {
268 template <>
269 inline constexpr auto token_kind_of<lexy::dsl::_zero> = lexy::digits_token_kind;
270 
271 template <int Radix>
272 constexpr auto token_kind_of<lexy::dsl::_d<Radix>> = lexy::digits_token_kind;
273 template <>
274 inline constexpr auto token_kind_of<lexy::dsl::hex_lower> = lexy::digits_token_kind;
275 template <>
276 inline constexpr auto token_kind_of<lexy::dsl::hex_upper> = lexy::digits_token_kind;
277 } // namespace lexy
278 
279 //=== digits ===//
280 namespace lexy
281 {
283 {
284  static LEXY_CONSTEVAL auto name()
285  {
286  return "forbidden leading zero";
287  }
288 };
289 } // namespace lexy
290 
291 namespace lexyd
292 {
293 template <typename Base, typename Reader>
294 constexpr bool _match_digits(Reader& reader)
295 {
296  // Need at least one digit.
297  // Checking for a single digit is also cheaper than doing a SWAR comparison,
298  // so we do that manually in either case.
299  if (!lexy::try_match_token(digit<Base>, reader))
300  return false;
301 
302  // Now we consume as many digits as possible.
303  // First using SWAR...
304  if constexpr (lexy::_detail::is_swar_reader<Reader>)
305  {
306  using char_type = typename Reader::encoding::char_type;
307  while (Base::template swar_matches<char_type>(reader.peek_swar()))
308  reader.bump_swar();
309  }
310 
311  // ... then manually to get any trailing digits.
312  while (lexy::try_match_token(digit<Base>, reader))
313  {}
314 
315  return true;
316 }
317 template <typename Base, typename Sep, typename Reader>
318 constexpr bool _match_digits_sep(Reader& reader)
319 {
320  // Need at least one digit.
321  if (!lexy::try_match_token(digit<Base>, reader))
322  return false;
323 
324  // Might have following digits.
325  while (true)
326  {
327  if (lexy::try_match_token(Sep{}, reader))
328  {
329  // Need a digit after a separator.
330  if (!lexy::try_match_token(digit<Base>, reader))
331  return false;
332  }
333  else
334  {
335  // Attempt to consume as many digits as possible.
336  if constexpr (lexy::_detail::is_swar_reader<Reader>)
337  {
338  using char_type = typename Reader::encoding::char_type;
339  while (Base::template swar_matches<char_type>(reader.peek_swar()))
340  reader.bump_swar();
341  }
342 
343  if (!lexy::try_match_token(digit<Base>, reader))
344  // If we're not having a digit, we're done.
345  break;
346  }
347  }
348 
349  return true;
350 }
351 
352 template <typename Base, typename Sep>
353 struct _digits_st : token_base<_digits_st<Base, Sep>>
354 {
355  template <typename Reader>
356  struct tp
357  {
358  typename Reader::iterator end;
360 
361  constexpr explicit tp(const Reader& reader)
362  : end(reader.position()), forbidden_leading_zero(false)
363  {}
364 
365  constexpr bool try_parse(Reader reader)
366  {
367  using char_type = typename Reader::encoding::char_type;
368  auto begin = reader.position();
369  auto result = _match_digits_sep<Base, Sep>(reader);
370  end = reader.position();
371 
372  if (result && lexy::_detail::next(begin) != end
373  && *begin == lexy::_detail::transcode_char<char_type>('0'))
374  {
376  forbidden_leading_zero = true;
377  return false;
378  }
379 
380  return result;
381  }
382 
383  template <typename Context>
384  constexpr void report_error(Context& context, const Reader& reader)
385  {
387  {
388  auto err
390  context.on(_ev::error{}, err);
391  }
392  else
393  {
394  auto err
395  = lexy::error<Reader, lexy::expected_char_class>(end, Base::char_class_name());
396  context.on(_ev::error{}, err);
397  }
398  }
399  };
400 };
401 
402 template <typename Base, typename Sep>
403 struct _digits_s : token_base<_digits_s<Base, Sep>>
404 {
405  template <typename Reader>
406  struct tp
407  {
408  typename Reader::iterator end;
409 
410  constexpr explicit tp(const Reader& reader) : end(reader.position()) {}
411 
412  constexpr bool try_parse(Reader reader)
413  {
414  auto result = _match_digits_sep<Base, Sep>(reader);
415  end = reader.position();
416  return result;
417  }
418 
419  template <typename Context>
420  constexpr void report_error(Context& context, const Reader&)
421  {
422  auto err = lexy::error<Reader, lexy::expected_char_class>(end, Base::char_class_name());
423  context.on(_ev::error{}, err);
424  }
425  };
426 
427  constexpr auto no_leading_zero() const
428  {
429  return _digits_st<Base, Sep>{};
430  }
431 };
432 
433 template <typename Base>
434 struct _digits_t : token_base<_digits_t<Base>>
435 {
436  template <typename Reader>
437  struct tp
438  {
439  typename Reader::iterator end;
441 
442  constexpr explicit tp(const Reader& reader)
443  : end(reader.position()), forbidden_leading_zero(false)
444  {}
445 
446  constexpr bool try_parse(Reader reader)
447  {
448  using char_type = typename Reader::encoding::char_type;
449  auto begin = reader.position();
450  auto result = _match_digits<Base>(reader);
451  end = reader.position();
452 
453  if (result && lexy::_detail::next(begin) != end
454  && *begin == lexy::_detail::transcode_char<char_type>('0'))
455  {
457  forbidden_leading_zero = true;
458  return false;
459  }
460 
461  return result;
462  }
463 
464  template <typename Context>
465  constexpr void report_error(Context& context, const Reader& reader)
466  {
468  {
469  auto err = lexy::error<Reader, lexy::forbidden_leading_zero>(reader.position(),
470  this->end);
471  context.on(_ev::error{}, err);
472  }
473  else
474  {
475  auto err = lexy::error<Reader, lexy::expected_char_class>(reader.position(),
476  Base::char_class_name());
477  context.on(_ev::error{}, err);
478  }
479  }
480  };
481 
482  template <typename Token>
483  constexpr auto sep(Token) const
484  {
485  static_assert(lexy::is_token_rule<Token>);
486  return _digits_st<Base, Token>{};
487  }
488 };
489 
490 template <typename Base>
491 struct _digits : token_base<_digits<Base>>
492 {
493  template <typename Reader>
494  struct tp
495  {
496  typename Reader::iterator end;
497 
498  constexpr explicit tp(const Reader& reader) : end(reader.position()) {}
499 
500  constexpr bool try_parse(Reader reader)
501  {
502  auto result = _match_digits<Base>(reader);
503  end = reader.position();
504  return result;
505  }
506 
507  template <typename Context>
508  constexpr void report_error(Context& context, const Reader& reader)
509  {
510  auto err = lexy::error<Reader, lexy::expected_char_class>(reader.position(),
511  Base::char_class_name());
512  context.on(_ev::error{}, err);
513  }
514  };
515 
516  template <typename Token>
517  constexpr auto sep(Token) const
518  {
519  static_assert(lexy::is_token_rule<Token>);
520  return _digits_s<Base, Token>{};
521  }
522 
523  constexpr auto no_leading_zero() const
524  {
525  return _digits_t<Base>{};
526  }
527 };
528 
530 template <typename Base = decimal>
531 constexpr auto digits = _digits<Base>{};
532 
533 constexpr auto digit_sep_underscore = LEXY_LIT("_");
534 constexpr auto digit_sep_tick = LEXY_LIT("'");
535 } // namespace lexyd
536 
537 namespace lexy
538 {
539 template <typename Base>
540 constexpr auto token_kind_of<lexy::dsl::_digits<Base>> = lexy::digits_token_kind;
541 template <typename Base>
542 constexpr auto token_kind_of<lexy::dsl::_digits_t<Base>> = lexy::digits_token_kind;
543 template <typename Base, typename Sep>
544 constexpr auto token_kind_of<lexy::dsl::_digits_s<Base, Sep>> = lexy::digits_token_kind;
545 template <typename Base, typename Sep>
546 constexpr auto token_kind_of<lexy::dsl::_digits_st<Base, Sep>> = lexy::digits_token_kind;
547 } // namespace lexy
548 
549 //=== n_digits ===//
550 namespace lexyd
551 {
552 template <std::size_t N, typename Base, typename Sep>
553 struct _ndigits_s : token_base<_ndigits_s<N, Base, Sep>>
554 {
555  template <typename Reader, typename Indices = lexy::_detail::make_index_sequence<N - 1>>
556  struct tp;
557  template <typename Reader, std::size_t... Idx>
558  struct tp<Reader, lexy::_detail::index_sequence<Idx...>>
559  {
560  typename Reader::iterator end;
561 
562  constexpr explicit tp(const Reader& reader) : end(reader.position()) {}
563 
564  constexpr bool try_parse(Reader reader)
565  {
566  // Match the Base one time.
567  if (!lexy::try_match_token(digit<Base>, reader))
568  {
569  end = reader.position();
570  return false;
571  }
572 
573  // Match each other digit after a separator.
574  auto success = (((void)Idx, lexy::try_match_token(Sep{}, reader),
575  lexy::try_match_token(digit<Base>, reader))
576  && ...);
577  end = reader.position();
578  return success;
579  }
580 
581  template <typename Context>
582  constexpr void report_error(Context& context, const Reader&)
583  {
584  auto err = lexy::error<Reader, lexy::expected_char_class>(end, Base::char_class_name());
585  context.on(_ev::error{}, err);
586  }
587  };
588 };
589 
590 template <std::size_t N, typename Base>
591 struct _ndigits : token_base<_ndigits<N, Base>>
592 {
593  static_assert(N > 1);
594 
595  template <typename Reader, typename Indices = lexy::_detail::make_index_sequence<N>>
596  struct tp;
597  template <typename Reader, std::size_t... Idx>
598  struct tp<Reader, lexy::_detail::index_sequence<Idx...>>
599  {
600  typename Reader::iterator end;
601 
602  constexpr explicit tp(const Reader& reader) : end(reader.position()) {}
603 
604  constexpr bool try_parse(Reader reader)
605  {
606  // Match the Base N times.
607  auto success = (((void)Idx, lexy::try_match_token(digit<Base>, reader)) && ...);
608  end = reader.position();
609  return success;
610  }
611 
612  template <typename Context>
613  constexpr void report_error(Context& context, const Reader&)
614  {
615  auto err = lexy::error<Reader, lexy::expected_char_class>(end, Base::char_class_name());
616  context.on(_ev::error{}, err);
617  }
618  };
619 
620  template <typename Token>
621  constexpr auto sep(Token) const
622  {
623  static_assert(lexy::is_token_rule<Token>);
625  }
626 };
627 
629 template <std::size_t N, typename Base = decimal>
630 constexpr auto n_digits = _ndigits<N, Base>{};
631 } // namespace lexyd
632 
633 namespace lexy
634 {
635 template <std::size_t N, typename Base>
636 constexpr auto token_kind_of<lexy::dsl::_ndigits<N, Base>> = lexy::digits_token_kind;
637 template <std::size_t N, typename Base, typename Sep>
638 constexpr auto token_kind_of<lexy::dsl::_ndigits_s<N, Base, Sep>> = lexy::digits_token_kind;
639 } // namespace lexy
640 
641 #endif // LEXY_DSL_DIGIT_HPP_INCLUDED
642 
lexyd::_d< 16 >::digit_value
static constexpr unsigned digit_value(CharT c)
Definition: digit.hpp:218
lexyd::position
constexpr auto position
Produces an iterator to the current reader position without parsing anything.
Definition: position.hpp:79
lexyd::_digits_st::tp::try_parse
constexpr bool try_parse(Reader reader)
Definition: digit.hpp:365
lexyd::hex_upper::swar_matches
static constexpr bool swar_matches(lexy::_detail::swar_int c)
Definition: digit.hpp:191
LEXY_CONSTEVAL
#define LEXY_CONSTEVAL
Definition: config.hpp:90
lexy::_detail::index_sequence
integer_sequence< std::size_t, Indices... > index_sequence
Definition: integer_sequence.hpp:17
lexyd::_digits_st
Definition: digit.hpp:353
lexyd::_ndigits::tp< Reader, lexy::_detail::index_sequence< Idx... > >::end
Reader::iterator end
Definition: digit.hpp:600
lexyd::_d< 10 >::digit_value
static constexpr unsigned digit_value(CharT c)
Definition: digit.hpp:109
token.hpp
lexyd::_digits::tp::tp
constexpr tp(const Reader &reader)
Definition: digit.hpp:498
literal.hpp
LEXY_LIT
#define LEXY_LIT(Str)
Definition: literal.hpp:390
magic_enum::char_type
string_view::value_type char_type
Definition: magic_enum.hpp:145
lexyd::_digits_st::tp::tp
constexpr tp(const Reader &reader)
Definition: digit.hpp:361
lexyd::_d< 10 >::char_class_ascii
static LEXY_CONSTEVAL auto char_class_ascii()
Definition: digit.hpp:99
lexyd::hex_upper::digit_value
static constexpr unsigned digit_value(CharT c)
Definition: digit.hpp:180
lexyd::n_digits
constexpr auto n_digits
Matches exactly N digits.
Definition: digit.hpp:630
lexyd::_ndigits_s::tp< Reader, lexy::_detail::index_sequence< Idx... > >::end
Reader::iterator end
Definition: digit.hpp:560
lexyd::_d< 2 >::digit_value
static constexpr unsigned digit_value(CharT c)
Definition: digit.hpp:39
lexyd::_digits_st::tp
Definition: digit.hpp:356
lexy::_detail::swar_int
std::uintmax_t swar_int
Definition: swar.hpp:20
lexyd::_digits_s::no_leading_zero
constexpr auto no_leading_zero() const
Definition: digit.hpp:427
lexyd::_zero::char_class_ascii
static LEXY_CONSTEVAL auto char_class_ascii()
Definition: digit.hpp:250
lexyd::_digits_s::tp::try_parse
constexpr bool try_parse(Reader reader)
Definition: digit.hpp:412
lexy::_detail::next
constexpr Iterator next(Iterator iter)
Definition: iterator.hpp:38
lexyd::_ndigits::tp< Reader, lexy::_detail::index_sequence< Idx... > >::report_error
constexpr void report_error(Context &context, const Reader &)
Definition: digit.hpp:613
lexyd::_digits_t::tp::try_parse
constexpr bool try_parse(Reader reader)
Definition: digit.hpp:446
lexyd::_d< 16 >
Definition: digit.hpp:199
lexyd::_d< 2 >::char_class_name
static LEXY_CONSTEVAL auto char_class_name()
Definition: digit.hpp:24
lexyd::_d< 16 >::char_class_name
static LEXY_CONSTEVAL auto char_class_name()
Definition: digit.hpp:201
lexyd::hex_upper
Definition: digit.hpp:162
lexyd::_d< 8 >::char_class_name
static LEXY_CONSTEVAL auto char_class_name()
Definition: digit.hpp:59
lexy::_detail::ascii_set::insert
constexpr void insert(int c)
Definition: char_class.hpp:54
lexyd::_digits_s
Definition: digit.hpp:403
lexyd::_digits::tp::try_parse
constexpr bool try_parse(Reader reader)
Definition: digit.hpp:500
lexy
Definition: any_ref.hpp:12
lexyd::_digits::tp
Definition: digit.hpp:494
lexyd::_zero::char_class_name
static LEXY_CONSTEVAL auto char_class_name()
Definition: digit.hpp:245
lexyd::hex_upper::char_class_ascii
static LEXY_CONSTEVAL auto char_class_ascii()
Definition: digit.hpp:169
lexyd::_digits_t::tp
Definition: digit.hpp:437
lexy::forbidden_leading_zero::name
static LEXY_CONSTEVAL auto name()
Definition: digit.hpp:284
lexy::_detail::make_index_sequence
typename _make_index_sequence< Size >::type make_index_sequence
Definition: integer_sequence.hpp:55
lexy::forbidden_leading_zero
Definition: digit.hpp:282
cx::end
constexpr auto end(const C &c) -> decltype(c.end())
Definition: wildcards.hpp:686
char_class.hpp
detail::void
j template void())
Definition: json.hpp:4893
lexy::error
Generic failure.
Definition: error.hpp:14
lexyd::_ndigits_s::tp< Reader, lexy::_detail::index_sequence< Idx... > >::report_error
constexpr void report_error(Context &context, const Reader &)
Definition: digit.hpp:582
lexyd::_d< 10 >::char_class_name
static LEXY_CONSTEVAL auto char_class_name()
Definition: digit.hpp:94
swar.hpp
lexyd::_digits_t::tp::tp
constexpr tp(const Reader &reader)
Definition: digit.hpp:442
lexyd::_ndigits
Definition: digit.hpp:591
lexyd::_digits_t::tp::forbidden_leading_zero
bool forbidden_leading_zero
Definition: digit.hpp:440
lexyd::_d< 2 >
Definition: digit.hpp:22
lexy::parse_events::error
Definition: dsl/base.hpp:55
lexy::try_match_token
constexpr LEXY_FORCE_INLINE auto try_match_token(TokenRule, Reader &reader)
Definition: dsl/base.hpp:232
lexyd::token_base
Definition: dsl/token.hpp:42
lexyd::_digits_s::tp::end
Reader::iterator end
Definition: digit.hpp:408
lexyd::digit_sep_underscore
constexpr auto digit_sep_underscore
Definition: digit.hpp:533
lexyd::_ndigits_s::tp
Definition: digit.hpp:556
lexyd::_digits_t
Definition: digit.hpp:434
lexyd::_ndigits_s::tp< Reader, lexy::_detail::index_sequence< Idx... > >::tp
constexpr tp(const Reader &reader)
Definition: digit.hpp:562
lexyd::hex_lower::swar_matches
static constexpr bool swar_matches(lexy::_detail::swar_int c)
Definition: digit.hpp:155
lexyd::_d< 8 >::swar_matches
static constexpr bool swar_matches(lexy::_detail::swar_int c)
Definition: digit.hpp:80
lexyd::_digits_t::tp::report_error
constexpr void report_error(Context &context, const Reader &reader)
Definition: digit.hpp:465
lexyd::_digits_s::tp::report_error
constexpr void report_error(Context &context, const Reader &)
Definition: digit.hpp:420
lexyd::_ndigits_s::tp< Reader, lexy::_detail::index_sequence< Idx... > >::try_parse
constexpr bool try_parse(Reader reader)
Definition: digit.hpp:564
lexy::digits_token_kind
@ digits_token_kind
Definition: grammar.hpp:86
lexyd::_d< 2 >::char_class_ascii
static LEXY_CONSTEVAL auto char_class_ascii()
Definition: digit.hpp:29
lexyd::_d
Definition: digit.hpp:19
lexyd::digits
constexpr auto digits
Matches a non-empty list of digits.
Definition: digit.hpp:531
lexyd::_ndigits_s
Definition: digit.hpp:553
lexyd::_digits_s::tp::tp
constexpr tp(const Reader &reader)
Definition: digit.hpp:410
lexyd::_zero
Definition: digit.hpp:243
lexyd::_match_digits_sep
constexpr bool _match_digits_sep(Reader &reader)
Definition: digit.hpp:318
lexyd::_digits_st::tp::report_error
constexpr void report_error(Context &context, const Reader &reader)
Definition: digit.hpp:384
lexyd::char_class_base
Definition: char_class.hpp:170
lexyd::hex_upper::char_class_name
static LEXY_CONSTEVAL auto char_class_name()
Definition: digit.hpp:164
lexyd::_d< 2 >::swar_matches
static constexpr bool swar_matches(lexy::_detail::swar_int c)
Definition: digit.hpp:45
lexyd::_digits::tp::end
Reader::iterator end
Definition: digit.hpp:496
cx::begin
constexpr auto begin(const C &c) -> decltype(c.begin())
Definition: wildcards.hpp:661
lexyd::_digits_st::tp::end
Reader::iterator end
Definition: digit.hpp:358
lexyd::_digits_t::tp::end
Reader::iterator end
Definition: digit.hpp:439
lexyd::_digits_st::tp::forbidden_leading_zero
bool forbidden_leading_zero
Definition: digit.hpp:359
lexyd::digit
constexpr auto digit
Matches a single digit.
Definition: digit.hpp:263
lexyd::digit_sep_tick
constexpr auto digit_sep_tick
Definition: digit.hpp:534
lexyd::_d< 16 >::char_class_ascii
static LEXY_CONSTEVAL auto char_class_ascii()
Definition: digit.hpp:206
lexyd::_digits_s::tp
Definition: digit.hpp:406
lexyd::hex_lower::char_class_name
static LEXY_CONSTEVAL auto char_class_name()
Definition: digit.hpp:128
lexyd::_ndigits::tp
Definition: digit.hpp:596
base.hpp
lexyd::_ndigits::tp< Reader, lexy::_detail::index_sequence< Idx... > >::tp
constexpr tp(const Reader &reader)
Definition: digit.hpp:602
lexyd::_match_digits
constexpr bool _match_digits(Reader &reader)
Definition: digit.hpp:294
lexyd::_digits::sep
constexpr auto sep(Token) const
Definition: digit.hpp:517
lexyd::_digits_t::sep
constexpr auto sep(Token) const
Definition: digit.hpp:483
lexyd::_d< 8 >::char_class_ascii
static LEXY_CONSTEVAL auto char_class_ascii()
Definition: digit.hpp:64
lexyd::_d< 10 >
Definition: digit.hpp:92
lexyd::_d< 10 >::swar_matches
static constexpr bool swar_matches(lexy::_detail::swar_int c)
Definition: digit.hpp:115
lexyd::hex_lower::digit_radix
static constexpr unsigned digit_radix
Definition: digit.hpp:141
lexyd::hex_lower::char_class_ascii
static LEXY_CONSTEVAL auto char_class_ascii()
Definition: digit.hpp:133
lexyd::_ndigits::sep
constexpr auto sep(Token) const
Definition: digit.hpp:621
lexyd::_digits
Definition: digit.hpp:491
lexyd::zero
constexpr auto zero
Matches the zero digit.
Definition: digit.hpp:259
lexyd::hex_lower
Definition: digit.hpp:126
lexyd::_d< 16 >::swar_matches
static constexpr bool swar_matches(lexy::_detail::swar_int c)
Definition: digit.hpp:231
lexyd::hex_lower::digit_value
static constexpr unsigned digit_value(CharT c)
Definition: digit.hpp:144
lexyd::_d< 8 >::digit_value
static constexpr unsigned digit_value(CharT c)
Definition: digit.hpp:74
lexyd
Definition: trace.hpp:22
lexyd::_ndigits::tp< Reader, lexy::_detail::index_sequence< Idx... > >::try_parse
constexpr bool try_parse(Reader reader)
Definition: digit.hpp:604
lexy::_detail::swar_fill_compl
constexpr swar_int swar_fill_compl(CharT _c)
Definition: swar.hpp:61
lexyd::hex_upper::digit_radix
static constexpr unsigned digit_radix
Definition: digit.hpp:177
lexyd::_digits::no_leading_zero
constexpr auto no_leading_zero() const
Definition: digit.hpp:523
lexyd::_d< 8 >
Definition: digit.hpp:57
lexyd::_digits::tp::report_error
constexpr void report_error(Context &context, const Reader &reader)
Definition: digit.hpp:508
lexy::_detail::ascii_set
Definition: char_class.hpp:14
lexy::_detail::swar_fill
constexpr swar_int swar_fill(CharT _c)
Definition: swar.hpp:46


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07