221 #ifndef CTRE_V2__CTRE_UNICODE__HPP
222 #define CTRE_V2__CTRE_UNICODE__HPP
224 #ifndef CTRE_V2__CTRE__HPP
225 #define CTRE_V2__CTRE__HPP
227 #ifndef CTRE_V2__CTRE__LITERALS__HPP
228 #define CTRE_V2__CTRE__LITERALS__HPP
230 #ifndef CTRE_V2__CTLL__HPP
231 #define CTRE_V2__CTLL__HPP
233 #ifndef CTLL__PARSER__HPP
234 #define CTLL__PARSER__HPP
236 #ifndef CTLL__FIXED_STRING__GPP
237 #define CTLL__FIXED_STRING__GPP
241 #include <string_view>
252 if ((first_unit & 0b1000'0000) == 0b0000'0000)
return {
static_cast<uint32_t>(first_unit), 1};
253 else if ((first_unit & 0b1110'0000) == 0b1100'0000)
return {
static_cast<uint32_t>(first_unit & 0b0001'1111), 2};
254 else if ((first_unit & 0b1111'0000) == 0b1110'0000)
return {
static_cast<uint32_t>(first_unit & 0b0000'1111), 3};
255 else if ((first_unit & 0b1111'1000) == 0b1111'0000)
return {
static_cast<uint32_t>(first_unit & 0b0000'0111), 4};
256 else if ((first_unit & 0b1111'1100) == 0b1111'1000)
return {
static_cast<uint32_t>(first_unit & 0b0000'0011), 5};
257 else if ((first_unit & 0b1111'1100) == 0b1111'1100)
return {
static_cast<uint32_t>(first_unit & 0b0000'0001), 6};
262 if ((unit & 0b1100'0000) == 0b1000'0000)
return unit & 0b0011'1111;
270 if ((first_unit & 0b1111110000000000) == 0b1101'1000'0000'0000)
return {
static_cast<uint32_t>(first_unit & 0b0000001111111111), 2};
271 else return {first_unit, 1};
279 if constexpr (std::is_same_v<T, char>) {
280 #ifdef CTRE_STRING_IS_UTF8
282 for (
size_t i{0};
i <
N; ++
i) {
283 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
285 switch (
info.length) {
311 for (
size_t i{0};
i <
N; ++
i) {
313 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
318 }
else if constexpr (std::is_same_v<T, char8_t>) {
320 for (
size_t i{0};
i <
N; ++
i) {
321 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
323 switch (
info.length) {
349 }
else if constexpr (std::is_same_v<T, char16_t>) {
351 for (
size_t i{0};
i <
N; ++
i) {
353 if (
info.length == 2) {
355 if ((
input[
i] & 0b1111'1100'0000'0000) == 0b1101'1100'0000'0000) {
363 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
368 }
else if constexpr (std::is_same_v<T, wchar_t> || std::is_same_v<T, char32_t>) {
369 for (
size_t i{0};
i <
N; ++
i) {
371 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
377 for (
size_t i{0};
i <
N; ++
i) {
399 if (
real_size != rhs.size())
return false;
405 constexpr
operator std::basic_string_view<char32_t>()
const noexcept {
406 return std::basic_string_view<char32_t>{
content,
size()};
411 static constexpr char32_t
empty[1] = {0};
437 constexpr
operator std::basic_string_view<char32_t>()
const noexcept {
438 return std::basic_string_view<char32_t>{
empty, 0};
449 #ifndef CTLL__TYPE_STACK__HPP
450 #define CTLL__TYPE_STACK__HPP
452 #ifndef CTLL__UTILITIES__HPP
453 #define CTLL__UTILITIES__HPP
455 #include <type_traits>
457 #if defined __cpp_nontype_template_parameter_class
458 #define CTLL_CNTTP_COMPILER_CHECK 1
459 #elif defined __cpp_nontype_template_args
461 #if __cpp_nontype_template_args >= 201911L
462 #define CTLL_CNTTP_COMPILER_CHECK 1
463 #elif __cpp_nontype_template_args >= 201411L
465 #if defined __apple_build_version__
466 #if defined __clang_major__ && __clang_major__ >= 13
468 #if __cplusplus > 201703L
469 #define CTLL_CNTTP_COMPILER_CHECK 1
474 #if defined __clang_major__ && __clang_major__ >= 12
476 #if __cplusplus > 201703L
477 #define CTLL_CNTTP_COMPILER_CHECK 1
484 #ifndef CTLL_CNTTP_COMPILER_CHECK
485 #define CTLL_CNTTP_COMPILER_CHECK 0
489 #define CTLL_FORCE_INLINE __forceinline
491 #define CTLL_FORCE_INLINE __attribute__((always_inline))
499 template <
typename A,
typename>
using type =
A;
503 template <
typename,
typename B>
using type =
B;
514 template <
typename... Ts>
struct list { };
521 template <
typename... Ts> constexpr
auto size(
list<Ts...>) noexcept {
return sizeof...(Ts); }
550 template <
typename T = _nothing> constexpr
auto front(
empty_list,
T =
T()) noexcept ->
T {
return {}; }
570 static constexpr
auto check(
T) {
return std::true_type{}; }
571 static constexpr
auto check(...) {
return std::false_type{}; }
584 return list<Ts...,
T>{};
590 return decltype((
list<>{} + ... + matcher.
select(Ts{}))){};
597 #ifndef CTLL__GRAMMARS__HPP
598 #define CTLL__GRAMMARS__HPP
603 template <auto v>
struct term {
617 template <
typename... Ts>
using push =
list<Ts...>;
620 struct accept { constexpr
explicit operator bool() noexcept {
return true; } };
621 struct reject { constexpr
explicit operator bool() noexcept {
return false; } };
653 template <auto A, decltype(A) B>
struct range {
654 constexpr
inline range() noexcept { }
656 template <auto V,
typename = std::enable_if_t<(A <= V) && (V <= B)>> constexpr inline range(term<V>) noexcept;
660 template <auto V, auto... Set>
struct contains {
661 static constexpr
bool value = ((Set == V) || ... ||
false);
666 template <
auto... Def>
struct set {
667 constexpr
inline set() noexcept { }
669 template <
auto V,
typename = std::enable_if_t<contains<V, Def...>
::value>> constexpr
inline set(
term<V>) noexcept;
671 template <
auto V,
typename = std::enable_if_t<((Def == V) || ... ||
false)>> constexpr
inline set(
term<V>) noexcept;
680 template <
auto V,
typename = std::enable_if_t<!contains<V, Def...>
::value>> constexpr
inline neg_set(
term<V>) noexcept;
682 template <
auto V,
typename = std::enable_if_t<!((Def == V) || ... ||
false)>> constexpr
inline neg_set(
term<V>) noexcept;
689 using typename Grammar::_start;
698 template <
typename Expected, auto V>
static constexpr
auto rule(Expected,
term<V>) -> std::enable_if_t<std::is_constructible_v<Expected, term<V>>,
ctll::pop_input>;
714 #ifndef CTLL__ACTIONS__HPP
715 #define CTLL__ACTIONS__HPP
722 template <
typename Action,
typename InputSymbol,
typename Subject>
static constexpr
auto apply(Action, InputSymbol, Subject
subject) {
727 template <
typename Actions>
struct identity:
public Actions {
728 using Actions::apply;
735 using Actions::apply;
737 template <
typename Action, auto V,
typename Subject> constexpr
static auto apply(Action,
term<V>, Subject) -> Subject {
return {}; }
738 template <
typename Action,
typename Subject> constexpr
static auto apply(Action,
epsilon, Subject) -> Subject {
return {}; }
758 #if CTLL_CNTTP_COMPILER_CHECK
759 template <
typename Grammar, ctll::fixed_
string input,
typename ActionSelector = empty_actions,
bool IgnoreUnknownActions = false>
struct parser {
761 template <
typename Grammar, const auto & input,
typename ActionSelector = empty_actions,
bool IgnoreUnknownActions = false>
struct parser {
765 #if CTLL_CNTTP_COMPILER_CHECK
777 template <
size_t Pos,
typename Stack,
typename Subject, decision Decision>
struct results {
786 #if CTLL_CNTTP_COMPILER_CHECK
796 static constexpr
size_t position =
Pos;
824 if constexpr (
Pos == 0) {
827 }
else if constexpr ((
Pos-1) <
input.size()) {
839 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
844 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
849 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
854 template <
size_t Pos,
typename... Content,
typename Terminal,
typename Stack,
typename Subject>
859 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
861 return decide<Pos>(stack,
subject);
865 template <
size_t Pos,
auto V,
typename... Content,
typename Stack,
typename Subject>
867 constexpr
auto local_input =
input;
872 template <
size_t Pos,
auto V,
typename... Content,
auto T,
typename Stack,
typename Subject>
874 constexpr
auto local_input =
input;
878 template <
size_t Pos,
typename Stack,
typename Subject>
static constexpr
auto decide(Stack previous_stack, Subject previous_subject) noexcept {
882 [[maybe_unused]]
auto stack = decltype(
ctll::pop_front(previous_stack))();
885 if constexpr (std::is_base_of_v<
ctll::action, decltype(top_symbol)>) {
886 auto subject = Actions::apply(top_symbol, get_previous_term<Pos>(), previous_subject);
892 return decide<Pos>(stack,
subject);
896 auto current_term = get_current_term<Pos>();
897 auto rule = decltype(
grammar::rule(top_symbol,current_term))();
898 return move<Pos>(rule, current_term, stack, previous_subject);
903 template <
typename Subject,
size_t...
Pos>
static constexpr
auto trampoline_decide(Subject, std::index_sequence<Pos...>) noexcept {
915 template <
typename Subject = empty_subject>
using output = decltype(trampoline_decide<Subject>());
916 template <
typename Subject = empty_subject>
static inline constexpr
bool correct_with = trampoline_decide<Subject>();
926 #ifndef CTRE__PCRE_ACTIONS__HPP
927 #define CTRE__PCRE_ACTIONS__HPP
929 #ifndef CTRE__PCRE__HPP
930 #define CTRE__PCRE__HPP
942 struct backslash_range {};
944 struct block_name2 {};
946 struct class_named_name {};
949 struct content_in_capture {};
955 struct hexdec_repeat {};
962 struct mode_switch2 {};
968 struct property_name2 {};
969 struct property_name {};
970 struct property_value2 {};
971 struct property_value {};
974 struct s {};
using _start = s;
1032 struct push_assert_subject_end_with_lineend:
ctll::action {};
1040 struct push_character_return_carriage:
ctll::action {};
1067 using _others =
ctll::neg_set<
'!',
'$',
'\x28',
'\x29',
'*',
'+',
',',
'-',
'.',
'/',
':',
'<',
'=',
'>',
'?',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'[',
'\\',
'0',
'\"',
']',
'^',
'_',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'\x7B',
'|',
'\x7D',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>;
1073 static constexpr
auto rule(s,
ctll::set<
'!',
',',
'/',
':',
'<',
'0',
'-',
'=',
'>',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'\"',
']',
'_',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>) ->
ctll::push<ctll::anything, push_character, repeat, string2, content2>;
1085 static constexpr
auto rule(
a,
ctll::set<
'!',
',',
'/',
':',
'<',
'0',
'-',
'=',
'>',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'\"',
']',
'_',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>) ->
ctll::push<ctll::anything, push_character, repeat, string2, content2, make_alternate>;
1106 static constexpr
auto rule(backslash,
ctll::set<'1','2','3','4','5','6','7','8','9'>) ->
ctll::push<ctll::anything, create_number, make_back_reference>;
1115 static constexpr
auto rule(backslash,
ctll::set<
'$',
'\x28',
'\x29',
'*',
'+',
'-',
'.',
'/',
'<',
'>',
'?',
'[',
'\\',
'\"',
']',
'^',
'\x7B',
'|',
'\x7D'>) ->
ctll::push<ctll::anything, push_character>;
1128 static constexpr
auto rule(backslash_range,
ctll::set<
'$',
'\x28',
'\x29',
'*',
'+',
'-',
'.',
'/',
'<',
'>',
'?',
'[',
'\\',
'\"',
']',
'^',
'\x7B',
'|',
'\x7D'>) ->
ctll::push<ctll::anything, push_character>;
1143 static constexpr
auto rule(block,
ctll::set<
'!',
',',
'/',
':',
'<',
'0',
'-',
'=',
'>',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'\"',
']',
'_',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>) ->
ctll::push<ctll::anything, push_character, repeat, string2, content2, make_capture, ctll::term<'\x29'>>;
1150 static constexpr
auto rule(block_name2,
ctll::set<'>','\x7D
'>) -> ctll::epsilon;
1151 static constexpr auto rule(block_name2, ctll::set<'0
','A','B','C','D','E','F','G','H','I
','J','K
','L
','M','N','O
','P','Q
','R','S','T','U','V
','W','X
','Y
','Z','_','a','b','c
','d
','e
','f','g','h
','i','j
','k
','l','m
','n','o
','p
','q
','r','s
','t','u
','v
','w
','x
','y
','z
','1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>) ->
ctll::push<ctll::anything, push_name, block_name2>;
1155 static constexpr
auto rule(c,
ctll::set<
'!',
'0',
'$',
'\x28',
'\x29',
'*',
'+',
',',
'.',
'/',
':',
'<',
'=',
'>',
'?',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'\"',
'_',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'\x7B',
'|',
'\x7D',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>) ->
ctll::push<ctll::anything, push_character, range, set_start, set2b, set_make, ctll::term<']'>>;
1181 static constexpr
auto rule(content,
ctll::set<
'!',
',',
'/',
':',
'<',
'0',
'-',
'=',
'>',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'\"',
']',
'_',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>) ->
ctll::push<ctll::anything, push_character, repeat, string2, content2>;
1191 static constexpr
auto rule(content_in_capture,
ctll::set<
'!',
',',
'/',
':',
'<',
'0',
'-',
'=',
'>',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'\"',
']',
'_',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'>) ->
ctll::push<ctll::anything, push_character, repeat, string2, content2>;
1204 static constexpr
auto rule(d,
ctll::term<'>'>) -> ctll::push<ctll::anything, reset_capture, start_atomic, content_in_capture, make_atomic, ctll::term<'\x29
'>>;
1205 static constexpr auto rule(d, ctll::term<'!
'>) -> ctll::push<ctll::anything, reset_capture, start_lookahead_negative, content_in_capture, look_finish, ctll::term<'\x29
'>>;
1206 static constexpr auto rule(d, ctll::term<'=
'>) -> ctll::push<ctll::anything, reset_capture, start_lookahead_positive, content_in_capture, look_finish, ctll::term<'\x29
'>>;
1208 static constexpr auto rule(e, ctll::term<'d
'>) -> ctll::push<ctll::anything, class_digit>;
1209 static constexpr auto rule(e, ctll::term<'h
'>) -> ctll::push<ctll::anything, class_horizontal_space>;
1210 static constexpr auto rule(e, ctll::term<'H'>) -> ctll::push<ctll::anything, class_non_horizontal_space>;
1211 static constexpr auto rule(e, ctll::term<'V
'>) -> ctll::push<ctll::anything, class_non_vertical_space>;
1212 static constexpr auto rule(e, ctll::term<'D'>) -> ctll::push<ctll::anything, class_nondigit>;
1213 static constexpr auto rule(e, ctll::term<'N'>) -> ctll::push<ctll::anything, class_nonnewline>;
1214 static constexpr auto rule(e, ctll::term<'S'>) -> ctll::push<ctll::anything, class_nonspace>;
1215 static constexpr auto rule(e, ctll::term<'W'>) -> ctll::push<ctll::anything, class_nonword>;
1216 static constexpr auto rule(e, ctll::term<'s
'>) -> ctll::push<ctll::anything, class_space>;
1217 static constexpr auto rule(e, ctll::term<'v
'>) -> ctll::push<ctll::anything, class_vertical_space>;
1218 static constexpr auto rule(e, ctll::term<'w
'>) -> ctll::push<ctll::anything, class_word>;
1219 static constexpr auto rule(e, ctll::term<'p
'>) -> ctll::push<ctll::anything, ctll::term<'\x7B
'>, property_name, ctll::term<'\x7D
'>, make_property>;
1220 static constexpr auto rule(e, ctll::term<'P'>) -> ctll::push<ctll::anything, ctll::term<'\x7B
'>, property_name, ctll::term<'\x7D
'>, make_property_negative>;
1221 static constexpr auto rule(e, ctll::term<'u
'>) -> ctll::push<ctll::anything, k, range>;
1222 static constexpr auto rule(e, ctll::term<'x
'>) -> ctll::push<ctll::anything, l, range>;
1223 static constexpr auto rule(e, ctll::set<'$
','\x28
','\x29
','*
','+
','-
','.
','/
','<
','>
','?
','[
','\\
','\
"',']','^','\x7B','|','\x7D'>) -> ctll::push<ctll::anything, push_character, range>;
1224 static constexpr auto rule(e, ctll::term<'a'>) -> ctll::push<ctll::anything, push_character_alarm, range>;
1225 static constexpr auto rule(e, ctll::term<'e'>) -> ctll::push<ctll::anything, push_character_escape, range>;
1226 static constexpr auto rule(e, ctll::term<'f'>) -> ctll::push<ctll::anything, push_character_formfeed, range>;
1227 static constexpr auto rule(e, ctll::term<'n'>) -> ctll::push<ctll::anything, push_character_newline, range>;
1228 static constexpr auto rule(e, ctll::term<'0'>) -> ctll::push<ctll::anything, push_character_null, range>;
1229 static constexpr auto rule(e, ctll::term<'r'>) -> ctll::push<ctll::anything, push_character_return_carriage, range>;
1230 static constexpr auto rule(e, ctll::term<'t'>) -> ctll::push<ctll::anything, push_character_tab, range>;
1232 static constexpr auto rule(f, ctll::term<'d'>) -> ctll::push<ctll::anything, class_digit>;
1233 static constexpr auto rule(f, ctll::term<'h'>) -> ctll::push<ctll::anything, class_horizontal_space>;
1234 static constexpr auto rule(f, ctll::term<'H'>) -> ctll::push<ctll::anything, class_non_horizontal_space>;
1235 static constexpr auto rule(f, ctll::term<'V'>) -> ctll::push<ctll::anything, class_non_vertical_space>;
1236 static constexpr auto rule(f, ctll::term<'D'>) -> ctll::push<ctll::anything, class_nondigit>;
1237 static constexpr auto rule(f, ctll::term<'N'>) -> ctll::push<ctll::anything, class_nonnewline>;
1238 static constexpr auto rule(f, ctll::term<'S'>) -> ctll::push<ctll::anything, class_nonspace>;
1239 static constexpr auto rule(f, ctll::term<'W'>) -> ctll::push<ctll::anything, class_nonword>;
1240 static constexpr auto rule(f, ctll::term<'s'>) -> ctll::push<ctll::anything, class_space>;
1241 static constexpr auto rule(f, ctll::term<'v'>) -> ctll::push<ctll::anything, class_vertical_space>;
1242 static constexpr auto rule(f, ctll::term<'w'>) -> ctll::push<ctll::anything, class_word>;
1243 static constexpr auto rule(f, ctll::term<'p'>) -> ctll::push<ctll::anything, ctll::term<'\x7B'>, property_name, ctll::term<'\x7D'>, make_property>;
1244 static constexpr auto rule(f, ctll::term<'P'>) -> ctll::push<ctll::anything, ctll::term<'\x7B'>, property_name, ctll::term<'\x7D'>, make_property_negative>;
1245 static constexpr auto rule(f, ctll::term<'u'>) -> ctll::push<ctll::anything, k, range>;
1246 static constexpr auto rule(f, ctll::term<'x'>) -> ctll::push<ctll::anything, l, range>;
1247 static constexpr auto rule(f, ctll::set<'$','\x28','\x29','*','+','-','.','/','<','>','?','[','\\','\"',']','^','\x7B','|','\x7D'>) -> ctll::push<ctll::anything, push_character, range>;
1248 static constexpr auto rule(f, ctll::term<'a'>) -> ctll::push<ctll::anything, push_character_alarm, range>;
1249 static constexpr auto rule(f, ctll::term<'e'>) -> ctll::push<ctll::anything, push_character_escape, range>;
1250 static constexpr auto rule(f, ctll::term<'f'>) -> ctll::push<ctll::anything, push_character_formfeed, range>;
1251 static constexpr auto rule(f, ctll::term<'n'>) -> ctll::push<ctll::anything, push_character_newline, range>;
1252 static constexpr auto rule(f, ctll::term<'0'>) -> ctll::push<ctll::anything, push_character_null, range>;
1253 static constexpr auto rule(f, ctll::term<'r'>) -> ctll::push<ctll::anything, push_character_return_carriage, range>;
1254 static constexpr auto rule(f, ctll::term<'t'>) -> ctll::push<ctll::anything, push_character_tab, range>;
1256 static constexpr auto rule(g, ctll::term<'s'>) -> ctll::push<ctll::anything, ctll::term<'c'>, ctll::term<'i'>, ctll::term<'i'>, class_named_ascii>;
1257 static constexpr auto rule(g, ctll::term<'l'>) -> ctll::push<ctll::anything, p>;
1259 static constexpr auto rule(h, ctll::term<'r'>) -> ctll::push<ctll::anything, ctll::term<'i'>, ctll::term<'n'>, ctll::term<'t'>, class_named_print>;
1260 static constexpr auto rule(h, ctll::term<'u'>) -> ctll::push<ctll::anything, ctll::term<'n'>, ctll::term<'c'>, ctll::term<'t'>, class_named_punct>;
1262 static constexpr auto rule(hexdec_repeat, ctll::term<'\x7D'>) -> ctll::epsilon;
1263 static constexpr auto rule(hexdec_repeat, ctll::set<'0','A','B','C','D','E','F','a','b','c','d','e','f','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_hexdec, hexdec_repeat>;
1265 static constexpr auto rule(i, ctll::term<'^'>) -> ctll::push<ctll::anything, class_named_name, negate_class_named, ctll::term<':'>, ctll::term<']'>>;
1266 static constexpr auto rule(i, ctll::term<'x'>) -> ctll::push<ctll::anything, ctll::term<'d'>, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_xdigit, ctll::term<':'>, ctll::term<']'>>;
1267 static constexpr auto rule(i, ctll::term<'d'>) -> ctll::push<ctll::anything, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_digit, ctll::term<':'>, ctll::term<']'>>;
1268 static constexpr auto rule(i, ctll::term<'b'>) -> ctll::push<ctll::anything, ctll::term<'l'>, ctll::term<'a'>, ctll::term<'n'>, ctll::term<'k'>, class_named_blank, ctll::term<':'>, ctll::term<']'>>;
1269 static constexpr auto rule(i, ctll::term<'c'>) -> ctll::push<ctll::anything, ctll::term<'n'>, ctll::term<'t'>, ctll::term<'r'>, ctll::term<'l'>, class_named_cntrl, ctll::term<':'>, ctll::term<']'>>;
1270 static constexpr auto rule(i, ctll::term<'w'>) -> ctll::push<ctll::anything, ctll::term<'o'>, ctll::term<'r'>, ctll::term<'d'>, class_named_word, ctll::term<':'>, ctll::term<']'>>;
1271 static constexpr auto rule(i, ctll::term<'l'>) -> ctll::push<ctll::anything, ctll::term<'o'>, ctll::term<'w'>, ctll::term<'e'>, ctll::term<'r'>, class_named_lower, ctll::term<':'>, ctll::term<']'>>;
1272 static constexpr auto rule(i, ctll::term<'s'>) -> ctll::push<ctll::anything, ctll::term<'p'>, ctll::term<'a'>, ctll::term<'c'>, ctll::term<'e'>, class_named_space, ctll::term<':'>, ctll::term<']'>>;
1273 static constexpr auto rule(i, ctll::term<'u'>) -> ctll::push<ctll::anything, ctll::term<'p'>, ctll::term<'p'>, ctll::term<'e'>, ctll::term<'r'>, class_named_upper, ctll::term<':'>, ctll::term<']'>>;
1274 static constexpr auto rule(i, ctll::term<'g'>) -> ctll::push<ctll::anything, ctll::term<'r'>, ctll::term<'a'>, ctll::term<'p'>, ctll::term<'h'>, class_named_graph, ctll::term<':'>, ctll::term<']'>>;
1275 static constexpr auto rule(i, ctll::term<'a'>) -> ctll::push<ctll::anything, g, ctll::term<':'>, ctll::term<']'>>;
1276 static constexpr auto rule(i, ctll::term<'p'>) -> ctll::push<ctll::anything, h, ctll::term<':'>, ctll::term<']'>>;
1278 static constexpr auto rule(j, ctll::term<'\\'>) -> ctll::push<ctll::anything, backslash_range, make_range>;
1279 static constexpr auto rule(j, ctll::set<'!','$','\x28','\x29','*','+',',','.','/',':','<','=','>','?','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\"','^','0','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\x7B','|','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_character, make_range>;
1280 static constexpr auto rule(j, _others) -> ctll::push<ctll::anything, push_character, make_range>;
1281 static constexpr auto rule(j, ctll::set<'-','[',']'>) -> ctll::reject;
1283 static constexpr auto rule(k, ctll::term<'\x7B'>) -> ctll::push<create_hexdec, ctll::anything, ctll::set<'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','a','b','c','d','e','f'>, push_hexdec, hexdec_repeat, ctll::term<'\x7D'>, finish_hexdec>;
1284 static constexpr auto rule(k, ctll::set<'0','A','B','C','D','E','F','a','b','c','d','e','f','1','2','3','4','5','6','7','8','9'>) -> ctll::push<create_hexdec, ctll::anything, push_hexdec, ctll::set<'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','a','b','c','d','e','f'>, push_hexdec, ctll::set<'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','a','b','c','d','e','f'>, push_hexdec, ctll::set<'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','a','b','c','d','e','f'>, push_hexdec, finish_hexdec>;
1286 static constexpr auto rule(l, ctll::term<'\x7B'>) -> ctll::push<create_hexdec, ctll::anything, ctll::set<'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','a','b','c','d','e','f'>, push_hexdec, hexdec_repeat, ctll::term<'\x7D'>, finish_hexdec>;
1287 static constexpr auto rule(l, ctll::set<'0','A','B','C','D','E','F','a','b','c','d','e','f','1','2','3','4','5','6','7','8','9'>) -> ctll::push<create_hexdec, ctll::anything, push_hexdec, ctll::set<'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','a','b','c','d','e','f'>, push_hexdec, finish_hexdec>;
1289 static constexpr auto rule(m, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, create_number, number2, ctll::term<'\x7D'>, make_back_reference>;
1290 static constexpr auto rule(m, ctll::term<'-'>) -> ctll::push<ctll::anything, number, ctll::term<'\x7D'>, make_relative_back_reference>;
1291 static constexpr auto rule(m, ctll::set<'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'>) -> ctll::push<ctll::anything, push_name, block_name2, ctll::term<'\x7D'>, make_back_reference>;
1293 static constexpr auto rule(mod, ctll::set<'!','$','\x28','\x29',',','-','.','/','0',':','<','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\','\"',']','^','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','|','1','2','3','4','5','6','7','8','9'>) -> ctll::epsilon;
1294 static constexpr auto rule(mod, ctll::epsilon) -> ctll::epsilon;
1295 static constexpr auto rule(mod, _others) -> ctll::epsilon;
1296 static constexpr auto rule(mod, ctll::term<'?'>) -> ctll::push<ctll::anything, make_lazy>;
1297 static constexpr auto rule(mod, ctll::term<'+'>) -> ctll::push<ctll::anything, make_possessive>;
1298 static constexpr auto rule(mod, ctll::set<'*','\x7B','\x7D'>) -> ctll::reject;
1300 static constexpr auto rule(mode_switch2, ctll::term<'i'>) -> ctll::push<ctll::anything, mode_case_insensitive, mode_switch2>;
1301 static constexpr auto rule(mode_switch2, ctll::term<'c'>) -> ctll::push<ctll::anything, mode_case_sensitive, mode_switch2>;
1302 static constexpr auto rule(mode_switch2, ctll::term<'m'>) -> ctll::push<ctll::anything, mode_multiline, mode_switch2>;
1303 static constexpr auto rule(mode_switch2, ctll::term<'s'>) -> ctll::push<ctll::anything, mode_singleline, mode_switch2>;
1304 static constexpr auto rule(mode_switch2, ctll::term<'\x29'>) -> ctll::push<ctll::anything>;
1306 static constexpr auto rule(n, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, create_number, number2, repeat_ab, ctll::term<'\x7D'>, mod>;
1307 static constexpr auto rule(n, ctll::term<'\x7D'>) -> ctll::push<repeat_at_least, ctll::anything, mod>;
1309 static constexpr auto rule(number2, ctll::set<',','\x7D'>) -> ctll::epsilon;
1310 static constexpr auto rule(number2, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_number, number2>;
1312 static constexpr auto rule(number, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, create_number, number2>;
1314 static constexpr auto rule(o, ctll::set<'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'>) -> ctll::push<ctll::anything, push_name, block_name2, ctll::term<'>'>, content_in_capture, make_capture_with_name, ctll::term<'\x29'>>;
1315 static constexpr auto rule(o, ctll::term<'!'>) -> ctll::push<ctll::anything, reset_capture, start_lookbehind_negative, content_in_capture, look_finish, ctll::term<'\x29'>>;
1316 static constexpr auto rule(o, ctll::term<'='>) -> ctll::push<ctll::anything, reset_capture, start_lookbehind_positive, content_in_capture, look_finish, ctll::term<'\x29'>>;
1318 static constexpr auto rule(p, ctll::term<'p'>) -> ctll::push<ctll::anything, ctll::term<'h'>, ctll::term<'a'>, class_named_alpha>;
1319 static constexpr auto rule(p, ctll::term<'n'>) -> ctll::push<ctll::anything, ctll::term<'u'>, ctll::term<'m'>, class_named_alnum>;
1321 static constexpr auto rule(property_name2, ctll::term<'\x7D'>) -> ctll::epsilon;
1322 static constexpr auto rule(property_name2, ctll::term<'='>) -> ctll::push<ctll::anything, property_value>;
1323 static constexpr auto rule(property_name2, ctll::set<'0','.','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_property_name, property_name2>;
1325 static constexpr auto rule(property_name, ctll::set<'0','.','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_property_name, property_name2>;
1327 static constexpr auto rule(property_value2, ctll::term<'\x7D'>) -> ctll::epsilon;
1328 static constexpr auto rule(property_value2, ctll::set<'0','.','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_property_value, property_value2>;
1330 static constexpr auto rule(property_value, ctll::set<'0','.','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_property_value, property_value2>;
1332 static constexpr auto rule(range, ctll::set<'!','$','\x28','\x29','*','+',',','.','/','0',':','<','=','>','?','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\','\"',']','^','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\x7B','|','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::epsilon;
1333 static constexpr auto rule(range, ctll::epsilon) -> ctll::epsilon;
1334 static constexpr auto rule(range, _others) -> ctll::epsilon;
1335 static constexpr auto rule(range, ctll::term<'-'>) -> ctll::push<ctll::anything, j>;
1337 static constexpr auto rule(repeat, ctll::set<'!','$','\x28','\x29',',','-','.','/','0',':','<','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\','\"',']','^','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','|','1','2','3','4','5','6','7','8','9'>) -> ctll::epsilon;
1338 static constexpr auto rule(repeat, ctll::epsilon) -> ctll::epsilon;
1339 static constexpr auto rule(repeat, _others) -> ctll::epsilon;
1340 static constexpr auto rule(repeat, ctll::term<'?'>) -> ctll::push<ctll::anything, make_optional, mod>;
1341 static constexpr auto rule(repeat, ctll::term<'\x7B'>) -> ctll::push<ctll::anything, number, b>;
1342 static constexpr auto rule(repeat, ctll::term<'+'>) -> ctll::push<ctll::anything, repeat_plus, mod>;
1343 static constexpr auto rule(repeat, ctll::term<'*'>) -> ctll::push<ctll::anything, repeat_star, mod>;
1344 static constexpr auto rule(repeat, ctll::term<'\x7D'>) -> ctll::reject;
1346 static constexpr auto rule(set2a, ctll::term<']'>) -> ctll::epsilon;
1347 static constexpr auto rule(set2a, ctll::term<'['>) -> ctll::push<ctll::anything, ctll::term<':'>, i, range, set_start, set2b>;
1348 static constexpr auto rule(set2a, ctll::term<'\\'>) -> ctll::push<ctll::anything, f, set_start, set2b>;
1349 static constexpr auto rule(set2a, ctll::set<'!','$','\x28','\x29','*','+',',','.','/',':','<','=','>','?','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\"','^','0','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\x7B','|','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_character, range, set_start, set2b>;
1350 static constexpr auto rule(set2a, _others) -> ctll::push<ctll::anything, push_character, range, set_start, set2b>;
1351 static constexpr auto rule(set2a, ctll::term<'-'>) -> ctll::reject;
1353 static constexpr auto rule(set2b, ctll::term<']'>) -> ctll::epsilon;
1354 static constexpr auto rule(set2b, ctll::term<'['>) -> ctll::push<ctll::anything, ctll::term<':'>, i, range, set_combine, set2b>;
1355 static constexpr auto rule(set2b, ctll::term<'\\'>) -> ctll::push<ctll::anything, f, set_combine, set2b>;
1356 static constexpr auto rule(set2b, ctll::set<'!','$','\x28','\x29','*','+',',','.','/',':','<','=','>','?','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\"','^','0','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\x7B','|','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_character, range, set_combine, set2b>;
1357 static constexpr auto rule(set2b, _others) -> ctll::push<ctll::anything, push_character, range, set_combine, set2b>;
1358 static constexpr auto rule(set2b, ctll::term<'-'>) -> ctll::reject;
1360 static constexpr auto rule(string2, ctll::set<'\x29','|'>) -> ctll::epsilon;
1361 static constexpr auto rule(string2, ctll::epsilon) -> ctll::epsilon;
1362 static constexpr auto rule(string2, ctll::term<'\\'>) -> ctll::push<ctll::anything, backslash, repeat, string2, make_sequence>;
1363 static constexpr auto rule(string2, ctll::term<'['>) -> ctll::push<ctll::anything, c, repeat, string2, make_sequence>;
1364 static constexpr auto rule(string2, ctll::term<'\x28'>) -> ctll::push<ctll::anything, prepare_capture, block, repeat, string2, make_sequence>;
1365 static constexpr auto rule(string2, ctll::term<'^'>) -> ctll::push<ctll::anything, push_assert_begin, repeat, string2, make_sequence>;
1366 static constexpr auto rule(string2, ctll::term<'$'>) -> ctll::push<ctll::anything, push_assert_end, repeat, string2, make_sequence>;
1367 static constexpr auto rule(string2, ctll::set<'!',',','/',':','<','0','-','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\"',']','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_character, repeat, string2, make_sequence>;
1368 static constexpr auto rule(string2, _others) -> ctll::push<ctll::anything, push_character, repeat, string2, make_sequence>;
1369 static constexpr auto rule(string2, ctll::term<'.'>) -> ctll::push<ctll::anything, push_character_anything, repeat, string2, make_sequence>;
1370 static constexpr auto rule(string2, ctll::set<'*','+','?','\x7B','\x7D'>) -> ctll::reject;
1376 #endif //CTRE__PCRE__HPP
1378 #ifndef CTRE__ROTATE__HPP
1379 #define CTRE__ROTATE__HPP
1381 #ifndef CTRE__ATOMS__HPP
1382 #define CTRE__ATOMS__HPP
1384 #ifndef CTRE__ATOMS_CHARACTERS__HPP
1385 #define CTRE__ATOMS_CHARACTERS__HPP
1387 #ifndef CTRE__UTILITY__HPP
1388 #define CTRE__UTILITY__HPP
1390 #define CTRE_CNTTP_COMPILER_CHECK CTLL_CNTTP_COMPILER_CHECK
1393 #if __has_cpp_attribute(likely)
1394 #define CTRE_LIKELY [[likely]]
1399 #if __has_cpp_attribute(unlikely)
1400 #define CTRE_UNLIKELY [[unlikely]]
1402 #define CTRE_UNLIKELY
1406 #define CTRE_UNLIKELY
1410 #define CTRE_FORCE_INLINE __forceinline
1411 #if _MSC_VER >= 1930
1412 #define CTRE_FLATTEN [[msvc::flatten]]
1414 #define CTRE_FLATTEN
1417 #define CTRE_FORCE_INLINE inline __attribute__((always_inline))
1418 #define CTRE_FLATTEN __attribute__((flatten))
1423 #ifndef CTRE_V2__CTRE__FLAGS_AND_MODES__HPP
1424 #define CTRE_V2__CTRE__FLAGS_AND_MODES__HPP
1428 struct singleline { };
1429 struct multiline { };
1431 struct case_sensitive { };
1432 struct case_insensitive { };
1434 using ci = case_insensitive;
1435 using cs = case_sensitive;
1437 template <typename... Flags> struct flag_list { };
1440 bool block_empty_match = false;
1441 bool multiline = false;
1442 bool case_insensitive = false;
1444 constexpr flags() = default;
1445 constexpr flags(const flags &) = default;
1446 constexpr flags(flags &&) = default;
1448 constexpr CTRE_FORCE_INLINE flags(ctre::singleline v) noexcept { set_flag(v); }
1449 constexpr CTRE_FORCE_INLINE flags(ctre::multiline v) noexcept { set_flag(v); }
1450 constexpr CTRE_FORCE_INLINE flags(ctre::case_sensitive v) noexcept { set_flag(v); }
1451 constexpr CTRE_FORCE_INLINE flags(ctre::case_insensitive v) noexcept { set_flag(v); }
1454 template <typename... Args> constexpr CTRE_FORCE_INLINE flags(ctll::list<Args...>) noexcept {
1455 (this->set_flag(Args{}), ...);
1458 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_case_insensitive) noexcept {
1459 f.case_insensitive = true;
1463 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_case_sensitive) noexcept {
1464 f.case_insensitive = false;
1468 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_singleline) noexcept {
1469 f.multiline = false;
1473 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_multiline) noexcept {
1478 constexpr CTRE_FORCE_INLINE void set_flag(ctre::singleline) noexcept {
1482 constexpr CTRE_FORCE_INLINE void set_flag(ctre::multiline) noexcept {
1486 constexpr CTRE_FORCE_INLINE void set_flag(ctre::case_insensitive) noexcept {
1487 case_insensitive = true;
1490 constexpr CTRE_FORCE_INLINE void set_flag(ctre::case_sensitive) noexcept {
1491 case_insensitive = false;
1495 constexpr CTRE_FORCE_INLINE auto not_empty_match(flags f) {
1496 f.block_empty_match = true;
1500 constexpr CTRE_FORCE_INLINE auto consumed_something(flags f, bool condition = true) {
1501 if (condition) f.block_empty_match = false;
1505 constexpr CTRE_FORCE_INLINE bool cannot_be_empty_match(flags f) {
1506 return f.block_empty_match;
1509 constexpr CTRE_FORCE_INLINE bool multiline_mode(flags f) {
1513 constexpr CTRE_FORCE_INLINE bool is_case_insensitive(flags f) {
1514 return f.case_insensitive;
1524 // sfinae check for types here
1526 template <typename T> class MatchesCharacter {
1527 template <typename Y, typename CharT> static auto test(CharT c) -> decltype(Y::match_char(c, std::declval<const flags &>()), std::true_type());
1528 template <typename> static auto test(...) -> std::false_type;
1530 template <typename CharT> static inline constexpr bool value = decltype(test<T>(std::declval<CharT>()))();
1533 template <typename T> constexpr CTRE_FORCE_INLINE bool is_ascii_alpha(T v) {
1534 return ((v >= static_cast<T>('a') && v <= static_cast<T>('z')) || (v >= static_cast<T>('A') && v <= static_cast<T>('Z')));
1537 template <typename T> constexpr CTRE_FORCE_INLINE bool is_ascii_alpha_lowercase(T v) {
1538 return (v >= static_cast<T>('a')) && (v <= static_cast<T>('z'));
1541 template <typename T> constexpr CTRE_FORCE_INLINE bool is_ascii_alpha_uppercase(T v) {
1542 return (v >= static_cast<T>('A')) && v <= (static_cast<T>('Z'));
1545 template <auto V> struct character {
1546 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1547 if constexpr (is_ascii_alpha(V)) {
1548 if (is_case_insensitive(f)) {
1549 if (value == (V ^ static_cast<decltype(V)>(0x20))) {
1558 template <typename... Content> struct negative_set {
1559 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1560 return !(Content::match_char(value, f) || ... || false);
1564 template <typename... Content> struct set {
1565 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1566 return (Content::match_char(value, f) || ... || false);
1570 template <auto... Cs> struct enumeration : set<character<Cs>...> { };
1572 template <typename... Content> struct negate {
1573 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1574 return !(Content::match_char(value, f) || ... || false);
1578 template <auto A, auto B> struct char_range {
1579 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1580 if constexpr (is_ascii_alpha_lowercase(A) && is_ascii_alpha_lowercase(B)) {
1581 if (is_case_insensitive(f)) {
1582 if (value >= (A ^ static_cast<decltype(A)>(0x20)) && value <= (B ^ static_cast<decltype(B)>(0x20))) {
1586 } else if constexpr (is_ascii_alpha_uppercase(A) && is_ascii_alpha_uppercase(B)) {
1587 if (is_case_insensitive(f)) {
1588 if (value >= (A ^ static_cast<decltype(A)>(0x20)) && value <= (B ^ static_cast<decltype(B)>(0x20))) {
1593 return (value >= A) && (value <= B);
1596 using word_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'>, character<'_'> >;
1598 using space_chars = enumeration<' ', '\t', '\n', '\v', '\f', '\r'>;
1600 using vertical_space_chars = enumeration<
1601 char{0x000A}, // Linefeed (LF)
1602 char{0x000B}, // Vertical tab (VT)
1603 char{0x000C}, // Form feed (FF)
1604 char{0x000D}, // Carriage return (CR)
1605 char32_t{0x0085}, // Next line (NEL)
1606 char32_t{0x2028}, // Line separator
1607 char32_t{0x2029} // Paragraph separator
1610 using horizontal_space_chars = enumeration<
1611 char{0x0009}, // Horizontal tab (HT)
1612 char{0x0020}, // Space
1613 char32_t{0x00A0}, // Non-break space
1614 char32_t{0x1680}, // Ogham space mark
1615 char32_t{0x180E}, // Mongolian vowel separator
1616 char32_t{0x2000}, // En quad
1617 char32_t{0x2001}, // Em quad
1618 char32_t{0x2002}, // En space
1619 char32_t{0x2003}, // Em space
1620 char32_t{0x2004}, // Three-per-em space
1621 char32_t{0x2005}, // Four-per-em space
1622 char32_t{0x2006}, // Six-per-em space
1623 char32_t{0x2007}, // Figure space
1624 char32_t{0x2008}, // Punctuation space
1625 char32_t{0x2009}, // Thin space
1626 char32_t{0x200A}, // Hair space
1627 char32_t{0x202F}, // Narrow no-break space
1628 char32_t{0x205F}, // Medium mathematical space
1629 char32_t{0x3000} // Ideographic space
1632 using alphanum_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'> >;
1634 using alpha_chars = set<char_range<'A','Z'>, char_range<'a','z'> >;
1636 using xdigit_chars = set<char_range<'A','F'>, char_range<'a','f'>, char_range<'0','9'> >;
1639 = enumeration<'!', '"', '#
', '$
', '%
', '&
', '\
'',
'(',
')',
'*',
'+',
',',
'-',
1640 '.',
'/',
':',
';',
'<',
'=',
'>',
'?',
'@',
'[',
'\\',
']',
1641 '^',
'_',
'`',
'{',
'|',
'}',
'~'>;
1643 using digit_chars = char_range<'0','9'>;
1645 using ascii_chars = char_range<'\x00','\x7F'>;
1658 struct start_mark { };
1659 struct end_mark { };
1660 struct end_cycle_mark { };
1661 struct end_lookahead_mark { };
1662 struct end_lookbehind_mark { };
1663 template <
size_t Id>
struct numeric_mark { };
1668 template <
auto... Str>
struct string { };
1669 template <
typename... Opts>
struct select { };
1670 template <
typename... Content>
struct sequence { };
1673 template <
size_t a,
size_t b,
typename... Content>
struct repeat { };
1674 template <
typename... Content>
using plus = repeat<1,0,Content...>;
1675 template <
typename... Content>
using star = repeat<0,0,Content...>;
1677 template <
size_t a,
size_t b,
typename... Content>
struct lazy_repeat { };
1678 template <
typename... Content>
using lazy_plus = lazy_repeat<1,0,Content...>;
1679 template <
typename... Content>
using lazy_star = lazy_repeat<0,0,Content...>;
1681 template <
size_t a,
size_t b,
typename... Content>
struct possessive_repeat { };
1682 template <
typename... Content>
using possessive_plus = possessive_repeat<1,0,Content...>;
1683 template <
typename... Content>
using possessive_star = possessive_repeat<0,0,Content...>;
1685 template <
typename... Content>
using optional = repeat<0,1,Content...>;
1686 template <
typename... Content>
using lazy_optional = lazy_repeat<0,1,Content...>;
1687 template <
typename... Content>
using possessive_optional = possessive_repeat<0,1,Content...>;
1689 template <
size_t Index,
typename... Content>
struct capture { };
1691 template <
size_t Index,
typename Name,
typename... Content>
struct capture_with_name { };
1693 template <
size_t Index>
struct back_reference { };
1694 template <
typename Name>
struct back_reference_with_name { };
1696 template <
typename Type>
struct look_start { };
1698 template <
typename... Content>
struct lookahead_positive { };
1699 template <
typename... Content>
struct lookahead_negative { };
1701 template <
typename... Content>
struct lookbehind_positive { };
1702 template <
typename... Content>
struct lookbehind_negative { };
1704 struct atomic_start { };
1706 template <
typename... Content>
struct atomic_group { };
1708 template <
typename... Content>
struct boundary { };
1709 template <
typename... Content>
struct not_boundary { };
1711 using word_boundary = boundary<word_chars>;
1712 using not_word_boundary = not_boundary<word_chars>;
1714 struct assert_subject_begin { };
1715 struct assert_subject_end { };
1716 struct assert_subject_end_line{ };
1717 struct assert_line_begin { };
1718 struct assert_line_end { };
1720 template <
typename>
struct mode_switch { };
1726 #ifndef CTRE__ATOMS_UNICODE__HPP
1727 #define CTRE__ATOMS_UNICODE__HPP
1730 #ifndef H_COR3NTIN_UNICODE_SYNOPSYS
1731 #define H_COR3NTIN_UNICODE_SYNOPSYS
1733 #include <string_view>
1737 enum class category;
1738 enum class property;
1739 enum class version : unsigned char;
1743 struct script_extensions_view {
1744 constexpr script_extensions_view(char32_t);
1749 constexpr iterator(char32_t c);
1752 constexpr iterator& operator++(
int);
1754 constexpr iterator operator++();
1765 constexpr iterator begin()
const;
1766 constexpr sentinel end()
const;
1772 struct numeric_value {
1774 constexpr
double value()
const;
1775 constexpr
long long numerator()
const;
1776 constexpr
int denominator()
const;
1780 constexpr numeric_value() =
default;
1781 constexpr numeric_value(
long long n,
int16_t d);
1785 friend constexpr numeric_value cp_numeric_value(char32_t cp);
1788 constexpr category cp_category(char32_t cp);
1789 constexpr script cp_script(char32_t cp);
1790 constexpr script_extensions_view cp_script_extensions(char32_t cp);
1791 constexpr
version cp_age(char32_t cp);
1792 constexpr block cp_block(char32_t cp);
1793 constexpr
bool cp_is_valid(char32_t cp);
1794 constexpr
bool cp_is_assigned(char32_t cp);
1795 constexpr
bool cp_is_ascii(char32_t cp);
1796 constexpr numeric_value cp_numeric_value(char32_t cp);
1799 constexpr
bool cp_script_is(char32_t);
1801 constexpr
bool cp_property_is(char32_t);
1803 constexpr
bool cp_category_is(char32_t);
1807 enum class binary_prop;
1808 constexpr
int propnamecomp(std::string_view sa, std::string_view sb);
1809 constexpr binary_prop binary_prop_from_string(std::string_view s);
1811 template<binary_prop p>
1812 constexpr
bool get_binary_prop(char32_t) =
delete;
1814 constexpr script script_from_string(std::string_view s);
1815 constexpr block block_from_string(std::string_view s);
1816 constexpr
version age_from_string(std::string_view
a);
1817 constexpr category category_from_string(std::string_view
a);
1819 constexpr
bool is_unassigned(category cat);
1820 constexpr
bool is_unknown(script s);
1821 constexpr
bool is_unknown(block
b);
1822 constexpr
bool is_unassigned(
version v);
1823 constexpr
bool is_unknown(binary_prop s);
1833 template <
auto... Str>
struct property_name { };
1834 template <
auto... Str>
struct property_value { };
1836 template <
size_t Sz> constexpr std::string_view get_string_view(
const char (&
arr)[Sz]) noexcept {
1837 return std::string_view(
arr, Sz);
1842 template <
typename T, T Type>
struct binary_property;
1843 template <
typename T, T Type, auto Value>
struct property;
1845 template <auto Type>
using make_binary_property = binary_property<std::remove_const_t<decltype(
Type)>,
Type>;
1846 template <auto Type, auto Value>
using make_property =
property<std::remove_const_t<decltype(
Type)>,
Type,
Value>;
1849 template <uni::detail::binary_prop Property>
struct binary_property<uni::detail::binary_prop, Property> {
1850 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1851 return uni::detail::get_binary_prop<Property>(
static_cast<char32_t
>(c));
1857 enum class property_type {
1858 script, script_extension, age, block, unknown
1863 template <uni::script Script>
struct binary_property<uni::script, Script> {
1864 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1865 return uni::cp_script(c) == Script;
1869 template <uni::script Script>
struct property<property_type, property_type::script_extension, Script> {
1870 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1871 for (uni::script sc: uni::cp_script_extensions(c)) {
1872 if (sc == Script)
return true;
1878 template <uni::version Age>
struct binary_property<uni::
version, Age> {
1879 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1880 return uni::cp_age(c) <= Age;
1884 template <uni::block Block>
struct binary_property<uni::block,
Block> {
1885 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1886 return uni::cp_block(c) ==
Block;
1892 template <
typename =
void>
1893 constexpr property_type property_type_from_name(std::string_view
str) noexcept {
1894 using namespace std::string_view_literals;
1895 if (uni::detail::propnamecomp(
str,
"script"sv) == 0 || uni::detail::propnamecomp(
str,
"sc"sv) == 0) {
1896 return property_type::script;
1897 }
else if (uni::detail::propnamecomp(
str,
"script_extension"sv) == 0 || uni::detail::propnamecomp(
str,
"scx"sv) == 0) {
1898 return property_type::script_extension;
1899 }
else if (uni::detail::propnamecomp(
str,
"age"sv) == 0) {
1900 return property_type::age;
1901 }
else if (uni::detail::propnamecomp(
str,
"block"sv) == 0) {
1902 return property_type::block;
1904 return property_type::unknown;
1908 template <property_type Property>
struct property_type_builder {
1909 template <
auto...
Value>
static constexpr
auto get() {
1914 template <
auto... Name>
struct property_builder {
1915 static constexpr
char name[
sizeof...(Name)]{
static_cast<char>(Name)...};
1916 static constexpr property_type
type = property_type_from_name(get_string_view(name));
1918 using helper = property_type_builder<type>;
1920 template <
auto...
Value>
static constexpr
auto get() {
1921 return helper::template get<
Value...>();
1927 template <>
struct property_type_builder<property_type::script> {
1928 template <
auto...
Value>
static constexpr
auto get() {
1929 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1930 constexpr
auto sc = uni::detail::script_from_string(get_string_view(
value));
1931 if constexpr (uni::detail::is_unknown(sc)) {
1934 return make_binary_property<sc>();
1939 template <>
struct property_type_builder<property_type::script_extension> {
1940 template <
auto...
Value>
static constexpr
auto get() {
1941 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1942 constexpr
auto sc = uni::detail::script_from_string(get_string_view(
value));
1943 if constexpr (uni::detail::is_unknown(sc)) {
1946 return make_property<property_type::script_extension, sc>();
1951 template <>
struct property_type_builder<property_type::age> {
1952 template <
auto...
Value>
static constexpr
auto get() {
1953 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1954 constexpr
auto age = uni::detail::age_from_string(get_string_view(
value));
1955 if constexpr (uni::detail::is_unassigned(age)) {
1958 return make_binary_property<age>();
1963 template <>
struct property_type_builder<property_type::block> {
1964 template <
auto...
Value>
static constexpr
auto get() {
1965 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1966 constexpr
auto block = uni::detail::block_from_string(get_string_view(
value));
1967 if constexpr (uni::detail::is_unknown(block)) {
1970 return make_binary_property<block>();
1982 template <
size_t Index,
typename... Content>
auto convert_to_capture(
ctll::list<Content...>) -> capture<Index, Content...>;
1983 template <
size_t Index,
typename Name,
typename... Content>
auto convert_to_named_capture(
ctll::list<Content...>) -> capture_with_name<Index, Name, Content...>;
1984 template <
template <size_t, size_t,
typename...>
typename CycleType,
size_t A,
size_t B,
typename... Content>
auto convert_to_repeat(
ctll::list<Content...>) -> CycleType<
A,
B, Content...>;
1985 template <
template <
typename...>
typename ListType,
typename... Content>
auto convert_to_basic_list(
ctll::list<Content...>) -> ListType<Content...>;
1987 template <auto V>
struct rotate_value {
1988 template <
auto... Vs>
friend constexpr
auto operator+(string<Vs...>, rotate_value<V>) noexcept ->
string<V, Vs...> {
return {}; }
1991 struct rotate_for_lookbehind {
1994 template <auto V>
static auto rotate(character<V>) -> character<V>;
1995 template <
typename... Content>
static auto rotate(negative_set<Content...>) -> negative_set<Content...>;
1997 template <
auto... Cs>
static auto rotate(enumeration<Cs...>) -> enumeration<Cs...>;
1998 template <
typename... Content>
static auto rotate(negate<Content...>) -> negate<Content...>;
1999 template <auto A, auto B>
static auto rotate(char_range<A,B>) -> char_range<A,B>;
2002 template <
auto... Str>
static auto rotate(property_name<Str...>) -> property_name<Str...>;
2003 template <
auto... Str>
static auto rotate(property_value<Str...>) -> property_value<Str...>;
2004 template <
typename T, T Type>
static auto rotate(binary_property<T, Type>) -> binary_property<T, Type>;
2005 template <
typename T, T Type, auto Value>
static auto rotate(property<T, Type, Value>) -> property<T, Type, Value>;
2008 static auto rotate(accept) -> accept;
2009 static auto rotate(reject) -> reject;
2010 static auto rotate(start_mark) -> start_mark;
2011 static auto rotate(end_mark) -> end_mark;
2012 static auto rotate(end_cycle_mark) -> end_cycle_mark;
2013 static auto rotate(end_lookahead_mark) -> end_lookahead_mark;
2014 static auto rotate(end_lookbehind_mark) -> end_lookbehind_mark;
2015 template <
size_t Id>
static auto rotate(numeric_mark<Id>) -> numeric_mark<Id>;
2016 static auto rotate(any) -> any;
2018 template <
typename... Content>
static auto rotate(select<Content...>) -> select<Content...>;
2021 template <
size_t a,
size_t b,
typename... Content>
static auto rotate(repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<repeat, a, b>(
ctll::rotate(
ctll::list<decltype(
rotate(Content{}))...>{})));
2022 template <
size_t a,
size_t b,
typename... Content>
static auto rotate(lazy_repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<lazy_repeat, a, b>(
ctll::rotate(
ctll::list<decltype(
rotate(Content{}))...>{})));
2023 template <
size_t a,
size_t b,
typename... Content>
static auto rotate(possessive_repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<possessive_repeat, a, b>(
ctll::rotate(
ctll::list<decltype(
rotate(Content{}))...>{})));
2025 template <
size_t Index,
typename... Content>
static auto rotate(capture<Index, Content...>) {
2029 template <
size_t Index,
typename Name,
typename... Content>
static auto rotate(capture_with_name<Index, Name, Content...>) {
2033 template <
size_t Index>
static auto rotate(back_reference<Index>) -> back_reference<Index>;
2034 template <
typename Name>
static auto rotate(back_reference_with_name<Name>) -> back_reference_with_name<Name>;
2036 template <
typename... Content>
static auto rotate(look_start<Content...>) -> look_start<Content...>;
2038 template <
auto... Str>
static auto rotate(string<Str...>) -> decltype((string<>{} + ... + rotate_value<Str>{}));
2040 template <
typename... Content>
static auto rotate(sequence<Content...>) {
2045 template <
typename... Content>
static auto rotate(lookahead_positive<Content...>) -> lookahead_positive<Content...>;
2046 template <
typename... Content>
static auto rotate(lookahead_negative<Content...>) -> lookahead_negative<Content...>;
2047 template <
typename... Content>
static auto rotate(lookbehind_positive<Content...>) -> lookbehind_positive<Content...>;
2048 template <
typename... Content>
static auto rotate(lookbehind_negative<Content...>) -> lookbehind_negative<Content...>;
2050 static auto rotate(atomic_start) -> atomic_start;
2052 template <
typename... Content>
static auto rotate(atomic_group<Content...>) {
2056 template <
typename... Content>
static auto rotate(boundary<Content...>) -> boundary<Content...>;
2057 template <
typename... Content>
static auto rotate(not_boundary<Content...>) -> not_boundary<Content...>;
2059 static auto rotate(assert_subject_begin) -> assert_subject_begin;
2060 static auto rotate(assert_subject_end) -> assert_subject_end;
2061 static auto rotate(assert_subject_end_line) -> assert_subject_end_line;
2062 static auto rotate(assert_line_begin) -> assert_line_begin;
2063 static auto rotate(assert_line_end) -> assert_line_end;
2071 #ifndef CTRE__ID__HPP
2072 #define CTRE__ID__HPP
2074 #include <type_traits>
2078 template <
auto... Name>
struct id {
2081 friend constexpr
auto operator==(id<Name...>, id<Name...>) noexcept -> std::true_type {
return {}; }
2083 template <
auto... Other>
friend constexpr
auto operator==(id<Name...>, id<Other...>) noexcept -> std::false_type {
return {}; }
2085 template <
typename T>
friend constexpr
auto operator==(id<Name...>,
T) noexcept -> std::false_type {
return {}; }
2087 template <
typename T>
friend constexpr
auto operator==(
T, id<Name...>) noexcept -> std::false_type {
return {}; }
2099 template <
size_t Counter>
struct pcre_parameters {
2100 static constexpr
size_t current_counter = Counter;
2103 template <
typename Stack = ctll::list<>,
typename Parameters = pcre_parameters<0>,
typename Mode = ctll::list<>>
struct pcre_context {
2104 using stack_type = Stack;
2105 using parameters_type = Parameters;
2106 using mode_list = Mode;
2107 static constexpr
inline auto stack = stack_type();
2108 static constexpr
inline auto parameters = parameters_type();
2109 static constexpr
inline auto mode = mode_list();
2110 constexpr pcre_context() noexcept { }
2111 constexpr pcre_context(Stack, Parameters) noexcept { }
2112 constexpr pcre_context(Stack, Parameters, Mode) noexcept { }
2117 template <
size_t Value>
struct number { };
2119 template <
size_t Id>
struct capture_id { };
2121 struct pcre_actions {
2123 #ifndef CTRE__ACTIONS__ASSERTS__HPP
2124 #define CTRE__ACTIONS__ASSERTS__HPP
2137 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_assert_subject_begin,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2142 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_assert_subject_end,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2147 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_assert_subject_end_with_lineend,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2153 #ifndef CTRE__ACTIONS__ATOMIC_GROUP__HPP
2154 #define CTRE__ACTIONS__ATOMIC_GROUP__HPP
2157 template <
auto V,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::start_atomic,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, pcre_parameters<Counter>>) {
2158 return pcre_context{
ctll::list<atomic_start, Ts...>(), pcre_parameters<Counter>()};
2167 template <
auto V,
typename... Atomic,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_atomic,
ctll::term<V>, pcre_context<
ctll::list<sequence<Atomic...>, atomic_start, Ts...>, pcre_parameters<Counter>>) {
2168 return pcre_context{
ctll::list<atomic_group<Atomic...>, Ts...>(), pcre_parameters<Counter>()};
2173 #ifndef CTRE__ACTIONS__BACKREFERENCE__HPP
2174 #define CTRE__ACTIONS__BACKREFERENCE__HPP
2177 template <
auto... Str,
auto V,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_back_reference,
ctll::term<V>, pcre_context<
ctll::list<id<Str...>, Ts...>, pcre_parameters<Counter>>) {
2182 template <
auto V,
size_t Id,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_back_reference,
ctll::term<V>, pcre_context<
ctll::list<number<Id>, Ts...>, pcre_parameters<Counter>>) {
2184 if constexpr (Counter < Id) {
2192 template <
auto V,
size_t Id,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_relative_back_reference,
ctll::term<V>, [[maybe_unused]] pcre_context<
ctll::list<number<Id>, Ts...>, pcre_parameters<Counter>>) {
2194 if constexpr (Counter < Id) {
2197 constexpr
size_t absolute_id = (Counter + 1) - Id;
2204 #ifndef CTRE__ACTIONS__BOUNDARIES__HPP
2205 #define CTRE__ACTIONS__BOUNDARIES__HPP
2213 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_not_word_boundary,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2219 #ifndef CTRE__ACTIONS__CAPTURE__HPP
2220 #define CTRE__ACTIONS__CAPTURE__HPP
2223 template <
auto V,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::prepare_capture,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, pcre_parameters<Counter>>) {
2228 template <
auto V,
typename... Ts,
size_t Id,
size_t Counter>
static constexpr
auto apply(pcre::reset_capture,
ctll::term<V>, pcre_context<
ctll::list<capture_id<Id>, Ts...>, pcre_parameters<Counter>>) {
2229 return pcre_context{
ctll::list<Ts...>(), pcre_parameters<Counter-1>()};
2233 template <
auto V,
typename A,
size_t Id,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_capture,
ctll::term<V>, pcre_context<
ctll::list<
A, capture_id<Id>, Ts...>, pcre_parameters<Counter>>) {
2237 template <
auto V,
typename... Content,
size_t Id,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_capture,
ctll::term<V>, pcre_context<
ctll::list<sequence<Content...>, capture_id<Id>, Ts...>, pcre_parameters<Counter>>) {
2245 template <
auto... Str,
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_name,
ctll::term<V>, pcre_context<
ctll::list<id<Str...>, Ts...>, Parameters>
subject) {
2249 template <
auto... Str,
auto V,
typename A,
size_t Id,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_capture_with_name,
ctll::term<V>, pcre_context<
ctll::list<
A, id<Str...>, capture_id<Id>, Ts...>, pcre_parameters<Counter>>) {
2253 template <
auto... Str,
auto V,
typename... Content,
size_t Id,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::make_capture_with_name,
ctll::term<V>, pcre_context<
ctll::list<sequence<Content...>, id<Str...>, capture_id<Id>, Ts...>, pcre_parameters<Counter>>) {
2259 #ifndef CTRE__ACTIONS__CHARACTERS__HPP
2260 #define CTRE__ACTIONS__CHARACTERS__HPP
2267 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_character_anything,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2271 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_character_alarm,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2275 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_character_escape,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2279 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_character_formfeed,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2283 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_character_newline,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2291 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_character_return_carriage,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2301 #ifndef CTRE__ACTIONS__CLASS__HPP
2302 #define CTRE__ACTIONS__CLASS__HPP
2322 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::class_horizontal_space,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2326 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::class_non_horizontal_space,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2330 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::class_vertical_space,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2334 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::class_non_vertical_space,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, Parameters>
subject) {
2353 #ifndef CTRE__ACTIONS__FUSION__HPP
2354 #define CTRE__ACTIONS__FUSION__HPP
2356 static constexpr
size_t combine_max_repeat_length(
size_t A,
size_t B) {
2357 if (
A &&
B)
return A+
B;
2361 template <
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content>
static constexpr
auto combine_repeat(repeat<MinA, MaxA, Content...>, repeat<MinB, MaxB, Content...>) {
2362 return repeat<MinA + MinB, combine_max_repeat_length(MaxA, MaxB), Content...>();
2365 template <
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content>
static constexpr
auto combine_repeat(lazy_repeat<MinA, MaxA, Content...>, lazy_repeat<MinB, MaxB, Content...>) {
2366 return lazy_repeat<MinA + MinB, combine_max_repeat_length(MaxA, MaxB), Content...>();
2369 template <
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content>
static constexpr
auto combine_repeat(possessive_repeat<MinA, MaxA, Content...>, possessive_repeat<MinB, MaxB, Content...>) {
2370 [[maybe_unused]] constexpr
bool first_is_unbounded = (MaxA == 0);
2371 [[maybe_unused]] constexpr
bool second_is_nonempty = (MinB > 0);
2372 [[maybe_unused]] constexpr
bool second_can_be_empty = (MinB == 0);
2374 if constexpr (first_is_unbounded && second_is_nonempty) {
2376 return sequence<reject, Content...>();
2377 }
else if constexpr (first_is_unbounded) {
2378 return possessive_repeat<MinA, MaxA, Content...>();
2379 }
else if constexpr (second_can_be_empty) {
2380 return possessive_repeat<MinA, combine_max_repeat_length(MaxA, MaxB), Content...>();
2382 return possessive_repeat<MaxA + MinB, combine_max_repeat_length(MaxA, MaxB), Content...>();
2387 template <
auto V,
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<repeat<MinB, MaxB, Content...>, repeat<MinA, MaxA, Content...>, Ts...>, Parameters>
subject) {
2392 template <
auto V,
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<lazy_repeat<MinB, MaxB, Content...>, lazy_repeat<MinA, MaxA, Content...>, Ts...>, Parameters>
subject) {
2397 template <
auto V,
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<possessive_repeat<MinB, MaxB, Content...>, possessive_repeat<MinA, MaxA, Content...>, Ts...>, Parameters>
subject) {
2402 template <
auto V,
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content,
typename... As,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<sequence<repeat<MinB, MaxB, Content...>, As...>,repeat<MinA, MaxA, Content...>,Ts...>, Parameters>
subject) {
2403 using result = decltype(combine_repeat(repeat<MinB, MaxB, Content...>(), repeat<MinA, MaxA, Content...>()));
2409 template <
auto V,
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content,
typename... As,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<sequence<lazy_repeat<MinB, MaxB, Content...>, As...>,lazy_repeat<MinA, MaxA, Content...>,Ts...>, Parameters>
subject) {
2410 using result = decltype(combine_repeat(lazy_repeat<MinB, MaxB, Content...>(), lazy_repeat<MinA, MaxA, Content...>()));
2416 template <
auto V,
size_t MinA,
size_t MaxA,
size_t MinB,
size_t MaxB,
typename... Content,
typename... As,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<sequence<possessive_repeat<MinB, MaxB, Content...>, As...>,possessive_repeat<MinA, MaxA, Content...>,Ts...>, Parameters>
subject) {
2417 using result = decltype(combine_repeat(possessive_repeat<MinB, MaxB, Content...>(), possessive_repeat<MinA, MaxA, Content...>()));
2424 #ifndef CTRE__ACTIONS__HEXDEC__HPP
2425 #define CTRE__ACTIONS__HEXDEC__HPP
2432 template <
auto V,
size_t N,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_hexdec,
ctll::term<V>, pcre_context<
ctll::list<number<N>, Ts...>, Parameters>
subject) {
2433 constexpr
auto previous =
N << 4ull;
2434 if constexpr (V >=
'a' && V <=
'f') {
2436 }
else if constexpr (V >=
'A' && V <=
'F') {
2443 template <
auto V,
size_t N,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::finish_hexdec,
ctll::term<V>, pcre_context<
ctll::list<number<N>, Ts...>, Parameters>
subject) {
2445 if constexpr (
N <= max_char) {
2454 #ifndef CTRE__ACTIONS__LOOKAHEAD__HPP
2455 #define CTRE__ACTIONS__LOOKAHEAD__HPP
2458 template <
auto V,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::start_lookahead_positive,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, pcre_parameters<Counter>>) {
2463 template <
auto V,
typename Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<Look, look_start<lookahead_positive<>>, Ts...>, pcre_parameters<Counter>>) {
2468 template <
auto V,
typename... Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<ctre::sequence<Look...>, look_start<lookahead_positive<>>, Ts...>, pcre_parameters<Counter>>) {
2469 return pcre_context{
ctll::list<lookahead_positive<Look...>, Ts...>(), pcre_parameters<Counter>()};
2473 template <
auto V,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::start_lookahead_negative,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, pcre_parameters<Counter>>) {
2478 template <
auto V,
typename Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<Look, look_start<lookahead_negative<>>, Ts...>, pcre_parameters<Counter>>) {
2483 template <
auto V,
typename... Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<ctre::sequence<Look...>, look_start<lookahead_negative<>>, Ts...>, pcre_parameters<Counter>>) {
2484 return pcre_context{
ctll::list<lookahead_negative<Look...>, Ts...>(), pcre_parameters<Counter>()};
2490 template <
auto V,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::start_lookbehind_positive,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, pcre_parameters<Counter>>) {
2495 template <
auto V,
typename Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<Look, look_start<lookbehind_positive<>>, Ts...>, pcre_parameters<Counter>>) {
2500 template <
auto V,
typename... Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<ctre::sequence<Look...>, look_start<lookbehind_positive<>>, Ts...>, pcre_parameters<Counter>>) {
2502 return pcre_context{
ctll::list<my_lookbehind, Ts...>(), pcre_parameters<Counter>()};
2506 template <
auto V,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::start_lookbehind_negative,
ctll::term<V>, pcre_context<
ctll::list<Ts...>, pcre_parameters<Counter>>) {
2511 template <
auto V,
typename Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<Look, look_start<lookbehind_negative<>>, Ts...>, pcre_parameters<Counter>>) {
2516 template <
auto V,
typename... Look,
typename... Ts,
size_t Counter>
static constexpr
auto apply(pcre::look_finish,
ctll::term<V>, pcre_context<
ctll::list<ctre::sequence<Look...>, look_start<lookbehind_negative<>>, Ts...>, pcre_parameters<Counter>>) {
2518 return pcre_context{
ctll::list<my_lookbehind, Ts...>(), pcre_parameters<Counter>()};
2523 #ifndef CTRE__ACTIONS__NAMED_CLASS__HPP
2524 #define CTRE__ACTIONS__NAMED_CLASS__HPP
2585 #ifndef CTRE__ACTIONS__OPTIONS__HPP
2586 #define CTRE__ACTIONS__OPTIONS__HPP
2603 template <
auto V,
typename A,
typename... Bs,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_alternate,
ctll::term<V>, pcre_context<
ctll::list<ctre::select<Bs...>,
A, Ts...>, Parameters>
subject) {
2612 template <
auto V,
typename... Content,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_optional,
ctll::term<V>, pcre_context<
ctll::list<sequence<Content...>, Ts...>, Parameters>
subject) {
2617 template <
auto V,
typename A,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_optional,
ctll::term<V>, pcre_context<
ctll::list<optional<A>, Ts...>, Parameters>
subject) {
2622 template <
auto V,
typename A,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_optional,
ctll::term<V>, pcre_context<
ctll::list<lazy_optional<A>, Ts...>, Parameters>
subject) {
2627 template <
auto V,
typename... Subject,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_lazy,
ctll::term<V>, pcre_context<
ctll::list<optional<Subject...>, Ts...>, Parameters>
subject) {
2632 template <
auto V,
typename... Subject,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_lazy,
ctll::term<V>, pcre_context<
ctll::list<lazy_optional<Subject...>, Ts...>, Parameters>
subject) {
2638 #ifndef CTRE__ACTIONS__PROPERTIES__HPP
2639 #define CTRE__ACTIONS__PROPERTIES__HPP
2646 template <
auto... Str,
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_property_name,
ctll::term<V>, pcre_context<
ctll::list<property_name<Str...>, Ts...>, Parameters>
subject) {
2655 template <
auto... Str,
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_property_value,
ctll::term<V>, pcre_context<
ctll::list<property_value<Str...>, Ts...>, Parameters>
subject) {
2660 template <
auto V,
auto... Name,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_property,
ctll::term<V>, [[maybe_unused]] pcre_context<
ctll::list<property_name<Name...>, Ts...>, Parameters>
subject) {
2662 constexpr
char name[
sizeof...(Name)]{
static_cast<char>(Name)...};
2663 constexpr
auto p = uni::detail::binary_prop_from_string(get_string_view(name));
2665 if constexpr (uni::detail::is_unknown(p)) {
2673 template <
auto V,
auto...
Value,
auto... Name,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_property,
ctll::term<V>, [[maybe_unused]] pcre_context<
ctll::list<property_value<Value...>, property_name<Name...>, Ts...>, Parameters>
subject) {
2675 constexpr
auto prop = property_builder<Name...>::template get<
Value...>();
2677 if constexpr (std::is_same_v<decltype(prop),
ctll::reject>) {
2685 template <
auto V,
auto... Name,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_property_negative,
ctll::term<V>, [[maybe_unused]] pcre_context<
ctll::list<property_name<Name...>, Ts...>, Parameters>
subject) {
2687 constexpr
char name[
sizeof...(Name)]{
static_cast<char>(Name)...};
2688 constexpr
auto p = uni::detail::binary_prop_from_string(get_string_view(name));
2690 if constexpr (uni::detail::is_unknown(p)) {
2698 template <
auto V,
auto...
Value,
auto... Name,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_property_negative,
ctll::term<V>, [[maybe_unused]] pcre_context<
ctll::list<property_value<Value...>, property_name<Name...>, Ts...>, Parameters>
subject) {
2700 constexpr
auto prop = property_builder<Name...>::template get<
Value...>();
2702 if constexpr (std::is_same_v<decltype(prop),
ctll::reject>) {
2711 #ifndef CTRE__ACTIONS__REPEAT__HPP
2712 #define CTRE__ACTIONS__REPEAT__HPP
2719 template <
auto V,
typename... Content,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_plus,
ctll::term<V>, pcre_context<
ctll::list<sequence<Content...>, Ts...>, Parameters>
subject) {
2728 template <
auto V,
typename... Content,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_star,
ctll::term<V>, pcre_context<
ctll::list<sequence<Content...>, Ts...>, Parameters>
subject) {
2737 template <
auto V,
size_t N,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::push_number,
ctll::term<V>, pcre_context<
ctll::list<number<N>, Ts...>, Parameters>
subject) {
2738 constexpr
size_t previous =
N * 10ull;
2743 template <
auto V,
typename Subject,
size_t A,
size_t B,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_ab,
ctll::term<V>, pcre_context<
ctll::list<number<B>, number<A>, Subject, Ts...>, Parameters>
subject) {
2747 template <
auto V,
typename... Content,
size_t A,
size_t B,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_ab,
ctll::term<V>, pcre_context<
ctll::list<number<B>, number<A>, sequence<Content...>, Ts...>, Parameters>
subject) {
2752 template <
auto V,
typename Subject,
size_t A,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_exactly,
ctll::term<V>, pcre_context<
ctll::list<number<A>, Subject, Ts...>, Parameters>
subject) {
2756 template <
auto V,
typename... Content,
size_t A,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_exactly,
ctll::term<V>, pcre_context<
ctll::list<number<A>, sequence<Content...>, Ts...>, Parameters>
subject) {
2761 template <
auto V,
typename Subject,
size_t A,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_at_least,
ctll::term<V>, pcre_context<
ctll::list<number<A>, Subject, Ts...>, Parameters>
subject) {
2765 template <
auto V,
typename... Content,
size_t A,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::repeat_at_least,
ctll::term<V>, pcre_context<
ctll::list<number<A>, sequence<Content...>, Ts...>, Parameters>
subject) {
2770 template <
auto V,
typename... Subject,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_lazy,
ctll::term<V>, pcre_context<
ctll::list<plus<Subject...>, Ts...>, Parameters>
subject) {
2775 template <
auto V,
typename... Subject,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_lazy,
ctll::term<V>, pcre_context<
ctll::list<star<Subject...>, Ts...>, Parameters>
subject) {
2780 template <
auto V,
typename... Subject,
size_t A,
size_t B,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_lazy,
ctll::term<V>, pcre_context<
ctll::list<repeat<A,B,Subject...>, Ts...>, Parameters>
subject) {
2785 template <
auto V,
typename... Subject,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_possessive,
ctll::term<V>, pcre_context<
ctll::list<plus<Subject...>, Ts...>, Parameters>
subject) {
2790 template <
auto V,
typename... Subject,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_possessive,
ctll::term<V>, pcre_context<
ctll::list<star<Subject...>, Ts...>, Parameters>
subject) {
2795 template <
auto V,
typename... Subject,
size_t A,
size_t B,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_possessive,
ctll::term<V>, pcre_context<
ctll::list<repeat<A,B,Subject...>, Ts...>, Parameters>
subject) {
2801 #ifndef CTRE__ACTIONS__SEQUENCE__HPP
2802 #define CTRE__ACTIONS__SEQUENCE__HPP
2809 template <
auto V,
typename A,
typename... Bs,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<sequence<Bs...>,
A,Ts...>, Parameters>
subject) {
2814 template <
auto V,
auto A,
auto B,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<character<B>,character<A>,Ts...>, Parameters>
subject) {
2818 template <
auto V,
auto A,
auto... Bs,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<string<Bs...>,character<A>,Ts...>, Parameters>
subject) {
2823 template <
auto V,
auto A,
auto B,
typename... Sq,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<sequence<character<B>,Sq...>,character<A>,Ts...>, Parameters>
subject) {
2827 template <
auto V,
auto A,
auto... Bs,
typename... Sq,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_sequence,
ctll::term<V>, pcre_context<
ctll::list<sequence<string<Bs...>,Sq...>,character<A>,Ts...>, Parameters>
subject) {
2833 #ifndef CTRE__ACTIONS__SET__HPP
2834 #define CTRE__ACTIONS__SET__HPP
2838 template <
template <
typename...>
typename SetType,
typename T,
typename... As,
bool Exists = (std::is_same_v<T, As> || ... ||
false)>
static constexpr
auto push_back_into_set(
T, SetType<As...>) ->
ctll::conditional<Exists, SetType<As...>, SetType<As...,
T>> {
return {}; }
2877 template <
auto V,
typename A,
typename... Content,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::set_combine,
ctll::term<V>, pcre_context<
ctll::list<
A,negative_set<Content...>,Ts...>, Parameters>
subject) {
2893 template <
auto V,
auto B,
auto A,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::make_range,
ctll::term<V>, pcre_context<
ctll::list<character<B>,character<A>, Ts...>, Parameters>
subject) {
2899 #ifndef CTRE__ACTIONS__MODE__HPP
2900 #define CTRE__ACTIONS__MODE__HPP
2903 template <
typename Mode,
typename... Ts,
typename Parameters>
static constexpr
auto apply_mode(Mode,
ctll::list<Ts...>, Parameters) {
2904 return pcre_context<ctll::list<mode_switch<Mode>, Ts...>, Parameters>{};
2907 template <
typename Mode,
typename... Ts,
size_t Id,
size_t Counter>
static constexpr
auto apply_mode(Mode,
ctll::list<capture_id<Id>, Ts...>, pcre_parameters<Counter>) {
2908 return pcre_context<ctll::list<mode_switch<Mode>, Ts...>, pcre_parameters<Counter-1>>{};
2912 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::mode_case_insensitive
mode,
ctll::term<V>,pcre_context<
ctll::list<Ts...>, Parameters>) {
2916 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::mode_case_sensitive
mode,
ctll::term<V>,pcre_context<
ctll::list<Ts...>, Parameters>) {
2920 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::mode_singleline
mode,
ctll::term<V>,pcre_context<
ctll::list<Ts...>, Parameters>) {
2924 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::mode_multiline
mode,
ctll::term<V>,pcre_context<
ctll::list<Ts...>, Parameters>) {
2938 #ifndef CTRE__EVALUATION__HPP
2939 #define CTRE__EVALUATION__HPP
2941 #ifndef CTRE__STARTS_WITH_ANCHOR__HPP
2942 #define CTRE__STARTS_WITH_ANCHOR__HPP
2946 template <
typename... Content>
2951 template <
typename... Content>
2957 template <
typename... Content>
2963 template <
typename CharLike,
typename... Content>
2964 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<boundary<CharLike>, Content...>) noexcept {
2969 template <
typename... Options,
typename... Content>
2970 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<select<Options...>, Content...>) noexcept {
2975 template <
typename... Optional,
typename... Content>
2976 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<optional<Optional...>, Content...>) noexcept {
2981 template <
typename... Optional,
typename... Content>
2982 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<lazy_optional<Optional...>, Content...>) noexcept {
2987 template <
typename... Seq,
typename... Content>
2988 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<sequence<Seq...>, Content...>) noexcept {
2993 template <
size_t A,
size_t B,
typename... Seq,
typename... Content>
2994 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<repeat<A, B, Seq...>, Content...>) noexcept {
2999 template <
size_t A,
size_t B,
typename... Seq,
typename... Content>
3000 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<lazy_repeat<A, B, Seq...>, Content...>) noexcept {
3005 template <
size_t A,
size_t B,
typename... Seq,
typename... Content>
3006 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<possessive_repeat<A, B, Seq...>, Content...>) noexcept {
3011 template <
size_t Index,
typename... Seq,
typename... Content>
3012 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<capture<Index, Seq...>, Content...>) noexcept {
3017 template <
size_t Index,
typename... Seq,
typename... Content>
3018 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<capture_with_name<Index, Seq...>, Content...>) noexcept {
3027 #ifndef CTRE__RETURN_TYPE__HPP
3028 #define CTRE__RETURN_TYPE__HPP
3030 #ifndef CTRE__UTF8__HPP
3031 #define CTRE__UTF8__HPP
3033 #if __cpp_char8_t >= 201811
3035 #include <string_view>
3038 #if __cpp_lib_char8_t >= 201811L
3039 #define CTRE_ENABLE_UTF8_RANGE
3044 struct utf8_iterator {
3045 using self_type = utf8_iterator;
3047 using reference = char8_t;
3048 using pointer =
const char8_t *;
3049 using iterator_category = std::bidirectional_iterator_tag;
3050 using difference_type =
int;
3054 using self_type = utf8_iterator;
3056 using reference = char8_t &;
3057 using pointer =
const char8_t *;
3058 using iterator_category = std::bidirectional_iterator_tag;
3059 using difference_type =
int;
3062 auto operator++() noexcept -> self_type &;
3063 auto operator++(
int) noexcept -> self_type;
3069 friend constexpr
auto operator==(self_type,
const char8_t * other_ptr) noexcept {
3070 return *other_ptr == char8_t{0};
3074 const char8_t * ptr{
nullptr};
3075 const char8_t * end{
nullptr};
3077 constexpr
friend bool operator!=(
const utf8_iterator & lhs, sentinel) {
3078 return lhs.ptr < lhs.end;
3081 constexpr
friend bool operator!=(sentinel,
const utf8_iterator & rhs) {
3082 return rhs.ptr < rhs.end;
3085 constexpr
friend bool operator!=(
const utf8_iterator & lhs,
const utf8_iterator & rhs) {
3086 return lhs.ptr != rhs.ptr;
3089 constexpr
friend bool operator==(
const utf8_iterator & lhs, sentinel) {
3090 return lhs.ptr >= lhs.end;
3093 constexpr
friend bool operator==(sentinel,
const utf8_iterator & rhs) {
3094 return rhs.ptr >= rhs.end;
3097 constexpr utf8_iterator & operator=(
const char8_t * rhs) {
3102 constexpr
operator const char8_t *()
const noexcept {
3106 constexpr utf8_iterator & operator++() noexcept {
3114 ptr += ((0x3A55000000000000ull >> ((*ptr >> 2) & 0b111110u)) & 0b11u) + 1;
3118 constexpr utf8_iterator &
operator--() noexcept {
3125 while ((*ptr & 0b11000000u) == 0b10'000000) {
3132 constexpr utf8_iterator
operator--(
int) noexcept {
3138 constexpr utf8_iterator operator++(
int) noexcept {
3144 constexpr utf8_iterator
operator+(
unsigned step)
const noexcept {
3145 utf8_iterator
result = *
this;
3153 constexpr utf8_iterator
operator-(
unsigned step)
const noexcept {
3154 utf8_iterator
result = *
this;
3162 constexpr char32_t
operator*()
const noexcept {
3163 constexpr char32_t mojibake = 0xFFFDull;
3166 if (!(*ptr & 0b1000'0000u)) CTRE_LIKELY {
3171 const unsigned length = ((0x3A55000000000000ull >> ((*ptr >> 2) & 0b111110u)) & 0b11u);
3176 if (!length) CTRE_UNLIKELY {
3181 if (((ptr + length) >= end)) CTRE_UNLIKELY {
3185 if ((ptr[1] & 0b1100'0000u) != 0b1000'0000) CTRE_UNLIKELY {
3189 const char8_t
mask =
static_cast<char8_t
>(0b0011'1111u >> length);
3198 char32_t
result =
static_cast<char32_t
>((ptr[0] &
mask) << 6u) | (ptr[1] & 0b0011'1111u);
3201 if (length == 1) CTRE_LIKELY {
3205 if ((ptr[2] & 0b1100'0000u) != 0b1000'0000) CTRE_UNLIKELY {
3211 if (length == 2) CTRE_LIKELY {
3215 if ((ptr[3] & 0b1100'0000u) != 0b1000'0000) CTRE_UNLIKELY {
3219 return (
result << 6) | (ptr[3] & 0b0011'1111u);
3223 #ifdef CTRE_ENABLE_UTF8_RANGE
3225 std::u8string_view
range;
3226 constexpr utf8_range(std::u8string_view
r) noexcept:
range{
r} { }
3228 constexpr
auto begin()
const noexcept {
3231 constexpr
auto end()
const noexcept {
3232 return utf8_iterator::sentinel{};
3243 #include <type_traits>
3245 #include <string_view>
3249 #if __has_include(<charconv>)
3255 constexpr
auto is_random_accessible_f(
const std::random_access_iterator_tag &) {
return std::true_type{}; }
3256 constexpr
auto is_random_accessible_f(...) {
return std::false_type{}; }
3258 template <
typename T> constexpr
auto is_reverse_iterator_f(
const std::reverse_iterator<T> &) {
return std::true_type{}; }
3259 constexpr
auto is_reverse_iterator_f(...) {
return std::false_type{}; }
3261 template <
typename T> constexpr
bool is_random_accessible = decltype(is_random_accessible_f(std::declval<const T &>())){};
3262 template <
typename T> constexpr
bool is_reverse_iterator = decltype(is_reverse_iterator_f(std::declval<const T &>())){};
3264 struct not_matched_tag_t { };
3266 constexpr
inline auto not_matched = not_matched_tag_t{};
3268 template <
size_t Id,
typename Name =
void>
struct captured_content {
3269 template <
typename Iterator>
class storage {
3273 bool _matched{
false};
3279 constexpr CTRE_FORCE_INLINE storage() noexcept {}
3281 constexpr CTRE_FORCE_INLINE
void matched() noexcept {
3284 constexpr CTRE_FORCE_INLINE
void unmatch() noexcept {
3287 constexpr CTRE_FORCE_INLINE
void set_start(Iterator pos) noexcept {
3290 constexpr CTRE_FORCE_INLINE storage & set_end(Iterator pos) noexcept {
3294 constexpr CTRE_FORCE_INLINE Iterator get_end()
const noexcept {
3299 constexpr
auto begin()
const noexcept {
3302 constexpr
auto end()
const noexcept {
3306 constexpr
explicit CTRE_FORCE_INLINE
operator bool()
const noexcept {
3310 template <
typename It = Iterator> constexpr CTRE_FORCE_INLINE
const auto * data_unsafe()
const noexcept {
3311 static_assert(!is_reverse_iterator<It>,
"Iterator in your capture must not be reverse!");
3313 #if __cpp_char8_t >= 201811
3314 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3324 template <
typename It = Iterator> constexpr CTRE_FORCE_INLINE
const auto *
data()
const noexcept {
3325 constexpr
bool must_be_contiguous_nonreverse_iterator = is_random_accessible<typename std::iterator_traits<It>::iterator_category> && !is_reverse_iterator<It>;
3327 static_assert(must_be_contiguous_nonreverse_iterator,
"To access result as a pointer you need to provide a random access iterator/range to regex (which is not reverse iterator based).");
3329 return data_unsafe();
3332 constexpr CTRE_FORCE_INLINE
auto size()
const noexcept {
3333 return static_cast<size_t>(std::distance(begin(), end()));
3336 constexpr CTRE_FORCE_INLINE
size_t unit_size()
const noexcept {
3337 #if __cpp_char8_t >= 201811
3338 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3339 return static_cast<size_t>(std::distance(_begin.ptr, _end.ptr));
3341 return static_cast<size_t>(std::distance(begin(), end()));
3344 return static_cast<size_t>(std::distance(begin(), end()));
3348 #if __has_include(<charconv>)
3349 template <
typename R =
int> constexpr CTRE_FORCE_INLINE
auto to_number(
int base = 10)
const noexcept ->
R {
3351 const auto view = to_view();
3352 std::from_chars(view.data(), view.data() + view.size(),
result, base);
3357 template <
typename T>
struct identify;
3359 template <
typename It = Iterator> constexpr CTRE_FORCE_INLINE
auto to_view()
const noexcept {
3361 constexpr
bool must_be_nonreverse_contiguous_iterator = is_random_accessible<typename std::iterator_traits<std::remove_const_t<It>>::iterator_category> && !is_reverse_iterator<It>;
3363 static_assert(must_be_nonreverse_contiguous_iterator,
"To convert capture into a basic_string_view you need to provide a pointer or a contiguous non-reverse iterator/range to regex.");
3365 return std::basic_string_view<char_type>(data_unsafe(),
static_cast<size_t>(unit_size()));
3368 constexpr CTRE_FORCE_INLINE std::basic_string<char_type> to_string()
const noexcept {
3369 #if __cpp_char8_t >= 201811
3370 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3371 return std::basic_string<char_type>(data_unsafe(),
static_cast<size_t>(unit_size()));
3373 return std::basic_string<char_type>(begin(), end());
3376 return std::basic_string<char_type>(begin(), end());
3380 constexpr CTRE_FORCE_INLINE
auto view()
const noexcept {
3384 constexpr CTRE_FORCE_INLINE
auto str()
const noexcept {
3388 constexpr CTRE_FORCE_INLINE
operator std::basic_string_view<char_type>()
const noexcept {
3392 constexpr CTRE_FORCE_INLINE
explicit operator std::basic_string<char_type>()
const noexcept {
3396 constexpr CTRE_FORCE_INLINE
static size_t get_id() noexcept {
3400 friend CTRE_FORCE_INLINE constexpr
bool operator==(
const storage & lhs, std::basic_string_view<char_type> rhs) noexcept {
3401 return bool(lhs) ? lhs.view() == rhs :
false;
3403 friend CTRE_FORCE_INLINE constexpr
bool operator!=(
const storage & lhs, std::basic_string_view<char_type> rhs) noexcept {
3404 return bool(lhs) ? lhs.view() != rhs :
false;
3406 friend CTRE_FORCE_INLINE constexpr
bool operator==(std::basic_string_view<char_type> lhs,
const storage & rhs) noexcept {
3407 return bool(rhs) ? lhs == rhs.view() :
false;
3409 friend CTRE_FORCE_INLINE constexpr
bool operator!=(std::basic_string_view<char_type> lhs,
const storage & rhs) noexcept {
3410 return bool(rhs) ? lhs != rhs.view() :
false;
3412 friend CTRE_FORCE_INLINE std::ostream &
operator<<(std::ostream &
str,
const storage & rhs) {
3413 return str << rhs.view();
3418 struct capture_not_exists_tag { };
3420 static constexpr
inline auto capture_not_exists = capture_not_exists_tag{};
3422 template <
typename... Captures>
struct captures;
3424 template <
typename Head,
typename... Tail>
struct captures<Head, Tail...>: captures<Tail...> {
3426 constexpr CTRE_FORCE_INLINE captures() noexcept { }
3427 template <
size_t id> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3428 if constexpr (
id == Head::get_id()) {
3431 return captures<Tail...>::template exists<id>();
3434 template <
typename Name> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3435 if constexpr (std::is_same_v<Name, typename Head::name>) {
3438 return captures<Tail...>::template exists<Name>();
3441 #if CTRE_CNTTP_COMPILER_CHECK
3442 template <ctll::fixed_
string Name> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3444 template <const auto & Name> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3446 if constexpr (std::is_same_v<typename Head::name, void>) {
3447 return captures<Tail...>::template exists<Name>();
3449 if constexpr (Head::name::name.is_same_as(Name)) {
3452 return captures<Tail...>::template exists<Name>();
3456 template <
size_t id> CTRE_FORCE_INLINE constexpr
auto & select() noexcept {
3457 if constexpr (
id == Head::get_id()) {
3460 return captures<Tail...>::template select<id>();
3463 template <
typename Name> CTRE_FORCE_INLINE constexpr
auto & select() noexcept {
3464 if constexpr (std::is_same_v<Name, typename Head::name>) {
3467 return captures<Tail...>::template select<Name>();
3470 template <
size_t id> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3471 if constexpr (
id == Head::get_id()) {
3474 return captures<Tail...>::template select<id>();
3477 template <
typename Name> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3478 if constexpr (std::is_same_v<Name, typename Head::name>) {
3481 return captures<Tail...>::template select<Name>();
3484 #if CTRE_CNTTP_COMPILER_CHECK
3485 template <ctll::fixed_
string Name> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3487 template <const auto & Name> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3489 if constexpr (std::is_same_v<typename Head::name, void>) {
3490 return captures<Tail...>::template select<Name>();
3492 if constexpr (Head::name::name.is_same_as(Name)) {
3495 return captures<Tail...>::template select<Name>();
3501 template <>
struct captures<> {
3502 constexpr CTRE_FORCE_INLINE captures() noexcept { }
3503 template <
size_t> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3506 template <
typename> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3509 #if CTRE_CNTTP_COMPILER_CHECK
3510 template <ctll::fixed_
string> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3512 template <const auto &> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3516 template <
size_t> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3517 return capture_not_exists;
3519 template <
typename> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3520 return capture_not_exists;
3522 #if CTRE_CNTTP_COMPILER_CHECK
3523 template <ctll::fixed_
string> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3525 template <const auto &> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3527 return capture_not_exists;
3531 template <
typename Iterator,
typename... Captures>
class regex_results {
3532 captures<captured_content<0>::template storage<Iterator>,
typename Captures::template storage<Iterator>...> _captures{};
3536 constexpr CTRE_FORCE_INLINE regex_results() noexcept { }
3537 constexpr CTRE_FORCE_INLINE regex_results(not_matched_tag_t) noexcept { }
3542 template <size_t Id, typename = std::enable_if_t<decltype(_captures)::template exists<Id>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3543 return _captures.template select<Id>();
3545 template <typename Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3546 return _captures.template select<Name>();
3548 #if CTRE_CNTTP_COMPILER_CHECK
3549 template <ctll::fixed_string Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3551 template <const auto & Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3553 return _captures.template select<Name>();
3555 static constexpr
size_t count() noexcept {
3556 return sizeof...(Captures) + 1;
3558 constexpr CTRE_FORCE_INLINE regex_results & matched() noexcept {
3559 _captures.template select<0>().matched();
3562 constexpr CTRE_FORCE_INLINE regex_results & unmatch() noexcept {
3563 _captures.template select<0>().unmatch();
3566 constexpr CTRE_FORCE_INLINE
operator bool()
const noexcept {
3567 return bool(_captures.template select<0>());
3570 constexpr CTRE_FORCE_INLINE
operator std::basic_string_view<char_type>()
const noexcept {
3574 constexpr CTRE_FORCE_INLINE
explicit operator std::basic_string<char_type>()
const noexcept {
3578 #if __has_include(<charconv>)
3579 template <
typename R =
int> constexpr CTRE_FORCE_INLINE
auto to_number(
int base = 10)
const noexcept ->
R {
3580 return _captures.template select<0>().template to_number<R>(base);
3584 constexpr CTRE_FORCE_INLINE
auto to_view()
const noexcept {
3585 return _captures.template select<0>().to_view();
3588 constexpr CTRE_FORCE_INLINE
auto to_string()
const noexcept {
3589 return _captures.template select<0>().to_string();
3592 constexpr CTRE_FORCE_INLINE
auto view()
const noexcept {
3593 return _captures.template select<0>().view();
3596 constexpr CTRE_FORCE_INLINE
auto str()
const noexcept {
3597 return _captures.template select<0>().to_string();
3600 constexpr CTRE_FORCE_INLINE
size_t size()
const noexcept {
3601 return _captures.template select<0>().size();
3604 constexpr CTRE_FORCE_INLINE
const auto *
data()
const noexcept {
3605 return _captures.template select<0>().data();
3608 constexpr CTRE_FORCE_INLINE regex_results & set_start_mark(Iterator pos) noexcept {
3609 _captures.template select<0>().set_start(pos);
3612 constexpr CTRE_FORCE_INLINE regex_results & set_end_mark(Iterator pos) noexcept {
3613 _captures.template select<0>().set_end(pos);
3616 constexpr CTRE_FORCE_INLINE Iterator get_end_position()
const noexcept {
3617 return _captures.template select<0>().get_end();
3619 template <
size_t Id> CTRE_FORCE_INLINE constexpr regex_results & start_capture(Iterator pos) noexcept {
3620 _captures.template select<Id>().set_start(pos);
3623 template <
size_t Id> CTRE_FORCE_INLINE constexpr regex_results & end_capture(Iterator pos) noexcept {
3624 _captures.template select<Id>().set_end(pos).matched();
3627 constexpr
auto begin()
const noexcept {
3628 return _captures.template select<0>().begin();
3630 constexpr
auto end()
const noexcept {
3631 return _captures.template select<0>().end();
3633 friend CTRE_FORCE_INLINE constexpr
bool operator==(
const regex_results & lhs, std::basic_string_view<char_type> rhs) noexcept {
3634 return bool(lhs) ? lhs.view() == rhs :
false;
3636 friend CTRE_FORCE_INLINE constexpr
bool operator!=(
const regex_results & lhs, std::basic_string_view<char_type> rhs) noexcept {
3637 return bool(lhs) ? lhs.view() != rhs :
true;
3639 friend CTRE_FORCE_INLINE constexpr
bool operator==(std::basic_string_view<char_type> lhs,
const regex_results & rhs) noexcept {
3640 return bool(rhs) ? lhs == rhs.view() :
false;
3642 friend CTRE_FORCE_INLINE constexpr
bool operator!=(std::basic_string_view<char_type> lhs,
const regex_results & rhs) noexcept {
3643 return bool(rhs) ? lhs != rhs.view() :
true;
3645 friend CTRE_FORCE_INLINE std::ostream &
operator<<(std::ostream &
str,
const regex_results & rhs) {
3646 return str << rhs.view();
3650 template <
size_t Id,
typename Iterator,
typename... Captures> constexpr
auto get(
const regex_results<Iterator, Captures...> &
results) noexcept {
3651 return results.template get<Id>();
3654 template <
typename Iterator,
typename... Captures> regex_results(Iterator,
ctll::list<Captures...>) -> regex_results<Iterator, Captures...>;
3656 template <
typename ResultIterator,
typename Pattern>
using return_type = decltype(regex_results(std::declval<ResultIterator>(), find_captures(
Pattern{})));
3664 #pragma clang diagnostic push
3665 #pragma clang diagnostic ignored "-Wmismatched-tags"
3669 template <
typename... Captures>
struct tuple_size<ctre::regex_results<Captures...>> :
public std::integral_constant<size_t, ctre::regex_results<Captures...>::count()> { };
3671 template <
size_t N,
typename... Captures>
struct tuple_element<
N, ctre::regex_results<Captures...>> {
3673 using type = decltype(
3674 std::declval<
const ctre::regex_results<Captures...> &>().
template get<N>()
3680 #pragma clang diagnostic pop
3686 #ifndef CTRE__FIND_CAPTURES__HPP
3687 #define CTRE__FIND_CAPTURES__HPP
3691 template <
typename Pattern> constexpr
auto find_captures(
Pattern) noexcept {
3699 template <
auto... String,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<string<String...>, Tail...>, Output
output) noexcept {
3703 template <
typename... Options,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<select<Options...>, Tail...>, Output
output) noexcept {
3707 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<optional<Content...>, Tail...>, Output
output) noexcept {
3711 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lazy_optional<Content...>, Tail...>, Output
output) noexcept {
3715 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<sequence<Content...>, Tail...>, Output
output) noexcept {
3736 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<plus<Content...>, Tail...>, Output
output) noexcept {
3740 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<star<Content...>, Tail...>, Output
output) noexcept {
3744 template <
size_t A,
size_t B,
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<repeat<A,B,Content...>, Tail...>, Output
output) noexcept {
3748 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lazy_plus<Content...>, Tail...>, Output
output) noexcept {
3752 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lazy_star<Content...>, Tail...>, Output
output) noexcept {
3756 template <
size_t A,
size_t B,
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lazy_repeat<A,B,Content...>, Tail...>, Output
output) noexcept {
3760 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<possessive_plus<Content...>, Tail...>, Output
output) noexcept {
3764 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<possessive_star<Content...>, Tail...>, Output
output) noexcept {
3768 template <
size_t A,
size_t B,
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<possessive_repeat<A,B,Content...>, Tail...>, Output
output) noexcept {
3772 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lookahead_positive<Content...>, Tail...>, Output
output) noexcept {
3776 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lookahead_negative<Content...>, Tail...>, Output
output) noexcept {
3780 template <
size_t Id,
typename... Content,
typename... Tail,
typename... Output> constexpr
auto find_captures(
ctll::list<capture<Id,Content...>, Tail...>,
ctll::list<Output...>) noexcept {
3784 template <
size_t Id,
typename Name,
typename... Content,
typename... Tail,
typename... Output> constexpr
auto find_captures(
ctll::list<capture_with_name<Id,Name,Content...>, Tail...>,
ctll::list<Output...>) noexcept {
3792 #ifndef CTRE__FIRST__HPP
3793 #define CTRE__FIRST__HPP
3797 struct can_be_anything {};
3800 template <
typename... Content>
3805 template <
typename... Content,
typename... Tail>
3810 template <
typename... Content,
typename... Tail>
3815 template <
typename... Content,
typename... Tail>
3820 template <
typename... Content,
typename... Tail>
3825 template <
typename... Content,
size_t Id,
typename... Tail>
3831 template <
typename... Content,
typename... Tail>
3837 template <
typename... Content,
typename CharLike,
typename... Tail>
3843 template <
typename... Content,
typename... Tail>
3848 template <
typename... Content,
typename... Tail>
3853 template <
typename... Content,
typename... Tail>
3859 template <
typename... Content,
typename... Tail>
3865 template <
typename... Content,
typename... Tail>
3872 template <
typename... Content,
typename... Seq,
typename... Tail>
3878 template <
typename... Content,
typename... Seq,
typename... Tail>
3884 template <
typename... Content,
typename... Seq,
typename... Tail>
3890 template <
typename... Content,
typename... Seq,
typename... Tail>
3896 template <
typename... Content,
typename... Seq,
typename... Tail>
3902 template <
typename... Content,
typename... Seq,
typename... Tail>
3908 template <
typename... Content,
typename... Seq,
typename... Tail>
3914 template <
typename... Content,
size_t A,
size_t B,
typename... Seq,
typename... Tail>
3919 template <
typename... Content,
size_t B,
typename... Seq,
typename... Tail>
3925 template <
typename... Content,
size_t A,
size_t B,
typename... Seq,
typename... Tail>
3930 template <
typename... Content,
size_t B,
typename... Seq,
typename... Tail>
3936 template <
typename... Content,
size_t A,
size_t B,
typename... Seq,
typename... Tail>
3941 template <
typename... Content,
size_t B,
typename... Seq,
typename... Tail>
3947 template <
typename... Content,
typename... Seq,
typename... Tail>
3953 template <
typename... Content,
typename... Seq,
typename... Tail>
3959 template <
typename... Content,
typename... Seq,
typename... Tail>
3965 template <
typename... Content,
typename... Seq,
typename... Tail>
3971 template <
typename... Content,
size_t Id,
typename... Seq,
typename... Tail>
3976 template <
typename... Content,
size_t Id,
typename Name,
typename... Seq,
typename... Tail>
3982 template <
typename... Content,
size_t Id,
typename... Tail>
3987 template <
typename... Content,
typename Name,
typename... Tail>
3993 template <
typename... Content,
auto First,
auto... String,
typename... Tail>
3995 return ctll::list<Content..., character<First>>{};
3998 template <
typename... Content,
typename... Tail>
4004 template <
typename... Content,
typename... Opt,
typename... Tail>
4009 template <
typename... Content,
typename... Opt,
typename... Tail>
4015 template <
typename... Content,
typename SHead,
typename... STail,
typename... Tail>
4020 template <
typename... Content,
typename... Tail>
4026 template <
typename... Content,
typename PropertyType, PropertyType Property,
typename... Tail>
4031 template <
typename... Content,
typename PropertyType, PropertyType Property,
auto Value,
typename... Tail>
4038 template <
typename... Content,
auto V,
typename... Tail>
4040 return ctll::list<Content..., character<V>>{};
4043 template <
typename... Content,
auto... Values,
typename... Tail>
4045 return ctll::list<Content..., character<Values>...>{};
4048 template <
typename... Content,
typename... SetContent,
typename... Tail>
4050 return ctll::list<Content..., SetContent...>{};
4053 template <
typename... Content,
auto A,
auto B,
typename... Tail>
4055 return ctll::list<Content..., char_range<A,B>>{};
4058 template <
typename... Content,
typename... Tail>
4064 template <
typename... Content,
typename... SetContent,
typename... Tail>
4066 return ctll::list<Content..., negative_set<SetContent...>>{};
4069 template <
typename... Content,
typename... SetContent,
typename... Tail>
4071 return ctll::list<Content..., negative_set<SetContent...>>{};
4075 template <
typename... Content> constexpr
auto calculate_first(Content...) noexcept {
4080 template <
typename... Content> constexpr
size_t calculate_size_of_first(ctre::negative_set<Content...>) {
4081 return 1 + calculate_size_of_first(ctre::set<Content...>{});
4084 template <
auto... V> constexpr
size_t calculate_size_of_first(ctre::enumeration<V...>) {
4085 return sizeof...(V);
4088 constexpr
size_t calculate_size_of_first(...) {
4093 return (calculate_size_of_first(Content{}) + ... + 0);
4096 template <
typename... Content> constexpr
size_t calculate_size_of_first(ctre::set<Content...>) {
4097 return (calculate_size_of_first(Content{}) + ... + 0);
4100 template <auto A,
typename CB> constexpr
int64_t negative_helper(ctre::character<A>,
CB & cb,
int64_t start) {
4113 template <auto A, auto B,
typename CB> constexpr
int64_t negative_helper(ctre::char_range<A,B>,
CB & cb,
int64_t start) {
4126 template <
auto Head,
auto... Tail,
typename CB> constexpr
int64_t negative_helper(ctre::enumeration<Head, Tail...>,
CB & cb,
int64_t start) {
4127 int64_t nstart = negative_helper(ctre::character<Head>{}, cb, start);
4128 return negative_helper(ctre::enumeration<Tail...>{}, cb, nstart);
4131 template <
typename CB> constexpr
int64_t negative_helper(ctre::enumeration<>,
CB &,
int64_t start) {
4135 template <
typename CB> constexpr
int64_t negative_helper(ctre::set<>,
CB &,
int64_t start) {
4139 template <
typename PropertyType, PropertyType Property,
typename CB>
4140 constexpr
auto negative_helper(ctre::binary_property<PropertyType, Property>,
CB &&,
int64_t start) {
4144 template <
typename PropertyType, PropertyType Property, auto Value,
typename CB>
4145 constexpr
auto negative_helper(ctre::property<PropertyType, Property, Value>,
CB &&,
int64_t start) {
4149 template <
typename Head,
typename... Rest,
typename CB> constexpr
int64_t negative_helper(ctre::set<Head, Rest...>,
CB & cb,
int64_t start) {
4150 start = negative_helper(Head{}, cb, start);
4151 return negative_helper(ctre::set<Rest...>{}, cb, start);
4155 start = negative_helper(Head{}, cb, start);
4156 negative_helper(ctre::negative_set<Rest...>{}, std::forward<CB>(cb), start);
4167 template <
size_t Capacity>
class point_set {
4171 constexpr
bool operator<(
const point & rhs)
const {
4172 return low < rhs.low;
4174 constexpr point() { }
4177 point points[Capacity+1]{};
4179 constexpr point * begin() {
4182 constexpr point * begin()
const {
4185 constexpr point * end() {
4186 return points + used;
4188 constexpr point * end()
const {
4189 return points + used;
4191 constexpr point * lower_bound(point obj) {
4192 auto first = begin();
4196 while (
count != 0) {
4198 auto step =
count / 2;
4199 std::advance(it, step);
4209 constexpr point * insert_point(
int64_t position,
int64_t other) {
4210 point obj{position, other};
4211 auto it = lower_bound(obj);
4236 constexpr point_set() { }
4238 insert_point(low, high);
4242 for (
auto r: *
this) {
4243 if (
r.low <= low && low <=
r.high) {
4245 }
else if (
r.low <= high && high <=
r.high) {
4247 }
else if (low <=
r.low &&
r.low <= high) {
4249 }
else if (low <=
r.high &&
r.high <= high) {
4257 template <auto V> constexpr
bool check(ctre::character<V>) {
4260 template <auto A, auto B> constexpr
bool check(ctre::char_range<A,B>) {
4263 constexpr
bool check(can_be_anything) {
4266 template <
typename... Content> constexpr
bool check(ctre::negative_set<Content...> nset) {
4267 bool collision =
false;
4269 collision |= this->
check(low, high);
4273 template <
auto... V> constexpr
bool check(ctre::enumeration<V...>) {
4275 return (
check(V,V) || ... ||
false);
4278 return (
check(Content{}) || ... ||
false);
4280 template <
typename... Content> constexpr
bool check(ctre::set<Content...>) {
4281 return (
check(Content{}) || ... ||
false);
4285 template <auto V> constexpr
void populate(ctre::character<V>) {
4288 template <auto A, auto B> constexpr
void populate(ctre::char_range<A,B>) {
4291 constexpr
void populate(...) {
4296 template <
typename... Content> constexpr
void populate(ctre::negative_set<Content...> nset) {
4298 this->insert(low, high);
4301 template <
typename... Content> constexpr
void populate(ctre::set<Content...>) {
4302 (populate(Content{}), ...);
4305 (populate(Content{}), ...);
4310 constexpr
size_t capacity = calculate_size_of_first(rhs);
4312 point_set<capacity>
set;
4315 return set.check(lhs);
4326 #ifndef CTRE_MSVC_GREEDY_WORKAROUND
4327 #define CTRE_MSVC_GREEDY_WORKAROUND
4333 template <
size_t Limit> constexpr CTRE_FORCE_INLINE
bool less_than_or_infinite([[maybe_unused]]
size_t i) noexcept {
4334 if constexpr (Limit == 0) {
4342 template <
size_t Limit> constexpr CTRE_FORCE_INLINE
bool less_than([[maybe_unused]]
size_t i) noexcept {
4343 if constexpr (Limit == 0) {
4351 constexpr
bool is_bidirectional(
const std::bidirectional_iterator_tag &) {
return true; }
4352 constexpr
bool is_bidirectional(...) {
return false; }
4355 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator>
4356 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator, Iterator,
const EndIterator,
flags,
R, ...) noexcept {
4361 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator>
4362 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator, Iterator,
const EndIterator,
flags,
R captures,
ctll::list<accept>) noexcept {
4363 return captures.matched();
4367 template <
typename R,
typename... Rest,
typename BeginIterator,
typename Iterator,
typename EndIterator>
4373 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4379 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4385 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4386 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator, Iterator current,
const EndIterator, [[maybe_unused]]
const flags &
f,
R captures,
ctll::list<end_cycle_mark>) noexcept {
4387 if (cannot_be_empty_match(
f)) {
4391 return captures.set_end_mark(current).matched();
4396 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename CharacterLike,
typename... Tail,
typename = std::enable_if_t<(MatchesCharacter<CharacterLike>::template value<decltype(*std::declval<Iterator>())>)>>
4398 if (current ==
last)
return not_matched;
4399 if (!CharacterLike::match_char(*current,
f))
return not_matched;
4404 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4406 if (current ==
last)
return not_matched;
4408 if (multiline_mode(
f)) {
4410 if (*current ==
'\n')
return not_matched;
4416 template <
auto... String,
typename Iterator,
typename EndIterator> constexpr CTRE_FORCE_INLINE
bool match_string([[maybe_unused]] Iterator & current, [[maybe_unused]]
const EndIterator
last, [[maybe_unused]]
const flags &
f) {
4417 return ((current !=
last && character<String>::match_char(*current++,
f)) && ... &&
true);
4420 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
auto... String,
typename... Tail>
4421 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator begin, Iterator current,
const EndIterator
last, [[maybe_unused]]
const flags &
f,
R captures,
ctll::list<string<String...>, Tail...>) noexcept {
4422 if (!match_string<String...>(current,
last,
f)) {
4426 return evaluate(begin, current,
last, consumed_something(
f,
sizeof...(String) > 0), captures,
ctll::list<Tail...>());
4430 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename HeadOptions,
typename... TailOptions,
typename... Tail>
4431 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator begin, Iterator current,
const EndIterator
last,
const flags &
f,
R captures,
ctll::list<select<HeadOptions, TailOptions...>, Tail...>) noexcept {