Go to the documentation of this file.
4 #ifndef LEXY_DSL_CASE_FOLDING_HPP_INCLUDED
5 #define LEXY_DSL_CASE_FOLDING_HPP_INCLUDED
15 template <
template <
typename>
typename CaseFolding>
18 template <
typename Reader>
22 template <
typename Literal,
template <
typename>
typename CaseFolding>
31 template <
typename Encoding>
34 return Literal::template lit_first_char<Encoding>();
37 template <
typename Trie>
39 std::size_t char_class)
41 return Literal::lit_insert(trie, pos, char_class);
44 template <
typename Reader>
48 typename Reader::marker
end;
50 constexpr
explicit tp(
const Reader& reader)
51 :
impl(CaseFolding<Reader>{reader}),
end(reader.current())
56 CaseFolding<Reader> reader{_reader};
57 auto result =
impl.try_parse(reader);
62 template <
typename Context>
65 impl.report_error(context, CaseFolding<Reader>{reader});
73 template <
typename Literal,
template <
typename>
typename CaseFolding>
80 template <
typename Reader>
87 using marker =
typename Reader::marker;
91 auto c =
_impl.peek();
92 if (encoding::to_int_type(
'A') <= c && c <= encoding::to_int_type(
'Z'))
93 return typename encoding::int_type(c + encoding::to_int_type(
'a' -
'A'));
105 return _impl.position();
110 return _impl.current();
123 template <
typename Encoding>
126 template <
typename Reader>
129 template <
typename Literal>
132 static_assert(lexy::is_literal_rule<Literal>);
133 static_assert(std::is_void_v<typename Literal::lit_case_folding>,
"cannot case fold twice");
145 template <
typename Reader>
158 auto c =
_impl.peek();
169 return _impl.position();
174 return _impl.current();
182 template <
typename Reader>
212 lexy::_detail::encode_code_point<encoding>(folded.value(),
_buffer, 4));
214 _impl.reset(result.end);
220 while (
_impl.position() != result.end.position())
235 return encoding::to_int_type(cur);
267 template <
typename Reader>
269 = std::conditional_t<std::is_same_v<typename Reader::encoding, lexy::utf32_encoding>,
272 template <
typename Reader>
283 template <
typename Encoding>
284 static constexpr
auto is_inplace = std::is_same_v<Encoding, lexy::utf32_encoding>;
286 template <
typename Reader>
289 template <
typename Literal>
292 static_assert(lexy::is_literal_rule<Literal>);
293 static_assert(std::is_void_v<typename Literal::lit_case_folding>,
"cannot case fold twice");
302 #endif // LEXY_DSL_CASE_FOLDING_HPP_INCLUDED
static constexpr auto lit_first_char() -> typename Encoding::char_type
constexpr marker current() const noexcept
LEXY_UNICODE_CONSTEXPR code_point simple_case_fold(code_point cp) noexcept
constexpr iterator position() const
static LEXY_CONSTEVAL std::size_t lit_insert(Trie &trie, std::size_t pos, std::size_t char_class)
encoding::char_type _buffer[4]
string_view::value_type char_type
static constexpr auto is_inplace
constexpr marker current() const noexcept
constexpr cp_result< Reader > parse_code_point(Reader reader)
static constexpr auto lit_char_classes
constexpr void report_error(Context &context, Reader reader)
constexpr auto peek() const -> typename encoding::int_type
constexpr _sucfr32(Reader impl)
constexpr bool try_parse(Reader _reader)
unsigned char _buffer_size
constexpr iterator position() const
std::conditional_t< std::is_same_v< typename Reader::encoding, lexy::utf32_encoding >, _sucfr32< Reader >, _sucfrm< Reader > > _sucfr_for
typename Reader::iterator iterator
constexpr void reset(marker m) noexcept
constexpr auto value() const noexcept
typename Reader::encoding encoding
constexpr iterator position() const
unsigned char _buffer_cur
constexpr marker current() const noexcept
typename Reader::marker marker
static constexpr auto lit_max_char_count
typename Reader::encoding encoding
constexpr auto simple_case_folding
Matches Literal with case insensitive Unicode characters (simple case folding).
constexpr auto peek() const -> typename encoding::int_type
constexpr void reset(marker m) noexcept
constexpr auto operator()(Literal) const
typename Reader::iterator iterator
typename Reader::marker marker
constexpr void reset(marker m) noexcept
constexpr auto peek() const -> typename encoding::int_type
constexpr auto case_folding
Matches Literal with case insensitive ASCII characters.
constexpr _sucfrm(Reader impl)
typename Reader::iterator iterator
typename Reader::encoding encoding
typename Reader::marker marker
lexy::token_parser_for< Literal, CaseFolding< Reader > > impl
constexpr tp(const Reader &reader)
typename TokenRule::template tp< Reader > token_parser_for
constexpr auto eof
Matches EOF.
static constexpr auto is_inplace
CaseFolding< Reader > reader
constexpr auto operator()(Literal) const