Go to the documentation of this file.
4 #ifndef LEXY_DSL_BITS_HPP_INCLUDED
5 #define LEXY_DSL_BITS_HPP_INCLUDED
24 static constexpr
auto size = 1u;
36 inline constexpr
auto _0 =
_b0{};
40 static constexpr
auto size = 1u;
53 inline constexpr
auto _1 =
_b1{};
55 template <
unsigned Value>
58 static_assert(Value <= 0xF);
60 static constexpr
auto size = 4u;
73 template <
unsigned Value>
81 static constexpr
auto size = N;
101 template <
unsigned Mask,
unsigned Value>
104 template <
typename Reader>
107 typename Reader::marker
end;
109 constexpr
explicit tp(
const Reader& reader) :
end(reader.current()) {}
113 static_assert(lexy::is_byte_encoding<typename Reader::encoding>);
115 auto byte = reader.peek();
117 || ((
static_cast<unsigned char>(
byte) & Mask) != Value))
121 end = reader.current();
125 template <
typename Context>
135 template <
typename... Bits>
138 static_assert((std::is_base_of_v<bit::_bit_rule, Bits> && ...),
"bits() requires bit rules");
139 static_assert((0 + ... +
Bits::size) == 8,
"must specify 8 bit at a time");
141 constexpr
auto pattern = [] {
143 (Bits::apply(result), ...);
147 return _bits<pattern.mask, pattern.value>{};
151 #endif // LEXY_DSL_BITS_HPP_INCLUDED
constexpr auto size(const C &c) -> decltype(c.size())
constexpr auto bits(Bits...)
Matches the specific bit pattern.
static constexpr auto size
static constexpr auto size
constexpr auto any
Matches N arbitrary bits.
static constexpr void apply(_bit_pattern &p)
constexpr auto _1
Matches a 1 bit.
constexpr auto _0
Matches a 0 bit.
constexpr void report_error(Context &context, const Reader &)
static constexpr auto size
static constexpr void apply(_bit_pattern &p)
constexpr auto _
Matches any bit.
constexpr bool try_parse(Reader reader)
static constexpr void apply(_bit_pattern &p)
static constexpr void apply(_bit_pattern &p)
constexpr auto nibble
Matches a specific nibble, i.e. four bits.
static constexpr auto size
constexpr tp(const Reader &reader)
constexpr auto eof
Matches EOF.
constexpr auto p
Parses the production.