Go to the documentation of this file.
4 #ifndef LEXY_DSL_DIGIT_HPP_INCLUDED
5 #define LEXY_DSL_DIGIT_HPP_INCLUDED
26 return "digit.binary";
36 static constexpr
unsigned digit_radix = 2;
38 template <
typename CharT>
41 return static_cast<unsigned>(c) -
'0';
44 template <
typename CharT>
51 return (c & mask) == expected && ((c + offset) & mask) == expected;
71 static constexpr
unsigned digit_radix = 8;
73 template <
typename CharT>
76 return static_cast<unsigned>(c) -
'0';
79 template <
typename CharT>
86 return (c & mask) == expected && ((c + offset) & mask) == expected;
96 return "digit.decimal";
106 static constexpr
unsigned digit_radix = 10;
108 template <
typename CharT>
111 return static_cast<unsigned>(c) -
'0';
114 template <
typename CharT>
121 return (c & mask) == expected && ((c + offset) & mask) == expected;
130 return "digit.hex-lower";
143 template <
typename CharT>
147 return static_cast<unsigned>(c) -
'a' + 10;
149 return static_cast<unsigned>(c) -
'0';
154 template <
typename CharT>
166 return "digit.hex-upper";
179 template <
typename CharT>
183 return static_cast<unsigned>(c) -
'A' + 10;
185 return static_cast<unsigned>(c) -
'0';
190 template <
typename CharT>
215 static constexpr
unsigned digit_radix = 16;
217 template <
typename CharT>
221 return static_cast<unsigned>(c) -
'a' + 10;
223 return static_cast<unsigned>(c) -
'A' + 10;
225 return static_cast<unsigned>(c) -
'0';
230 template <
typename CharT>
262 template <
typename Base = decimal,
int = Base::digit_radix>
286 return "forbidden leading zero";
293 template <
typename Base,
typename Reader>
304 if constexpr (lexy::_detail::is_swar_reader<Reader>)
307 while (Base::template swar_matches<char_type>(reader.peek_swar()))
318 template <
typename Base,
typename Sep,
typename Reader>
337 if constexpr (lexy::_detail::is_swar_reader<Reader>)
340 while (Base::template swar_matches<char_type>(reader.peek_swar()))
353 template <
typename Base,
typename Sep>
356 template <
typename Reader>
359 typename Reader::marker
end;
362 constexpr
explicit tp(
const Reader& reader)
369 auto begin = reader.current();
370 auto result = _match_digits_sep<Base, Sep>(reader);
371 end = reader.current();
374 && *
begin.position() == lexy::_detail::transcode_char<char_type>(
'0'))
378 end = reader.current();
387 template <
typename Context>
399 Base::char_class_name());
406 template <
typename Base,
typename Sep>
409 template <
typename Reader>
412 typename Reader::marker
end;
414 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
418 auto result = _match_digits_sep<Base, Sep>(reader);
419 end = reader.current();
423 template <
typename Context>
427 Base::char_class_name());
438 template <
typename Base>
441 template <
typename Reader>
444 typename Reader::marker
end;
447 constexpr
explicit tp(
const Reader& reader)
454 auto begin = reader.current();
455 auto result = _match_digits<Base>(reader);
456 end = reader.current();
459 && *
begin.position() == lexy::_detail::transcode_char<char_type>(
'0'))
463 end = reader.current();
472 template <
typename Context>
484 Base::char_class_name());
490 template <
typename Token>
491 constexpr
auto sep(Token)
const
493 static_assert(lexy::is_token_rule<Token>);
498 template <
typename Base>
501 template <
typename Reader>
504 typename Reader::marker
end;
506 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
510 auto result = _match_digits<Base>(reader);
511 end = reader.current();
515 template <
typename Context>
519 Base::char_class_name());
524 template <
typename Token>
525 constexpr
auto sep(Token)
const
527 static_assert(lexy::is_token_rule<Token>);
538 template <
typename Base = decimal>
547 template <
typename Base>
549 template <
typename Base>
551 template <
typename Base,
typename Sep>
553 template <
typename Base,
typename Sep>
560 template <std::
size_t N,
typename Base,
typename Sep>
565 template <
typename Reader, std::size_t... Idx>
568 typename Reader::marker
end;
570 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
577 end = reader.current();
585 end = reader.current();
589 template <
typename Context>
593 Base::char_class_name());
599 template <std::
size_t N,
typename Base>
602 static_assert(N > 1);
604 template <
typename Reader,
typename Indices = lexy::_detail::make_index_sequence<N>>
606 template <
typename Reader, std::size_t... Idx>
609 typename Reader::marker
end;
611 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
617 end = reader.current();
621 template <
typename Context>
625 Base::char_class_name());
630 template <
typename Token>
631 constexpr
auto sep(Token)
const
633 static_assert(lexy::is_token_rule<Token>);
639 template <std::
size_t N,
typename Base = decimal>
645 template <std::
size_t N,
typename Base>
647 template <std::
size_t N,
typename Base,
typename Sep>
651 #endif // LEXY_DSL_DIGIT_HPP_INCLUDED
static constexpr unsigned digit_value(CharT c)
constexpr bool try_parse(Reader reader)
static constexpr bool swar_matches(lexy::_detail::swar_int c)
integer_sequence< std::size_t, Indices... > index_sequence
static constexpr unsigned digit_value(CharT c)
constexpr tp(const Reader &reader)
string_view::value_type char_type
constexpr tp(const Reader &reader)
static LEXY_CONSTEVAL auto char_class_ascii()
static constexpr unsigned digit_value(CharT c)
constexpr auto n_digits
Matches exactly N digits.
static constexpr unsigned digit_value(CharT c)
constexpr auto no_leading_zero() const
static LEXY_CONSTEVAL auto char_class_ascii()
constexpr bool try_parse(Reader reader)
constexpr Iterator next(Iterator iter)
constexpr void report_error(Context &context, const Reader &)
constexpr bool try_parse(Reader reader)
static LEXY_CONSTEVAL auto char_class_name()
static LEXY_CONSTEVAL auto char_class_name()
static LEXY_CONSTEVAL auto char_class_name()
constexpr void insert(int c)
constexpr bool try_parse(Reader reader)
static LEXY_CONSTEVAL auto char_class_name()
static LEXY_CONSTEVAL auto char_class_ascii()
static LEXY_CONSTEVAL auto name()
typename _make_index_sequence< Size >::type make_index_sequence
constexpr auto end(const C &c) -> decltype(c.end())
constexpr void report_error(Context &context, const Reader &)
static LEXY_CONSTEVAL auto char_class_name()
constexpr tp(const Reader &reader)
bool forbidden_leading_zero
constexpr LEXY_FORCE_INLINE auto try_match_token(TokenRule, Reader &reader)
constexpr auto digit_sep_underscore
constexpr tp(const Reader &reader)
static constexpr bool swar_matches(lexy::_detail::swar_int c)
static constexpr bool swar_matches(lexy::_detail::swar_int c)
constexpr void report_error(Context &context, const Reader &reader)
constexpr void report_error(Context &context, const Reader &)
constexpr bool try_parse(Reader reader)
static LEXY_CONSTEVAL auto char_class_ascii()
constexpr auto digits
Matches a non-empty list of digits.
constexpr tp(const Reader &reader)
constexpr bool _match_digits_sep(Reader &reader)
constexpr void report_error(Context &context, const Reader &reader)
static LEXY_CONSTEVAL auto char_class_name()
static constexpr bool swar_matches(lexy::_detail::swar_int c)
constexpr auto begin(const C &c) -> decltype(c.begin())
bool forbidden_leading_zero
constexpr auto digit
Matches a single digit.
constexpr auto digit_sep_tick
static LEXY_CONSTEVAL auto char_class_ascii()
static LEXY_CONSTEVAL auto char_class_name()
constexpr tp(const Reader &reader)
constexpr bool _match_digits(Reader &reader)
constexpr auto sep(Token) const
constexpr auto sep(Token) const
static LEXY_CONSTEVAL auto char_class_ascii()
static constexpr bool swar_matches(lexy::_detail::swar_int c)
static constexpr unsigned digit_radix
static LEXY_CONSTEVAL auto char_class_ascii()
constexpr auto sep(Token) const
constexpr auto zero
Matches the zero digit.
static constexpr bool swar_matches(lexy::_detail::swar_int c)
static constexpr unsigned digit_value(CharT c)
static constexpr unsigned digit_value(CharT c)
constexpr bool try_parse(Reader reader)
constexpr swar_int swar_fill_compl(CharT _c)
static constexpr unsigned digit_radix
constexpr auto no_leading_zero() const
constexpr void report_error(Context &context, const Reader &reader)
constexpr swar_int swar_fill(CharT _c)