221 #ifndef CTRE_V2__CTRE__HPP
222 #define CTRE_V2__CTRE__HPP
224 #ifndef CTRE_V2__CTRE__LITERALS__HPP
225 #define CTRE_V2__CTRE__LITERALS__HPP
227 #ifndef CTRE_V2__CTLL__HPP
228 #define CTRE_V2__CTLL__HPP
230 #ifndef CTLL__PARSER__HPP
231 #define CTLL__PARSER__HPP
233 #ifndef CTLL__FIXED_STRING__GPP
234 #define CTLL__FIXED_STRING__GPP
238 #include <string_view>
243 struct length_value_t {
249 if ((first_unit & 0b1000'0000) == 0b0000'0000)
return {
static_cast<uint32_t>(first_unit), 1};
250 else if ((first_unit & 0b1110'0000) == 0b1100'0000)
return {
static_cast<uint32_t>(first_unit & 0b0001'1111), 2};
251 else if ((first_unit & 0b1111'0000) == 0b1110'0000)
return {
static_cast<uint32_t>(first_unit & 0b0000'1111), 3};
252 else if ((first_unit & 0b1111'1000) == 0b1111'0000)
return {
static_cast<uint32_t>(first_unit & 0b0000'0111), 4};
253 else if ((first_unit & 0b1111'1100) == 0b1111'1000)
return {
static_cast<uint32_t>(first_unit & 0b0000'0011), 5};
254 else if ((first_unit & 0b1111'1100) == 0b1111'1100)
return {
static_cast<uint32_t>(first_unit & 0b0000'0001), 6};
259 if ((unit & 0b1100'0000) == 0b1000'0000)
return unit & 0b0011'1111;
267 if ((first_unit & 0b1111110000000000) == 0b1101'1000'0000'0000)
return {
static_cast<uint32_t>(first_unit & 0b0000001111111111), 2};
268 else return {first_unit, 1};
276 if constexpr (std::is_same_v<T, char>) {
277 #ifdef CTRE_STRING_IS_UTF8
279 for (
size_t i{0};
i <
N; ++
i) {
280 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
282 switch (
info.length) {
308 for (
size_t i{0};
i <
N; ++
i) {
310 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
315 }
else if constexpr (std::is_same_v<T, char8_t>) {
317 for (
size_t i{0};
i <
N; ++
i) {
318 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
320 switch (
info.length) {
346 }
else if constexpr (std::is_same_v<T, char16_t>) {
348 for (
size_t i{0};
i <
N; ++
i) {
350 if (
info.length == 2) {
352 if ((
input[
i] & 0b1111'1100'0000'0000) == 0b1101'1100'0000'0000) {
360 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
365 }
else if constexpr (std::is_same_v<T, wchar_t> || std::is_same_v<T, char32_t>) {
366 for (
size_t i{0};
i <
N; ++
i) {
368 if ((
i == (
N-1)) && (
input[
i] == 0))
break;
374 for (
size_t i{0};
i <
N; ++
i) {
396 if (
real_size != rhs.size())
return false;
402 constexpr
operator std::basic_string_view<char32_t>()
const noexcept {
403 return std::basic_string_view<char32_t>{
content,
size()};
408 static constexpr char32_t
empty[1] = {0};
434 constexpr
operator std::basic_string_view<char32_t>()
const noexcept {
435 return std::basic_string_view<char32_t>{
empty, 0};
440 template <
size_t N>
fixed_string(fixed_string<N>) -> fixed_string<N>;
446 #ifndef CTLL__TYPE_STACK__HPP
447 #define CTLL__TYPE_STACK__HPP
449 #ifndef CTLL__UTILITIES__HPP
450 #define CTLL__UTILITIES__HPP
452 #include <type_traits>
454 #if defined __cpp_nontype_template_parameter_class
455 #define CTLL_CNTTP_COMPILER_CHECK 1
456 #elif defined __cpp_nontype_template_args
458 #if __cpp_nontype_template_args >= 201911L
459 #define CTLL_CNTTP_COMPILER_CHECK 1
460 #elif __cpp_nontype_template_args >= 201411L
462 #if defined __apple_build_version__
463 #if defined __clang_major__ && __clang_major__ >= 13
465 #if __cplusplus > 201703L
466 #define CTLL_CNTTP_COMPILER_CHECK 1
471 #if defined __clang_major__ && __clang_major__ >= 12
473 #if __cplusplus > 201703L
474 #define CTLL_CNTTP_COMPILER_CHECK 1
481 #ifndef CTLL_CNTTP_COMPILER_CHECK
482 #define CTLL_CNTTP_COMPILER_CHECK 0
486 #define CTLL_FORCE_INLINE __forceinline
488 #define CTLL_FORCE_INLINE __attribute__((always_inline))
493 template <
bool>
struct conditional_helper;
495 template <>
struct conditional_helper<
true> {
496 template <
typename A,
typename>
using type =
A;
500 template <
typename,
typename B>
using type =
B;
511 template <
typename... Ts>
struct list { };
518 template <
typename... Ts> constexpr
auto size(list<Ts...>) noexcept {
return sizeof...(Ts); }
522 template <
typename... Ts> constexpr
bool empty(list<Ts...>) noexcept {
return false; }
526 template <
typename... As,
typename... Bs> constexpr
auto concat(list<As...>, list<Bs...>) noexcept -> list<As..., Bs...> {
return {}; }
529 template <
typename T,
typename... As> constexpr
auto push_front(
T, list<As...>) noexcept -> list<
T, As...> {
return {}; }
532 template <
typename T,
typename... As> constexpr
auto pop_front(list<T, As...>) noexcept -> list<As...> {
return {}; }
536 template <
typename Front,
typename List>
struct list_pop_pair {
546 template <
typename Head,
typename... As,
typename T = _nothing> constexpr
auto front(list<Head, As...>,
T =
T()) noexcept -> Head {
return {}; }
547 template <
typename T = _nothing> constexpr
auto front(
empty_list,
T =
T()) noexcept ->
T {
return {}; }
550 template <
typename T>
struct rotate_item {
554 template <
typename... Ts> constexpr
auto rotate(list<Ts...>) -> decltype((list<>{} + ... + rotate_item<Ts>{})) {
559 template <
typename T>
struct item_matcher {
560 struct not_selected {
563 template <
typename Y>
struct wrapper {
567 static constexpr
auto check(
T) {
return std::true_type{}; }
568 static constexpr
auto check(...) {
return std::false_type{}; }
573 template <
typename T,
typename... Ts> constexpr
bool exists_in(
T, list<Ts...>) noexcept {
577 template <
typename T,
typename... Ts> constexpr
auto add_item(
T item, list<Ts...>
l) noexcept {
581 return list<Ts...,
T>{};
585 template <
typename T,
typename... Ts> constexpr
auto remove_item(
T, list<Ts...>) noexcept {
586 item_matcher<T> matcher;
587 return decltype((list<>{} + ... + matcher.select(Ts{}))){};
594 #ifndef CTLL__GRAMMARS__HPP
595 #define CTLL__GRAMMARS__HPP
600 template <auto v>
struct term {
601 static constexpr
auto value = v;
607 static constexpr
auto value =
'-';
611 struct empty_stack_symbol {};
614 template <
typename... Ts>
using push = list<Ts...>;
617 struct accept { constexpr
explicit operator bool() noexcept {
return true; } };
618 struct reject { constexpr
explicit operator bool() noexcept {
return false; } };
622 struct action_tag { };
627 struct pop_input_tag { };
631 template <
typename... Ts> constexpr
auto push_front(pop_input, list<Ts...>) -> list<Ts...> {
return {}; }
633 template <
typename... Ts> constexpr
auto push_front(
epsilon, list<Ts...>) -> list<Ts...> {
return {}; }
635 template <
typename... As,
typename... Bs> constexpr
auto push_front(list<As...>, list<Bs...>) -> list<As..., Bs...> {
return {}; }
650 template <auto A, decltype(A) B>
struct range {
651 constexpr
inline range() noexcept { }
653 template <auto V,
typename = std::enable_if_t<(A <= V) && (V <= B)>> constexpr inline range(term<V>) noexcept;
657 template <auto V, auto... Set>
struct contains {
658 static constexpr
bool value = ((Set == V) || ... ||
false);
663 template <
auto... Def>
struct set {
664 constexpr
inline set() noexcept { }
666 template <
auto V,
typename = std::enable_if_t<contains<V, Def...>
::value>> constexpr
inline set(
term<V>) noexcept;
668 template <
auto V,
typename = std::enable_if_t<((Def == V) || ... ||
false)>> constexpr
inline set(
term<V>) noexcept;
673 template <
auto... Def>
struct neg_set {
677 template <
auto V,
typename = std::enable_if_t<!contains<V, Def...>
::value>> constexpr
inline neg_set(
term<V>) noexcept;
679 template <
auto V,
typename = std::enable_if_t<!((Def == V) || ... ||
false)>> constexpr
inline neg_set(
term<V>) noexcept;
686 using typename Grammar::_start;
695 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>;
711 #ifndef CTLL__ACTIONS__HPP
712 #define CTLL__ACTIONS__HPP
715 struct empty_subject { };
717 struct empty_actions {
719 template <
typename Action,
typename InputSymbol,
typename Subject>
static constexpr
auto apply(Action, InputSymbol, Subject
subject) {
724 template <
typename Actions>
struct identity:
public Actions {
725 using Actions::apply;
731 template <
typename Actions>
struct ignore_unknown:
public Actions {
732 using Actions::apply;
734 template <
typename Action, auto V,
typename Subject> constexpr
static auto apply(Action,
term<V>, Subject) -> Subject {
return {}; }
735 template <
typename Action,
typename Subject> constexpr
static auto apply(Action,
epsilon, Subject) -> Subject {
return {}; }
751 struct placeholder { };
755 #if CTLL_CNTTP_COMPILER_CHECK
756 template <
typename Grammar, ctll::fixed_
string input,
typename ActionSelector = empty_actions,
bool IgnoreUnknownActions = false>
struct parser {
758 template <
typename Grammar, const auto & input,
typename ActionSelector = empty_actions,
bool IgnoreUnknownActions = false>
struct parser {
762 #if CTLL_CNTTP_COMPILER_CHECK
774 template <
size_t Pos,
typename Stack,
typename Subject, decision Decision>
struct results {
783 #if CTLL_CNTTP_COMPILER_CHECK
793 static constexpr
size_t position =
Pos;
821 if constexpr (
Pos == 0) {
824 }
else if constexpr ((
Pos-1) <
input.size()) {
836 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
841 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
846 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
851 template <
size_t Pos,
typename... Content,
typename Terminal,
typename Stack,
typename Subject>
856 template <
size_t Pos,
typename Terminal,
typename Stack,
typename Subject>
858 return decide<Pos>(stack,
subject);
862 template <
size_t Pos,
auto V,
typename... Content,
typename Stack,
typename Subject>
864 constexpr
auto local_input =
input;
869 template <
size_t Pos,
auto V,
typename... Content,
auto T,
typename Stack,
typename Subject>
871 constexpr
auto local_input =
input;
875 template <
size_t Pos,
typename Stack,
typename Subject>
static constexpr
auto decide(Stack previous_stack, Subject previous_subject) noexcept {
879 [[maybe_unused]]
auto stack = decltype(
ctll::pop_front(previous_stack))();
882 if constexpr (std::is_base_of_v<
ctll::action, decltype(top_symbol)>) {
883 auto subject = Actions::apply(top_symbol, get_previous_term<Pos>(), previous_subject);
889 return decide<Pos>(stack,
subject);
893 auto current_term = get_current_term<Pos>();
894 auto rule = decltype(
grammar::rule(top_symbol,current_term))();
895 return move<Pos>(rule, current_term, stack, previous_subject);
900 template <
typename Subject,
size_t...
Pos>
static constexpr
auto trampoline_decide(Subject, std::index_sequence<Pos...>) noexcept {
912 template <
typename Subject = empty_subject>
using output = decltype(trampoline_decide<Subject>());
913 template <
typename Subject = empty_subject>
static inline constexpr
bool correct_with = trampoline_decide<Subject>();
923 #ifndef CTRE__PCRE_ACTIONS__HPP
924 #define CTRE__PCRE_ACTIONS__HPP
926 #ifndef CTRE__PCRE__HPP
927 #define CTRE__PCRE__HPP
939 struct backslash_range {};
941 struct block_name2 {};
943 struct class_named_name {};
946 struct content_in_capture {};
952 struct hexdec_repeat {};
959 struct mode_switch2 {};
965 struct property_name2 {};
966 struct property_name {};
967 struct property_value2 {};
968 struct property_value {};
971 struct s {};
using _start = s;
1029 struct push_assert_subject_end_with_lineend:
ctll::action {};
1037 struct push_character_return_carriage:
ctll::action {};
1064 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'>;
1070 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>;
1082 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>;
1103 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>;
1112 static constexpr
auto rule(backslash,
ctll::set<
'$',
'\x28',
'\x29',
'*',
'+',
'-',
'.',
'/',
'<',
'>',
'?',
'[',
'\\',
'\"',
']',
'^',
'\x7B',
'|',
'\x7D'>) ->
ctll::push<ctll::anything, push_character>;
1125 static constexpr
auto rule(backslash_range,
ctll::set<
'$',
'\x28',
'\x29',
'*',
'+',
'-',
'.',
'/',
'<',
'>',
'?',
'[',
'\\',
'\"',
']',
'^',
'\x7B',
'|',
'\x7D'>) ->
ctll::push<ctll::anything, push_character>;
1140 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'>>;
1147 static constexpr
auto rule(block_name2,
ctll::set<'>','\x7D
'>) -> ctll::epsilon;
1148 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>;
1152 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<']'>>;
1178 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>;
1188 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>;
1201 static constexpr
auto rule(d,
ctll::term<'>'>) -> ctll::push<ctll::anything, reset_capture, start_atomic, content_in_capture, make_atomic, ctll::term<'\x29
'>>;
1202 static constexpr auto rule(d, ctll::term<'!
'>) -> ctll::push<ctll::anything, reset_capture, start_lookahead_negative, content_in_capture, look_finish, ctll::term<'\x29
'>>;
1203 static constexpr auto rule(d, ctll::term<'=
'>) -> ctll::push<ctll::anything, reset_capture, start_lookahead_positive, content_in_capture, look_finish, ctll::term<'\x29
'>>;
1205 static constexpr auto rule(e, ctll::term<'d
'>) -> ctll::push<ctll::anything, class_digit>;
1206 static constexpr auto rule(e, ctll::term<'h
'>) -> ctll::push<ctll::anything, class_horizontal_space>;
1207 static constexpr auto rule(e, ctll::term<'H'>) -> ctll::push<ctll::anything, class_non_horizontal_space>;
1208 static constexpr auto rule(e, ctll::term<'V
'>) -> ctll::push<ctll::anything, class_non_vertical_space>;
1209 static constexpr auto rule(e, ctll::term<'D'>) -> ctll::push<ctll::anything, class_nondigit>;
1210 static constexpr auto rule(e, ctll::term<'N'>) -> ctll::push<ctll::anything, class_nonnewline>;
1211 static constexpr auto rule(e, ctll::term<'S'>) -> ctll::push<ctll::anything, class_nonspace>;
1212 static constexpr auto rule(e, ctll::term<'W'>) -> ctll::push<ctll::anything, class_nonword>;
1213 static constexpr auto rule(e, ctll::term<'s
'>) -> ctll::push<ctll::anything, class_space>;
1214 static constexpr auto rule(e, ctll::term<'v
'>) -> ctll::push<ctll::anything, class_vertical_space>;
1215 static constexpr auto rule(e, ctll::term<'w
'>) -> ctll::push<ctll::anything, class_word>;
1216 static constexpr auto rule(e, ctll::term<'p
'>) -> ctll::push<ctll::anything, ctll::term<'\x7B
'>, property_name, ctll::term<'\x7D
'>, make_property>;
1217 static constexpr auto rule(e, ctll::term<'P'>) -> ctll::push<ctll::anything, ctll::term<'\x7B
'>, property_name, ctll::term<'\x7D
'>, make_property_negative>;
1218 static constexpr auto rule(e, ctll::term<'u
'>) -> ctll::push<ctll::anything, k, range>;
1219 static constexpr auto rule(e, ctll::term<'x
'>) -> ctll::push<ctll::anything, l, range>;
1220 static constexpr auto rule(e, ctll::set<'$
','\x28
','\x29
','*
','+
','-
','.
','/
','<
','>
','?
','[
','\\
','\
"',']','^','\x7B','|','\x7D'>) -> ctll::push<ctll::anything, push_character, range>;
1221 static constexpr auto rule(e, ctll::term<'a'>) -> ctll::push<ctll::anything, push_character_alarm, range>;
1222 static constexpr auto rule(e, ctll::term<'e'>) -> ctll::push<ctll::anything, push_character_escape, range>;
1223 static constexpr auto rule(e, ctll::term<'f'>) -> ctll::push<ctll::anything, push_character_formfeed, range>;
1224 static constexpr auto rule(e, ctll::term<'n'>) -> ctll::push<ctll::anything, push_character_newline, range>;
1225 static constexpr auto rule(e, ctll::term<'0'>) -> ctll::push<ctll::anything, push_character_null, range>;
1226 static constexpr auto rule(e, ctll::term<'r'>) -> ctll::push<ctll::anything, push_character_return_carriage, range>;
1227 static constexpr auto rule(e, ctll::term<'t'>) -> ctll::push<ctll::anything, push_character_tab, range>;
1229 static constexpr auto rule(f, ctll::term<'d'>) -> ctll::push<ctll::anything, class_digit>;
1230 static constexpr auto rule(f, ctll::term<'h'>) -> ctll::push<ctll::anything, class_horizontal_space>;
1231 static constexpr auto rule(f, ctll::term<'H'>) -> ctll::push<ctll::anything, class_non_horizontal_space>;
1232 static constexpr auto rule(f, ctll::term<'V'>) -> ctll::push<ctll::anything, class_non_vertical_space>;
1233 static constexpr auto rule(f, ctll::term<'D'>) -> ctll::push<ctll::anything, class_nondigit>;
1234 static constexpr auto rule(f, ctll::term<'N'>) -> ctll::push<ctll::anything, class_nonnewline>;
1235 static constexpr auto rule(f, ctll::term<'S'>) -> ctll::push<ctll::anything, class_nonspace>;
1236 static constexpr auto rule(f, ctll::term<'W'>) -> ctll::push<ctll::anything, class_nonword>;
1237 static constexpr auto rule(f, ctll::term<'s'>) -> ctll::push<ctll::anything, class_space>;
1238 static constexpr auto rule(f, ctll::term<'v'>) -> ctll::push<ctll::anything, class_vertical_space>;
1239 static constexpr auto rule(f, ctll::term<'w'>) -> ctll::push<ctll::anything, class_word>;
1240 static constexpr auto rule(f, ctll::term<'p'>) -> ctll::push<ctll::anything, ctll::term<'\x7B'>, property_name, ctll::term<'\x7D'>, make_property>;
1241 static constexpr auto rule(f, ctll::term<'P'>) -> ctll::push<ctll::anything, ctll::term<'\x7B'>, property_name, ctll::term<'\x7D'>, make_property_negative>;
1242 static constexpr auto rule(f, ctll::term<'u'>) -> ctll::push<ctll::anything, k, range>;
1243 static constexpr auto rule(f, ctll::term<'x'>) -> ctll::push<ctll::anything, l, range>;
1244 static constexpr auto rule(f, ctll::set<'$','\x28','\x29','*','+','-','.','/','<','>','?','[','\\','\"',']','^','\x7B','|','\x7D'>) -> ctll::push<ctll::anything, push_character, range>;
1245 static constexpr auto rule(f, ctll::term<'a'>) -> ctll::push<ctll::anything, push_character_alarm, range>;
1246 static constexpr auto rule(f, ctll::term<'e'>) -> ctll::push<ctll::anything, push_character_escape, range>;
1247 static constexpr auto rule(f, ctll::term<'f'>) -> ctll::push<ctll::anything, push_character_formfeed, range>;
1248 static constexpr auto rule(f, ctll::term<'n'>) -> ctll::push<ctll::anything, push_character_newline, range>;
1249 static constexpr auto rule(f, ctll::term<'0'>) -> ctll::push<ctll::anything, push_character_null, range>;
1250 static constexpr auto rule(f, ctll::term<'r'>) -> ctll::push<ctll::anything, push_character_return_carriage, range>;
1251 static constexpr auto rule(f, ctll::term<'t'>) -> ctll::push<ctll::anything, push_character_tab, range>;
1253 static constexpr auto rule(g, ctll::term<'s'>) -> ctll::push<ctll::anything, ctll::term<'c'>, ctll::term<'i'>, ctll::term<'i'>, class_named_ascii>;
1254 static constexpr auto rule(g, ctll::term<'l'>) -> ctll::push<ctll::anything, p>;
1256 static constexpr auto rule(h, ctll::term<'r'>) -> ctll::push<ctll::anything, ctll::term<'i'>, ctll::term<'n'>, ctll::term<'t'>, class_named_print>;
1257 static constexpr auto rule(h, ctll::term<'u'>) -> ctll::push<ctll::anything, ctll::term<'n'>, ctll::term<'c'>, ctll::term<'t'>, class_named_punct>;
1259 static constexpr auto rule(hexdec_repeat, ctll::term<'\x7D'>) -> ctll::epsilon;
1260 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>;
1262 static constexpr auto rule(i, ctll::term<'^'>) -> ctll::push<ctll::anything, class_named_name, negate_class_named, ctll::term<':'>, ctll::term<']'>>;
1263 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<']'>>;
1264 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<']'>>;
1265 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<']'>>;
1266 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<']'>>;
1267 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<']'>>;
1268 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<']'>>;
1269 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<']'>>;
1270 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<']'>>;
1271 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<']'>>;
1272 static constexpr auto rule(i, ctll::term<'a'>) -> ctll::push<ctll::anything, g, ctll::term<':'>, ctll::term<']'>>;
1273 static constexpr auto rule(i, ctll::term<'p'>) -> ctll::push<ctll::anything, h, ctll::term<':'>, ctll::term<']'>>;
1275 static constexpr auto rule(j, ctll::term<'\\'>) -> ctll::push<ctll::anything, backslash_range, make_range>;
1276 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>;
1277 static constexpr auto rule(j, _others) -> ctll::push<ctll::anything, push_character, make_range>;
1278 static constexpr auto rule(j, ctll::set<'-','[',']'>) -> ctll::reject;
1280 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>;
1281 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>;
1283 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>;
1284 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>;
1286 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>;
1287 static constexpr auto rule(m, ctll::term<'-'>) -> ctll::push<ctll::anything, number, ctll::term<'\x7D'>, make_relative_back_reference>;
1288 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>;
1290 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;
1291 static constexpr auto rule(mod, ctll::epsilon) -> ctll::epsilon;
1292 static constexpr auto rule(mod, _others) -> ctll::epsilon;
1293 static constexpr auto rule(mod, ctll::term<'?'>) -> ctll::push<ctll::anything, make_lazy>;
1294 static constexpr auto rule(mod, ctll::term<'+'>) -> ctll::push<ctll::anything, make_possessive>;
1295 static constexpr auto rule(mod, ctll::set<'*','\x7B','\x7D'>) -> ctll::reject;
1297 static constexpr auto rule(mode_switch2, ctll::term<'i'>) -> ctll::push<ctll::anything, mode_case_insensitive, mode_switch2>;
1298 static constexpr auto rule(mode_switch2, ctll::term<'c'>) -> ctll::push<ctll::anything, mode_case_sensitive, mode_switch2>;
1299 static constexpr auto rule(mode_switch2, ctll::term<'m'>) -> ctll::push<ctll::anything, mode_multiline, mode_switch2>;
1300 static constexpr auto rule(mode_switch2, ctll::term<'s'>) -> ctll::push<ctll::anything, mode_singleline, mode_switch2>;
1301 static constexpr auto rule(mode_switch2, ctll::term<'\x29'>) -> ctll::push<ctll::anything>;
1303 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>;
1304 static constexpr auto rule(n, ctll::term<'\x7D'>) -> ctll::push<repeat_at_least, ctll::anything, mod>;
1306 static constexpr auto rule(number2, ctll::set<',','\x7D'>) -> ctll::epsilon;
1307 static constexpr auto rule(number2, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, push_number, number2>;
1309 static constexpr auto rule(number, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push<ctll::anything, create_number, number2>;
1311 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'>>;
1312 static constexpr auto rule(o, ctll::term<'!'>) -> ctll::push<ctll::anything, reset_capture, start_lookbehind_negative, content_in_capture, look_finish, ctll::term<'\x29'>>;
1313 static constexpr auto rule(o, ctll::term<'='>) -> ctll::push<ctll::anything, reset_capture, start_lookbehind_positive, content_in_capture, look_finish, ctll::term<'\x29'>>;
1315 static constexpr auto rule(p, ctll::term<'p'>) -> ctll::push<ctll::anything, ctll::term<'h'>, ctll::term<'a'>, class_named_alpha>;
1316 static constexpr auto rule(p, ctll::term<'n'>) -> ctll::push<ctll::anything, ctll::term<'u'>, ctll::term<'m'>, class_named_alnum>;
1318 static constexpr auto rule(property_name2, ctll::term<'\x7D'>) -> ctll::epsilon;
1319 static constexpr auto rule(property_name2, ctll::term<'='>) -> ctll::push<ctll::anything, property_value>;
1320 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>;
1322 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>;
1324 static constexpr auto rule(property_value2, ctll::term<'\x7D'>) -> ctll::epsilon;
1325 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>;
1327 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>;
1329 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;
1330 static constexpr auto rule(range, ctll::epsilon) -> ctll::epsilon;
1331 static constexpr auto rule(range, _others) -> ctll::epsilon;
1332 static constexpr auto rule(range, ctll::term<'-'>) -> ctll::push<ctll::anything, j>;
1334 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;
1335 static constexpr auto rule(repeat, ctll::epsilon) -> ctll::epsilon;
1336 static constexpr auto rule(repeat, _others) -> ctll::epsilon;
1337 static constexpr auto rule(repeat, ctll::term<'?'>) -> ctll::push<ctll::anything, make_optional, mod>;
1338 static constexpr auto rule(repeat, ctll::term<'\x7B'>) -> ctll::push<ctll::anything, number, b>;
1339 static constexpr auto rule(repeat, ctll::term<'+'>) -> ctll::push<ctll::anything, repeat_plus, mod>;
1340 static constexpr auto rule(repeat, ctll::term<'*'>) -> ctll::push<ctll::anything, repeat_star, mod>;
1341 static constexpr auto rule(repeat, ctll::term<'\x7D'>) -> ctll::reject;
1343 static constexpr auto rule(set2a, ctll::term<']'>) -> ctll::epsilon;
1344 static constexpr auto rule(set2a, ctll::term<'['>) -> ctll::push<ctll::anything, ctll::term<':'>, i, range, set_start, set2b>;
1345 static constexpr auto rule(set2a, ctll::term<'\\'>) -> ctll::push<ctll::anything, f, set_start, set2b>;
1346 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>;
1347 static constexpr auto rule(set2a, _others) -> ctll::push<ctll::anything, push_character, range, set_start, set2b>;
1348 static constexpr auto rule(set2a, ctll::term<'-'>) -> ctll::reject;
1350 static constexpr auto rule(set2b, ctll::term<']'>) -> ctll::epsilon;
1351 static constexpr auto rule(set2b, ctll::term<'['>) -> ctll::push<ctll::anything, ctll::term<':'>, i, range, set_combine, set2b>;
1352 static constexpr auto rule(set2b, ctll::term<'\\'>) -> ctll::push<ctll::anything, f, set_combine, set2b>;
1353 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>;
1354 static constexpr auto rule(set2b, _others) -> ctll::push<ctll::anything, push_character, range, set_combine, set2b>;
1355 static constexpr auto rule(set2b, ctll::term<'-'>) -> ctll::reject;
1357 static constexpr auto rule(string2, ctll::set<'\x29','|'>) -> ctll::epsilon;
1358 static constexpr auto rule(string2, ctll::epsilon) -> ctll::epsilon;
1359 static constexpr auto rule(string2, ctll::term<'\\'>) -> ctll::push<ctll::anything, backslash, repeat, string2, make_sequence>;
1360 static constexpr auto rule(string2, ctll::term<'['>) -> ctll::push<ctll::anything, c, repeat, string2, make_sequence>;
1361 static constexpr auto rule(string2, ctll::term<'\x28'>) -> ctll::push<ctll::anything, prepare_capture, block, repeat, string2, make_sequence>;
1362 static constexpr auto rule(string2, ctll::term<'^'>) -> ctll::push<ctll::anything, push_assert_begin, repeat, string2, make_sequence>;
1363 static constexpr auto rule(string2, ctll::term<'$'>) -> ctll::push<ctll::anything, push_assert_end, repeat, string2, make_sequence>;
1364 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>;
1365 static constexpr auto rule(string2, _others) -> ctll::push<ctll::anything, push_character, repeat, string2, make_sequence>;
1366 static constexpr auto rule(string2, ctll::term<'.'>) -> ctll::push<ctll::anything, push_character_anything, repeat, string2, make_sequence>;
1367 static constexpr auto rule(string2, ctll::set<'*','+','?','\x7B','\x7D'>) -> ctll::reject;
1373 #endif //CTRE__PCRE__HPP
1375 #ifndef CTRE__ROTATE__HPP
1376 #define CTRE__ROTATE__HPP
1378 #ifndef CTRE__ATOMS__HPP
1379 #define CTRE__ATOMS__HPP
1381 #ifndef CTRE__ATOMS_CHARACTERS__HPP
1382 #define CTRE__ATOMS_CHARACTERS__HPP
1384 #ifndef CTRE__UTILITY__HPP
1385 #define CTRE__UTILITY__HPP
1387 #define CTRE_CNTTP_COMPILER_CHECK CTLL_CNTTP_COMPILER_CHECK
1390 #if __has_cpp_attribute(likely)
1391 #define CTRE_LIKELY [[likely]]
1396 #if __has_cpp_attribute(unlikely)
1397 #define CTRE_UNLIKELY [[unlikely]]
1399 #define CTRE_UNLIKELY
1403 #define CTRE_UNLIKELY
1407 #define CTRE_FORCE_INLINE __forceinline
1408 #if _MSC_VER >= 1930
1409 #define CTRE_FLATTEN [[msvc::flatten]]
1411 #define CTRE_FLATTEN
1414 #define CTRE_FORCE_INLINE inline __attribute__((always_inline))
1415 #define CTRE_FLATTEN __attribute__((flatten))
1420 #ifndef CTRE_V2__CTRE__FLAGS_AND_MODES__HPP
1421 #define CTRE_V2__CTRE__FLAGS_AND_MODES__HPP
1425 struct singleline { };
1426 struct multiline { };
1428 struct case_sensitive { };
1429 struct case_insensitive { };
1431 using ci = case_insensitive;
1432 using cs = case_sensitive;
1434 template <typename... Flags> struct flag_list { };
1437 bool block_empty_match = false;
1438 bool multiline = false;
1439 bool case_insensitive = false;
1441 constexpr flags() = default;
1442 constexpr flags(const flags &) = default;
1443 constexpr flags(flags &&) = default;
1445 constexpr CTRE_FORCE_INLINE flags(ctre::singleline v) noexcept { set_flag(v); }
1446 constexpr CTRE_FORCE_INLINE flags(ctre::multiline v) noexcept { set_flag(v); }
1447 constexpr CTRE_FORCE_INLINE flags(ctre::case_sensitive v) noexcept { set_flag(v); }
1448 constexpr CTRE_FORCE_INLINE flags(ctre::case_insensitive v) noexcept { set_flag(v); }
1451 template <typename... Args> constexpr CTRE_FORCE_INLINE flags(ctll::list<Args...>) noexcept {
1452 (this->set_flag(Args{}), ...);
1455 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_case_insensitive) noexcept {
1456 f.case_insensitive = true;
1460 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_case_sensitive) noexcept {
1461 f.case_insensitive = false;
1465 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_singleline) noexcept {
1466 f.multiline = false;
1470 constexpr friend CTRE_FORCE_INLINE auto operator+(flags f, pcre::mode_multiline) noexcept {
1475 constexpr CTRE_FORCE_INLINE void set_flag(ctre::singleline) noexcept {
1479 constexpr CTRE_FORCE_INLINE void set_flag(ctre::multiline) noexcept {
1483 constexpr CTRE_FORCE_INLINE void set_flag(ctre::case_insensitive) noexcept {
1484 case_insensitive = true;
1487 constexpr CTRE_FORCE_INLINE void set_flag(ctre::case_sensitive) noexcept {
1488 case_insensitive = false;
1492 constexpr CTRE_FORCE_INLINE auto not_empty_match(flags f) {
1493 f.block_empty_match = true;
1497 constexpr CTRE_FORCE_INLINE auto consumed_something(flags f, bool condition = true) {
1498 if (condition) f.block_empty_match = false;
1502 constexpr CTRE_FORCE_INLINE bool cannot_be_empty_match(flags f) {
1503 return f.block_empty_match;
1506 constexpr CTRE_FORCE_INLINE bool multiline_mode(flags f) {
1510 constexpr CTRE_FORCE_INLINE bool is_case_insensitive(flags f) {
1511 return f.case_insensitive;
1521 // sfinae check for types here
1523 template <typename T> class MatchesCharacter {
1524 template <typename Y, typename CharT> static auto test(CharT c) -> decltype(Y::match_char(c, std::declval<const flags &>()), std::true_type());
1525 template <typename> static auto test(...) -> std::false_type;
1527 template <typename CharT> static inline constexpr bool value = decltype(test<T>(std::declval<CharT>()))();
1530 template <typename T> constexpr CTRE_FORCE_INLINE bool is_ascii_alpha(T v) {
1531 return ((v >= static_cast<T>('a') && v <= static_cast<T>('z')) || (v >= static_cast<T>('A') && v <= static_cast<T>('Z')));
1534 template <typename T> constexpr CTRE_FORCE_INLINE bool is_ascii_alpha_lowercase(T v) {
1535 return (v >= static_cast<T>('a')) && (v <= static_cast<T>('z'));
1538 template <typename T> constexpr CTRE_FORCE_INLINE bool is_ascii_alpha_uppercase(T v) {
1539 return (v >= static_cast<T>('A')) && v <= (static_cast<T>('Z'));
1542 template <auto V> struct character {
1543 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1544 if constexpr (is_ascii_alpha(V)) {
1545 if (is_case_insensitive(f)) {
1546 if (value == (V ^ static_cast<decltype(V)>(0x20))) {
1555 template <typename... Content> struct negative_set {
1556 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1557 return !(Content::match_char(value, f) || ... || false);
1561 template <typename... Content> struct set {
1562 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1563 return (Content::match_char(value, f) || ... || false);
1567 template <auto... Cs> struct enumeration : set<character<Cs>...> { };
1569 template <typename... Content> struct negate {
1570 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1571 return !(Content::match_char(value, f) || ... || false);
1575 template <auto A, auto B> struct char_range {
1576 template <typename CharT> CTRE_FORCE_INLINE static constexpr bool match_char(CharT value, const flags & f) noexcept {
1577 if constexpr (is_ascii_alpha_lowercase(A) && is_ascii_alpha_lowercase(B)) {
1578 if (is_case_insensitive(f)) {
1579 if (value >= (A ^ static_cast<decltype(A)>(0x20)) && value <= (B ^ static_cast<decltype(B)>(0x20))) {
1583 } else if constexpr (is_ascii_alpha_uppercase(A) && is_ascii_alpha_uppercase(B)) {
1584 if (is_case_insensitive(f)) {
1585 if (value >= (A ^ static_cast<decltype(A)>(0x20)) && value <= (B ^ static_cast<decltype(B)>(0x20))) {
1590 return (value >= A) && (value <= B);
1593 using word_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'>, character<'_'> >;
1595 using space_chars = enumeration<' ', '\t', '\n', '\v', '\f', '\r'>;
1597 using vertical_space_chars = enumeration<
1598 char{0x000A}, // Linefeed (LF)
1599 char{0x000B}, // Vertical tab (VT)
1600 char{0x000C}, // Form feed (FF)
1601 char{0x000D}, // Carriage return (CR)
1602 char32_t{0x0085}, // Next line (NEL)
1603 char32_t{0x2028}, // Line separator
1604 char32_t{0x2029} // Paragraph separator
1607 using horizontal_space_chars = enumeration<
1608 char{0x0009}, // Horizontal tab (HT)
1609 char{0x0020}, // Space
1610 char32_t{0x00A0}, // Non-break space
1611 char32_t{0x1680}, // Ogham space mark
1612 char32_t{0x180E}, // Mongolian vowel separator
1613 char32_t{0x2000}, // En quad
1614 char32_t{0x2001}, // Em quad
1615 char32_t{0x2002}, // En space
1616 char32_t{0x2003}, // Em space
1617 char32_t{0x2004}, // Three-per-em space
1618 char32_t{0x2005}, // Four-per-em space
1619 char32_t{0x2006}, // Six-per-em space
1620 char32_t{0x2007}, // Figure space
1621 char32_t{0x2008}, // Punctuation space
1622 char32_t{0x2009}, // Thin space
1623 char32_t{0x200A}, // Hair space
1624 char32_t{0x202F}, // Narrow no-break space
1625 char32_t{0x205F}, // Medium mathematical space
1626 char32_t{0x3000} // Ideographic space
1629 using alphanum_chars = set<char_range<'A','Z'>, char_range<'a','z'>, char_range<'0','9'> >;
1631 using alpha_chars = set<char_range<'A','Z'>, char_range<'a','z'> >;
1633 using xdigit_chars = set<char_range<'A','F'>, char_range<'a','f'>, char_range<'0','9'> >;
1636 = enumeration<'!', '"', '#
', '$
', '%
', '&
', '\
'',
'(',
')',
'*',
'+',
',',
'-',
1637 '.',
'/',
':',
';',
'<',
'=',
'>',
'?',
'@',
'[',
'\\',
']',
1638 '^',
'_',
'`',
'{',
'|',
'}',
'~'>;
1640 using digit_chars = char_range<'0','9'>;
1642 using ascii_chars = char_range<'\x00','\x7F'>;
1655 struct start_mark { };
1656 struct end_mark { };
1657 struct end_cycle_mark { };
1658 struct end_lookahead_mark { };
1659 struct end_lookbehind_mark { };
1660 template <
size_t Id>
struct numeric_mark { };
1665 template <
auto... Str>
struct string { };
1666 template <
typename... Opts>
struct select { };
1667 template <
typename... Content>
struct sequence { };
1670 template <
size_t a,
size_t b,
typename... Content>
struct repeat { };
1671 template <
typename... Content>
using plus = repeat<1,0,Content...>;
1672 template <
typename... Content>
using star = repeat<0,0,Content...>;
1674 template <
size_t a,
size_t b,
typename... Content>
struct lazy_repeat { };
1675 template <
typename... Content>
using lazy_plus = lazy_repeat<1,0,Content...>;
1676 template <
typename... Content>
using lazy_star = lazy_repeat<0,0,Content...>;
1678 template <
size_t a,
size_t b,
typename... Content>
struct possessive_repeat { };
1679 template <
typename... Content>
using possessive_plus = possessive_repeat<1,0,Content...>;
1680 template <
typename... Content>
using possessive_star = possessive_repeat<0,0,Content...>;
1682 template <
typename... Content>
using optional = repeat<0,1,Content...>;
1683 template <
typename... Content>
using lazy_optional = lazy_repeat<0,1,Content...>;
1684 template <
typename... Content>
using possessive_optional = possessive_repeat<0,1,Content...>;
1686 template <
size_t Index,
typename... Content>
struct capture { };
1688 template <
size_t Index,
typename Name,
typename... Content>
struct capture_with_name { };
1690 template <
size_t Index>
struct back_reference { };
1691 template <
typename Name>
struct back_reference_with_name { };
1693 template <
typename Type>
struct look_start { };
1695 template <
typename... Content>
struct lookahead_positive { };
1696 template <
typename... Content>
struct lookahead_negative { };
1698 template <
typename... Content>
struct lookbehind_positive { };
1699 template <
typename... Content>
struct lookbehind_negative { };
1701 struct atomic_start { };
1703 template <
typename... Content>
struct atomic_group { };
1705 template <
typename... Content>
struct boundary { };
1706 template <
typename... Content>
struct not_boundary { };
1708 using word_boundary = boundary<word_chars>;
1709 using not_word_boundary = not_boundary<word_chars>;
1711 struct assert_subject_begin { };
1712 struct assert_subject_end { };
1713 struct assert_subject_end_line{ };
1714 struct assert_line_begin { };
1715 struct assert_line_end { };
1717 template <
typename>
struct mode_switch { };
1723 #ifndef CTRE__ATOMS_UNICODE__HPP
1724 #define CTRE__ATOMS_UNICODE__HPP
1727 #ifndef H_COR3NTIN_UNICODE_SYNOPSYS
1728 #define H_COR3NTIN_UNICODE_SYNOPSYS
1730 #include <string_view>
1734 enum class category;
1735 enum class property;
1736 enum class version : unsigned char;
1740 struct script_extensions_view {
1741 constexpr script_extensions_view(char32_t);
1746 constexpr iterator(char32_t c);
1749 constexpr iterator& operator++(
int);
1751 constexpr iterator operator++();
1762 constexpr iterator begin()
const;
1763 constexpr sentinel end()
const;
1769 struct numeric_value {
1771 constexpr
double value()
const;
1772 constexpr
long long numerator()
const;
1773 constexpr
int denominator()
const;
1777 constexpr numeric_value() =
default;
1778 constexpr numeric_value(
long long n,
int16_t d);
1782 friend constexpr numeric_value cp_numeric_value(char32_t cp);
1785 constexpr category cp_category(char32_t cp);
1786 constexpr script cp_script(char32_t cp);
1787 constexpr script_extensions_view cp_script_extensions(char32_t cp);
1788 constexpr
version cp_age(char32_t cp);
1789 constexpr block cp_block(char32_t cp);
1790 constexpr
bool cp_is_valid(char32_t cp);
1791 constexpr
bool cp_is_assigned(char32_t cp);
1792 constexpr
bool cp_is_ascii(char32_t cp);
1793 constexpr numeric_value cp_numeric_value(char32_t cp);
1796 constexpr
bool cp_script_is(char32_t);
1798 constexpr
bool cp_property_is(char32_t);
1800 constexpr
bool cp_category_is(char32_t);
1804 enum class binary_prop;
1805 constexpr
int propnamecomp(std::string_view sa, std::string_view sb);
1806 constexpr binary_prop binary_prop_from_string(std::string_view s);
1808 template<binary_prop p>
1809 constexpr
bool get_binary_prop(char32_t) =
delete;
1811 constexpr script script_from_string(std::string_view s);
1812 constexpr block block_from_string(std::string_view s);
1813 constexpr
version age_from_string(std::string_view
a);
1814 constexpr category category_from_string(std::string_view
a);
1816 constexpr
bool is_unassigned(category cat);
1817 constexpr
bool is_unknown(script s);
1818 constexpr
bool is_unknown(block
b);
1819 constexpr
bool is_unassigned(
version v);
1820 constexpr
bool is_unknown(binary_prop s);
1830 template <
auto... Str>
struct property_name { };
1831 template <
auto... Str>
struct property_value { };
1833 template <
size_t Sz> constexpr std::string_view get_string_view(
const char (&
arr)[Sz]) noexcept {
1834 return std::string_view(
arr, Sz);
1839 template <
typename T, T Type>
struct binary_property;
1840 template <
typename T, T Type, auto Value>
struct property;
1842 template <auto Type>
using make_binary_property = binary_property<std::remove_const_t<decltype(
Type)>,
Type>;
1843 template <auto Type, auto Value>
using make_property =
property<std::remove_const_t<decltype(
Type)>,
Type,
Value>;
1846 template <uni::detail::binary_prop Property>
struct binary_property<uni::detail::binary_prop, Property> {
1847 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1848 return uni::detail::get_binary_prop<Property>(
static_cast<char32_t
>(c));
1854 enum class property_type {
1855 script, script_extension, age, block, unknown
1860 template <uni::script Script>
struct binary_property<uni::script, Script> {
1861 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1862 return uni::cp_script(c) == Script;
1866 template <uni::script Script>
struct property<property_type, property_type::script_extension, Script> {
1867 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1868 for (uni::script sc: uni::cp_script_extensions(c)) {
1869 if (sc == Script)
return true;
1875 template <uni::version Age>
struct binary_property<uni::
version, Age> {
1876 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1877 return uni::cp_age(c) <= Age;
1881 template <uni::block Block>
struct binary_property<uni::block,
Block> {
1882 template <
typename CharT>
inline static constexpr
bool match_char(CharT c,
const flags &) noexcept {
1883 return uni::cp_block(c) ==
Block;
1889 template <
typename =
void>
1890 constexpr property_type property_type_from_name(std::string_view
str) noexcept {
1891 using namespace std::string_view_literals;
1892 if (uni::detail::propnamecomp(
str,
"script"sv) == 0 || uni::detail::propnamecomp(
str,
"sc"sv) == 0) {
1893 return property_type::script;
1894 }
else if (uni::detail::propnamecomp(
str,
"script_extension"sv) == 0 || uni::detail::propnamecomp(
str,
"scx"sv) == 0) {
1895 return property_type::script_extension;
1896 }
else if (uni::detail::propnamecomp(
str,
"age"sv) == 0) {
1897 return property_type::age;
1898 }
else if (uni::detail::propnamecomp(
str,
"block"sv) == 0) {
1899 return property_type::block;
1901 return property_type::unknown;
1905 template <property_type Property>
struct property_type_builder {
1906 template <
auto...
Value>
static constexpr
auto get() {
1911 template <
auto... Name>
struct property_builder {
1912 static constexpr
char name[
sizeof...(Name)]{
static_cast<char>(Name)...};
1913 static constexpr property_type
type = property_type_from_name(get_string_view(name));
1915 using helper = property_type_builder<type>;
1917 template <
auto...
Value>
static constexpr
auto get() {
1918 return helper::template get<
Value...>();
1924 template <>
struct property_type_builder<property_type::script> {
1925 template <
auto...
Value>
static constexpr
auto get() {
1926 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1927 constexpr
auto sc = uni::detail::script_from_string(get_string_view(
value));
1928 if constexpr (uni::detail::is_unknown(sc)) {
1931 return make_binary_property<sc>();
1936 template <>
struct property_type_builder<property_type::script_extension> {
1937 template <
auto...
Value>
static constexpr
auto get() {
1938 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1939 constexpr
auto sc = uni::detail::script_from_string(get_string_view(
value));
1940 if constexpr (uni::detail::is_unknown(sc)) {
1943 return make_property<property_type::script_extension, sc>();
1948 template <>
struct property_type_builder<property_type::age> {
1949 template <
auto...
Value>
static constexpr
auto get() {
1950 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1951 constexpr
auto age = uni::detail::age_from_string(get_string_view(
value));
1952 if constexpr (uni::detail::is_unassigned(age)) {
1955 return make_binary_property<age>();
1960 template <>
struct property_type_builder<property_type::block> {
1961 template <
auto...
Value>
static constexpr
auto get() {
1962 constexpr
char value[
sizeof...(Value)]{
static_cast<char>(
Value)...};
1963 constexpr
auto block = uni::detail::block_from_string(get_string_view(
value));
1964 if constexpr (uni::detail::is_unknown(block)) {
1967 return make_binary_property<block>();
1979 template <
size_t Index,
typename... Content>
auto convert_to_capture(
ctll::list<Content...>) -> capture<Index, Content...>;
1980 template <
size_t Index,
typename Name,
typename... Content>
auto convert_to_named_capture(
ctll::list<Content...>) -> capture_with_name<Index, Name, Content...>;
1981 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...>;
1982 template <
template <
typename...>
typename ListType,
typename... Content>
auto convert_to_basic_list(
ctll::list<Content...>) -> ListType<Content...>;
1984 template <auto V>
struct rotate_value {
1985 template <
auto... Vs>
friend constexpr
auto operator+(string<Vs...>, rotate_value<V>) noexcept ->
string<V, Vs...> {
return {}; }
1988 struct rotate_for_lookbehind {
1991 template <auto V>
static auto rotate(character<V>) -> character<V>;
1992 template <
typename... Content>
static auto rotate(negative_set<Content...>) -> negative_set<Content...>;
1994 template <
auto... Cs>
static auto rotate(enumeration<Cs...>) -> enumeration<Cs...>;
1995 template <
typename... Content>
static auto rotate(negate<Content...>) -> negate<Content...>;
1996 template <auto A, auto B>
static auto rotate(char_range<A,B>) -> char_range<A,B>;
1999 template <
auto... Str>
static auto rotate(property_name<Str...>) -> property_name<Str...>;
2000 template <
auto... Str>
static auto rotate(property_value<Str...>) -> property_value<Str...>;
2001 template <
typename T, T Type>
static auto rotate(binary_property<T, Type>) -> binary_property<T, Type>;
2002 template <
typename T, T Type, auto Value>
static auto rotate(property<T, Type, Value>) -> property<T, Type, Value>;
2005 static auto rotate(accept) -> accept;
2006 static auto rotate(reject) -> reject;
2007 static auto rotate(start_mark) -> start_mark;
2008 static auto rotate(end_mark) -> end_mark;
2009 static auto rotate(end_cycle_mark) -> end_cycle_mark;
2010 static auto rotate(end_lookahead_mark) -> end_lookahead_mark;
2011 static auto rotate(end_lookbehind_mark) -> end_lookbehind_mark;
2012 template <
size_t Id>
static auto rotate(numeric_mark<Id>) -> numeric_mark<Id>;
2013 static auto rotate(any) -> any;
2015 template <
typename... Content>
static auto rotate(select<Content...>) -> select<Content...>;
2018 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{}))...>{})));
2019 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{}))...>{})));
2020 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{}))...>{})));
2022 template <
size_t Index,
typename... Content>
static auto rotate(capture<Index, Content...>) {
2026 template <
size_t Index,
typename Name,
typename... Content>
static auto rotate(capture_with_name<Index, Name, Content...>) {
2030 template <
size_t Index>
static auto rotate(back_reference<Index>) -> back_reference<Index>;
2031 template <
typename Name>
static auto rotate(back_reference_with_name<Name>) -> back_reference_with_name<Name>;
2033 template <
typename... Content>
static auto rotate(look_start<Content...>) -> look_start<Content...>;
2035 template <
auto... Str>
static auto rotate(string<Str...>) -> decltype((string<>{} + ... + rotate_value<Str>{}));
2037 template <
typename... Content>
static auto rotate(sequence<Content...>) {
2042 template <
typename... Content>
static auto rotate(lookahead_positive<Content...>) -> lookahead_positive<Content...>;
2043 template <
typename... Content>
static auto rotate(lookahead_negative<Content...>) -> lookahead_negative<Content...>;
2044 template <
typename... Content>
static auto rotate(lookbehind_positive<Content...>) -> lookbehind_positive<Content...>;
2045 template <
typename... Content>
static auto rotate(lookbehind_negative<Content...>) -> lookbehind_negative<Content...>;
2047 static auto rotate(atomic_start) -> atomic_start;
2049 template <
typename... Content>
static auto rotate(atomic_group<Content...>) {
2053 template <
typename... Content>
static auto rotate(boundary<Content...>) -> boundary<Content...>;
2054 template <
typename... Content>
static auto rotate(not_boundary<Content...>) -> not_boundary<Content...>;
2056 static auto rotate(assert_subject_begin) -> assert_subject_begin;
2057 static auto rotate(assert_subject_end) -> assert_subject_end;
2058 static auto rotate(assert_subject_end_line) -> assert_subject_end_line;
2059 static auto rotate(assert_line_begin) -> assert_line_begin;
2060 static auto rotate(assert_line_end) -> assert_line_end;
2068 #ifndef CTRE__ID__HPP
2069 #define CTRE__ID__HPP
2071 #include <type_traits>
2075 template <
auto... Name>
struct id {
2078 friend constexpr
auto operator==(id<Name...>, id<Name...>) noexcept -> std::true_type {
return {}; }
2080 template <
auto... Other>
friend constexpr
auto operator==(id<Name...>, id<Other...>) noexcept -> std::false_type {
return {}; }
2082 template <
typename T>
friend constexpr
auto operator==(id<Name...>,
T) noexcept -> std::false_type {
return {}; }
2084 template <
typename T>
friend constexpr
auto operator==(
T, id<Name...>) noexcept -> std::false_type {
return {}; }
2096 template <
size_t Counter>
struct pcre_parameters {
2097 static constexpr
size_t current_counter = Counter;
2100 template <
typename Stack = ctll::list<>,
typename Parameters = pcre_parameters<0>,
typename Mode = ctll::list<>>
struct pcre_context {
2101 using stack_type = Stack;
2102 using parameters_type = Parameters;
2103 using mode_list = Mode;
2104 static constexpr
inline auto stack = stack_type();
2105 static constexpr
inline auto parameters = parameters_type();
2106 static constexpr
inline auto mode = mode_list();
2107 constexpr pcre_context() noexcept { }
2108 constexpr pcre_context(Stack, Parameters) noexcept { }
2109 constexpr pcre_context(Stack, Parameters, Mode) noexcept { }
2114 template <
size_t Value>
struct number { };
2116 template <
size_t Id>
struct capture_id { };
2118 struct pcre_actions {
2120 #ifndef CTRE__ACTIONS__ASSERTS__HPP
2121 #define CTRE__ACTIONS__ASSERTS__HPP
2134 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) {
2139 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) {
2144 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) {
2150 #ifndef CTRE__ACTIONS__ATOMIC_GROUP__HPP
2151 #define CTRE__ACTIONS__ATOMIC_GROUP__HPP
2154 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>>) {
2155 return pcre_context{
ctll::list<atomic_start, Ts...>(), pcre_parameters<Counter>()};
2164 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>>) {
2165 return pcre_context{
ctll::list<atomic_group<Atomic...>, Ts...>(), pcre_parameters<Counter>()};
2170 #ifndef CTRE__ACTIONS__BACKREFERENCE__HPP
2171 #define CTRE__ACTIONS__BACKREFERENCE__HPP
2174 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>>) {
2179 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>>) {
2181 if constexpr (Counter < Id) {
2189 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>>) {
2191 if constexpr (Counter < Id) {
2194 constexpr
size_t absolute_id = (Counter + 1) - Id;
2201 #ifndef CTRE__ACTIONS__BOUNDARIES__HPP
2202 #define CTRE__ACTIONS__BOUNDARIES__HPP
2210 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) {
2216 #ifndef CTRE__ACTIONS__CAPTURE__HPP
2217 #define CTRE__ACTIONS__CAPTURE__HPP
2220 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>>) {
2225 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>>) {
2226 return pcre_context{
ctll::list<Ts...>(), pcre_parameters<Counter-1>()};
2230 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>>) {
2234 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>>) {
2242 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) {
2246 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>>) {
2250 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>>) {
2256 #ifndef CTRE__ACTIONS__CHARACTERS__HPP
2257 #define CTRE__ACTIONS__CHARACTERS__HPP
2264 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) {
2268 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) {
2272 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) {
2276 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) {
2280 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) {
2288 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) {
2298 #ifndef CTRE__ACTIONS__CLASS__HPP
2299 #define CTRE__ACTIONS__CLASS__HPP
2319 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) {
2323 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) {
2327 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) {
2331 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) {
2350 #ifndef CTRE__ACTIONS__FUSION__HPP
2351 #define CTRE__ACTIONS__FUSION__HPP
2353 static constexpr
size_t combine_max_repeat_length(
size_t A,
size_t B) {
2354 if (
A &&
B)
return A+
B;
2358 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...>) {
2359 return repeat<MinA + MinB, combine_max_repeat_length(MaxA, MaxB), Content...>();
2362 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...>) {
2363 return lazy_repeat<MinA + MinB, combine_max_repeat_length(MaxA, MaxB), Content...>();
2366 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...>) {
2367 [[maybe_unused]] constexpr
bool first_is_unbounded = (MaxA == 0);
2368 [[maybe_unused]] constexpr
bool second_is_nonempty = (MinB > 0);
2369 [[maybe_unused]] constexpr
bool second_can_be_empty = (MinB == 0);
2371 if constexpr (first_is_unbounded && second_is_nonempty) {
2373 return sequence<reject, Content...>();
2374 }
else if constexpr (first_is_unbounded) {
2375 return possessive_repeat<MinA, MaxA, Content...>();
2376 }
else if constexpr (second_can_be_empty) {
2377 return possessive_repeat<MinA, combine_max_repeat_length(MaxA, MaxB), Content...>();
2379 return possessive_repeat<MaxA + MinB, combine_max_repeat_length(MaxA, MaxB), Content...>();
2384 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) {
2389 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) {
2394 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) {
2399 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) {
2400 using result = decltype(combine_repeat(repeat<MinB, MaxB, Content...>(), repeat<MinA, MaxA, Content...>()));
2406 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) {
2407 using result = decltype(combine_repeat(lazy_repeat<MinB, MaxB, Content...>(), lazy_repeat<MinA, MaxA, Content...>()));
2413 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) {
2414 using result = decltype(combine_repeat(possessive_repeat<MinB, MaxB, Content...>(), possessive_repeat<MinA, MaxA, Content...>()));
2421 #ifndef CTRE__ACTIONS__HEXDEC__HPP
2422 #define CTRE__ACTIONS__HEXDEC__HPP
2429 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) {
2430 constexpr
auto previous =
N << 4ull;
2431 if constexpr (V >=
'a' && V <=
'f') {
2433 }
else if constexpr (V >=
'A' && V <=
'F') {
2440 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) {
2442 if constexpr (
N <= max_char) {
2451 #ifndef CTRE__ACTIONS__LOOKAHEAD__HPP
2452 #define CTRE__ACTIONS__LOOKAHEAD__HPP
2455 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>>) {
2460 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>>) {
2465 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>>) {
2466 return pcre_context{
ctll::list<lookahead_positive<Look...>, Ts...>(), pcre_parameters<Counter>()};
2470 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>>) {
2475 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>>) {
2480 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>>) {
2481 return pcre_context{
ctll::list<lookahead_negative<Look...>, Ts...>(), pcre_parameters<Counter>()};
2487 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>>) {
2492 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>>) {
2497 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>>) {
2499 return pcre_context{
ctll::list<my_lookbehind, Ts...>(), pcre_parameters<Counter>()};
2503 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>>) {
2508 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>>) {
2513 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>>) {
2515 return pcre_context{
ctll::list<my_lookbehind, Ts...>(), pcre_parameters<Counter>()};
2520 #ifndef CTRE__ACTIONS__NAMED_CLASS__HPP
2521 #define CTRE__ACTIONS__NAMED_CLASS__HPP
2582 #ifndef CTRE__ACTIONS__OPTIONS__HPP
2583 #define CTRE__ACTIONS__OPTIONS__HPP
2600 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) {
2609 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) {
2614 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) {
2619 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) {
2624 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) {
2629 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) {
2635 #ifndef CTRE__ACTIONS__PROPERTIES__HPP
2636 #define CTRE__ACTIONS__PROPERTIES__HPP
2643 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) {
2652 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) {
2657 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) {
2659 constexpr
char name[
sizeof...(Name)]{
static_cast<char>(Name)...};
2660 constexpr
auto p = uni::detail::binary_prop_from_string(get_string_view(name));
2662 if constexpr (uni::detail::is_unknown(p)) {
2670 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) {
2672 constexpr
auto prop = property_builder<Name...>::template get<
Value...>();
2674 if constexpr (std::is_same_v<decltype(prop),
ctll::reject>) {
2682 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) {
2684 constexpr
char name[
sizeof...(Name)]{
static_cast<char>(Name)...};
2685 constexpr
auto p = uni::detail::binary_prop_from_string(get_string_view(name));
2687 if constexpr (uni::detail::is_unknown(p)) {
2695 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) {
2697 constexpr
auto prop = property_builder<Name...>::template get<
Value...>();
2699 if constexpr (std::is_same_v<decltype(prop),
ctll::reject>) {
2708 #ifndef CTRE__ACTIONS__REPEAT__HPP
2709 #define CTRE__ACTIONS__REPEAT__HPP
2716 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) {
2725 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) {
2734 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) {
2735 constexpr
size_t previous =
N * 10ull;
2740 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) {
2744 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) {
2749 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) {
2753 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) {
2758 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) {
2762 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) {
2767 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) {
2772 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) {
2777 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) {
2782 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) {
2787 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) {
2792 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) {
2798 #ifndef CTRE__ACTIONS__SEQUENCE__HPP
2799 #define CTRE__ACTIONS__SEQUENCE__HPP
2806 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) {
2811 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) {
2815 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) {
2820 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) {
2824 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) {
2830 #ifndef CTRE__ACTIONS__SET__HPP
2831 #define CTRE__ACTIONS__SET__HPP
2835 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 {}; }
2874 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) {
2890 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) {
2896 #ifndef CTRE__ACTIONS__MODE__HPP
2897 #define CTRE__ACTIONS__MODE__HPP
2900 template <
typename Mode,
typename... Ts,
typename Parameters>
static constexpr
auto apply_mode(Mode,
ctll::list<Ts...>, Parameters) {
2901 return pcre_context<ctll::list<mode_switch<Mode>, Ts...>, Parameters>{};
2904 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>) {
2905 return pcre_context<ctll::list<mode_switch<Mode>, Ts...>, pcre_parameters<Counter-1>>{};
2909 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>) {
2913 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>) {
2917 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::mode_singleline
mode,
ctll::term<V>,pcre_context<
ctll::list<Ts...>, Parameters>) {
2921 template <
auto V,
typename... Ts,
typename Parameters>
static constexpr
auto apply(pcre::mode_multiline
mode,
ctll::term<V>,pcre_context<
ctll::list<Ts...>, Parameters>) {
2935 #ifndef CTRE__EVALUATION__HPP
2936 #define CTRE__EVALUATION__HPP
2938 #ifndef CTRE__STARTS_WITH_ANCHOR__HPP
2939 #define CTRE__STARTS_WITH_ANCHOR__HPP
2943 template <
typename... Content>
2948 template <
typename... Content>
2954 template <
typename... Content>
2960 template <
typename CharLike,
typename... Content>
2961 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<boundary<CharLike>, Content...>) noexcept {
2966 template <
typename... Options,
typename... Content>
2967 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<select<Options...>, Content...>) noexcept {
2972 template <
typename... Optional,
typename... Content>
2973 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<optional<Optional...>, Content...>) noexcept {
2978 template <
typename... Optional,
typename... Content>
2979 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<lazy_optional<Optional...>, Content...>) noexcept {
2984 template <
typename... Seq,
typename... Content>
2985 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<sequence<Seq...>, Content...>) noexcept {
2990 template <
size_t A,
size_t B,
typename... Seq,
typename... Content>
2991 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<repeat<A, B, Seq...>, Content...>) noexcept {
2996 template <
size_t A,
size_t B,
typename... Seq,
typename... Content>
2997 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<lazy_repeat<A, B, Seq...>, Content...>) noexcept {
3002 template <
size_t A,
size_t B,
typename... Seq,
typename... Content>
3003 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<possessive_repeat<A, B, Seq...>, Content...>) noexcept {
3008 template <
size_t Index,
typename... Seq,
typename... Content>
3009 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<capture<Index, Seq...>, Content...>) noexcept {
3014 template <
size_t Index,
typename... Seq,
typename... Content>
3015 constexpr
bool starts_with_anchor(
const flags &
f,
ctll::list<capture_with_name<Index, Seq...>, Content...>) noexcept {
3024 #ifndef CTRE__RETURN_TYPE__HPP
3025 #define CTRE__RETURN_TYPE__HPP
3027 #ifndef CTRE__UTF8__HPP
3028 #define CTRE__UTF8__HPP
3030 #if __cpp_char8_t >= 201811
3032 #include <string_view>
3035 #if __cpp_lib_char8_t >= 201811L
3036 #define CTRE_ENABLE_UTF8_RANGE
3041 struct utf8_iterator {
3042 using self_type = utf8_iterator;
3044 using reference = char8_t;
3045 using pointer =
const char8_t *;
3046 using iterator_category = std::bidirectional_iterator_tag;
3047 using difference_type =
int;
3051 using self_type = utf8_iterator;
3053 using reference = char8_t &;
3054 using pointer =
const char8_t *;
3055 using iterator_category = std::bidirectional_iterator_tag;
3056 using difference_type =
int;
3059 auto operator++() noexcept -> self_type &;
3060 auto operator++(
int) noexcept -> self_type;
3066 friend constexpr
auto operator==(self_type,
const char8_t * other_ptr) noexcept {
3067 return *other_ptr == char8_t{0};
3071 const char8_t * ptr{
nullptr};
3072 const char8_t * end{
nullptr};
3074 constexpr
friend bool operator!=(
const utf8_iterator & lhs, sentinel) {
3075 return lhs.ptr < lhs.end;
3078 constexpr
friend bool operator!=(sentinel,
const utf8_iterator & rhs) {
3079 return rhs.ptr < rhs.end;
3082 constexpr
friend bool operator!=(
const utf8_iterator & lhs,
const utf8_iterator & rhs) {
3083 return lhs.ptr != rhs.ptr;
3086 constexpr
friend bool operator==(
const utf8_iterator & lhs, sentinel) {
3087 return lhs.ptr >= lhs.end;
3090 constexpr
friend bool operator==(sentinel,
const utf8_iterator & rhs) {
3091 return rhs.ptr >= rhs.end;
3094 constexpr utf8_iterator & operator=(
const char8_t * rhs) {
3099 constexpr
operator const char8_t *()
const noexcept {
3103 constexpr utf8_iterator & operator++() noexcept {
3111 ptr += ((0x3A55000000000000ull >> ((*ptr >> 2) & 0b111110u)) & 0b11u) + 1;
3115 constexpr utf8_iterator &
operator--() noexcept {
3122 while ((*ptr & 0b11000000u) == 0b10'000000) {
3129 constexpr utf8_iterator
operator--(
int) noexcept {
3135 constexpr utf8_iterator operator++(
int) noexcept {
3141 constexpr utf8_iterator
operator+(
unsigned step)
const noexcept {
3142 utf8_iterator
result = *
this;
3150 constexpr utf8_iterator
operator-(
unsigned step)
const noexcept {
3151 utf8_iterator
result = *
this;
3159 constexpr char32_t
operator*()
const noexcept {
3160 constexpr char32_t mojibake = 0xFFFDull;
3163 if (!(*ptr & 0b1000'0000u)) CTRE_LIKELY {
3168 const unsigned length = ((0x3A55000000000000ull >> ((*ptr >> 2) & 0b111110u)) & 0b11u);
3173 if (!length) CTRE_UNLIKELY {
3178 if (((ptr + length) >= end)) CTRE_UNLIKELY {
3182 if ((ptr[1] & 0b1100'0000u) != 0b1000'0000) CTRE_UNLIKELY {
3186 const char8_t
mask =
static_cast<char8_t
>(0b0011'1111u >> length);
3195 char32_t
result =
static_cast<char32_t
>((ptr[0] &
mask) << 6u) | (ptr[1] & 0b0011'1111u);
3198 if (length == 1) CTRE_LIKELY {
3202 if ((ptr[2] & 0b1100'0000u) != 0b1000'0000) CTRE_UNLIKELY {
3208 if (length == 2) CTRE_LIKELY {
3212 if ((ptr[3] & 0b1100'0000u) != 0b1000'0000) CTRE_UNLIKELY {
3216 return (
result << 6) | (ptr[3] & 0b0011'1111u);
3220 #ifdef CTRE_ENABLE_UTF8_RANGE
3222 std::u8string_view
range;
3223 constexpr utf8_range(std::u8string_view
r) noexcept:
range{
r} { }
3225 constexpr
auto begin()
const noexcept {
3228 constexpr
auto end()
const noexcept {
3229 return utf8_iterator::sentinel{};
3240 #include <type_traits>
3242 #include <string_view>
3246 #if __has_include(<charconv>)
3252 constexpr
auto is_random_accessible_f(
const std::random_access_iterator_tag &) {
return std::true_type{}; }
3253 constexpr
auto is_random_accessible_f(...) {
return std::false_type{}; }
3255 template <
typename T> constexpr
auto is_reverse_iterator_f(
const std::reverse_iterator<T> &) {
return std::true_type{}; }
3256 constexpr
auto is_reverse_iterator_f(...) {
return std::false_type{}; }
3258 template <
typename T> constexpr
bool is_random_accessible = decltype(is_random_accessible_f(std::declval<const T &>())){};
3259 template <
typename T> constexpr
bool is_reverse_iterator = decltype(is_reverse_iterator_f(std::declval<const T &>())){};
3261 struct not_matched_tag_t { };
3263 constexpr
inline auto not_matched = not_matched_tag_t{};
3265 template <
size_t Id,
typename Name =
void>
struct captured_content {
3266 template <
typename Iterator>
class storage {
3270 bool _matched{
false};
3276 constexpr CTRE_FORCE_INLINE storage() noexcept {}
3278 constexpr CTRE_FORCE_INLINE
void matched() noexcept {
3281 constexpr CTRE_FORCE_INLINE
void unmatch() noexcept {
3284 constexpr CTRE_FORCE_INLINE
void set_start(Iterator pos) noexcept {
3287 constexpr CTRE_FORCE_INLINE storage & set_end(Iterator pos) noexcept {
3291 constexpr CTRE_FORCE_INLINE Iterator get_end()
const noexcept {
3296 constexpr
auto begin()
const noexcept {
3299 constexpr
auto end()
const noexcept {
3303 constexpr
explicit CTRE_FORCE_INLINE
operator bool()
const noexcept {
3307 template <
typename It = Iterator> constexpr CTRE_FORCE_INLINE
const auto * data_unsafe()
const noexcept {
3308 static_assert(!is_reverse_iterator<It>,
"Iterator in your capture must not be reverse!");
3310 #if __cpp_char8_t >= 201811
3311 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3321 template <
typename It = Iterator> constexpr CTRE_FORCE_INLINE
const auto *
data()
const noexcept {
3322 constexpr
bool must_be_contiguous_nonreverse_iterator = is_random_accessible<typename std::iterator_traits<It>::iterator_category> && !is_reverse_iterator<It>;
3324 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).");
3326 return data_unsafe();
3329 constexpr CTRE_FORCE_INLINE
auto size()
const noexcept {
3330 return static_cast<size_t>(std::distance(begin(), end()));
3333 constexpr CTRE_FORCE_INLINE
size_t unit_size()
const noexcept {
3334 #if __cpp_char8_t >= 201811
3335 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3336 return static_cast<size_t>(std::distance(_begin.ptr, _end.ptr));
3338 return static_cast<size_t>(std::distance(begin(), end()));
3341 return static_cast<size_t>(std::distance(begin(), end()));
3345 #if __has_include(<charconv>)
3346 template <
typename R =
int> constexpr CTRE_FORCE_INLINE
auto to_number(
int base = 10)
const noexcept ->
R {
3348 const auto view = to_view();
3349 std::from_chars(view.data(), view.data() + view.size(),
result, base);
3354 template <
typename T>
struct identify;
3356 template <
typename It = Iterator> constexpr CTRE_FORCE_INLINE
auto to_view()
const noexcept {
3358 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>;
3360 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.");
3362 return std::basic_string_view<char_type>(data_unsafe(),
static_cast<size_t>(unit_size()));
3365 constexpr CTRE_FORCE_INLINE std::basic_string<char_type> to_string()
const noexcept {
3366 #if __cpp_char8_t >= 201811
3367 if constexpr (std::is_same_v<Iterator, utf8_iterator>) {
3368 return std::basic_string<char_type>(data_unsafe(),
static_cast<size_t>(unit_size()));
3370 return std::basic_string<char_type>(begin(), end());
3373 return std::basic_string<char_type>(begin(), end());
3377 constexpr CTRE_FORCE_INLINE
auto view()
const noexcept {
3381 constexpr CTRE_FORCE_INLINE
auto str()
const noexcept {
3385 constexpr CTRE_FORCE_INLINE
operator std::basic_string_view<char_type>()
const noexcept {
3389 constexpr CTRE_FORCE_INLINE
explicit operator std::basic_string<char_type>()
const noexcept {
3393 constexpr CTRE_FORCE_INLINE
static size_t get_id() noexcept {
3397 friend CTRE_FORCE_INLINE constexpr
bool operator==(
const storage & lhs, std::basic_string_view<char_type> rhs) noexcept {
3398 return bool(lhs) ? lhs.view() == rhs :
false;
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==(std::basic_string_view<char_type> lhs,
const storage & rhs) noexcept {
3404 return bool(rhs) ? lhs == rhs.view() :
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 std::ostream &
operator<<(std::ostream &
str,
const storage & rhs) {
3410 return str << rhs.view();
3415 struct capture_not_exists_tag { };
3417 static constexpr
inline auto capture_not_exists = capture_not_exists_tag{};
3419 template <
typename... Captures>
struct captures;
3421 template <
typename Head,
typename... Tail>
struct captures<Head, Tail...>: captures<Tail...> {
3423 constexpr CTRE_FORCE_INLINE captures() noexcept { }
3424 template <
size_t id> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3425 if constexpr (
id == Head::get_id()) {
3428 return captures<Tail...>::template exists<id>();
3431 template <
typename Name> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3432 if constexpr (std::is_same_v<Name, typename Head::name>) {
3435 return captures<Tail...>::template exists<Name>();
3438 #if CTRE_CNTTP_COMPILER_CHECK
3439 template <ctll::fixed_
string Name> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3441 template <const auto & Name> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3443 if constexpr (std::is_same_v<typename Head::name, void>) {
3444 return captures<Tail...>::template exists<Name>();
3446 if constexpr (Head::name::name.is_same_as(Name)) {
3449 return captures<Tail...>::template exists<Name>();
3453 template <
size_t id> CTRE_FORCE_INLINE constexpr
auto & select() noexcept {
3454 if constexpr (
id == Head::get_id()) {
3457 return captures<Tail...>::template select<id>();
3460 template <
typename Name> CTRE_FORCE_INLINE constexpr
auto & select() noexcept {
3461 if constexpr (std::is_same_v<Name, typename Head::name>) {
3464 return captures<Tail...>::template select<Name>();
3467 template <
size_t id> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3468 if constexpr (
id == Head::get_id()) {
3471 return captures<Tail...>::template select<id>();
3474 template <
typename Name> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3475 if constexpr (std::is_same_v<Name, typename Head::name>) {
3478 return captures<Tail...>::template select<Name>();
3481 #if CTRE_CNTTP_COMPILER_CHECK
3482 template <ctll::fixed_
string Name> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3484 template <const auto & Name> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3486 if constexpr (std::is_same_v<typename Head::name, void>) {
3487 return captures<Tail...>::template select<Name>();
3489 if constexpr (Head::name::name.is_same_as(Name)) {
3492 return captures<Tail...>::template select<Name>();
3498 template <>
struct captures<> {
3499 constexpr CTRE_FORCE_INLINE captures() noexcept { }
3500 template <
size_t> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3503 template <
typename> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3506 #if CTRE_CNTTP_COMPILER_CHECK
3507 template <ctll::fixed_
string> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3509 template <const auto &> CTRE_FORCE_INLINE
static constexpr
bool exists() noexcept {
3513 template <
size_t> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3514 return capture_not_exists;
3516 template <
typename> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3517 return capture_not_exists;
3519 #if CTRE_CNTTP_COMPILER_CHECK
3520 template <ctll::fixed_
string> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3522 template <const auto &> CTRE_FORCE_INLINE constexpr
auto & select()
const noexcept {
3524 return capture_not_exists;
3528 template <
typename Iterator,
typename... Captures>
class regex_results {
3529 captures<captured_content<0>::template storage<Iterator>,
typename Captures::template storage<Iterator>...> _captures{};
3533 constexpr CTRE_FORCE_INLINE regex_results() noexcept { }
3534 constexpr CTRE_FORCE_INLINE regex_results(not_matched_tag_t) noexcept { }
3539 template <size_t Id, typename = std::enable_if_t<decltype(_captures)::template exists<Id>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3540 return _captures.template select<Id>();
3542 template <typename Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3543 return _captures.template select<Name>();
3545 #if CTRE_CNTTP_COMPILER_CHECK
3546 template <ctll::fixed_string Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3548 template <const auto & Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr
auto get()
const noexcept {
3550 return _captures.template select<Name>();
3552 static constexpr
size_t count() noexcept {
3553 return sizeof...(Captures) + 1;
3555 constexpr CTRE_FORCE_INLINE regex_results & matched() noexcept {
3556 _captures.template select<0>().matched();
3559 constexpr CTRE_FORCE_INLINE regex_results & unmatch() noexcept {
3560 _captures.template select<0>().unmatch();
3563 constexpr CTRE_FORCE_INLINE
operator bool()
const noexcept {
3564 return bool(_captures.template select<0>());
3567 constexpr CTRE_FORCE_INLINE
operator std::basic_string_view<char_type>()
const noexcept {
3571 constexpr CTRE_FORCE_INLINE
explicit operator std::basic_string<char_type>()
const noexcept {
3575 #if __has_include(<charconv>)
3576 template <
typename R =
int> constexpr CTRE_FORCE_INLINE
auto to_number(
int base = 10)
const noexcept ->
R {
3577 return _captures.template select<0>().template to_number<R>(base);
3581 constexpr CTRE_FORCE_INLINE
auto to_view()
const noexcept {
3582 return _captures.template select<0>().to_view();
3585 constexpr CTRE_FORCE_INLINE
auto to_string()
const noexcept {
3586 return _captures.template select<0>().to_string();
3589 constexpr CTRE_FORCE_INLINE
auto view()
const noexcept {
3590 return _captures.template select<0>().view();
3593 constexpr CTRE_FORCE_INLINE
auto str()
const noexcept {
3594 return _captures.template select<0>().to_string();
3597 constexpr CTRE_FORCE_INLINE
size_t size()
const noexcept {
3598 return _captures.template select<0>().size();
3601 constexpr CTRE_FORCE_INLINE
const auto *
data()
const noexcept {
3602 return _captures.template select<0>().data();
3605 constexpr CTRE_FORCE_INLINE regex_results & set_start_mark(Iterator pos) noexcept {
3606 _captures.template select<0>().set_start(pos);
3609 constexpr CTRE_FORCE_INLINE regex_results & set_end_mark(Iterator pos) noexcept {
3610 _captures.template select<0>().set_end(pos);
3613 constexpr CTRE_FORCE_INLINE Iterator get_end_position()
const noexcept {
3614 return _captures.template select<0>().get_end();
3616 template <
size_t Id> CTRE_FORCE_INLINE constexpr regex_results & start_capture(Iterator pos) noexcept {
3617 _captures.template select<Id>().set_start(pos);
3620 template <
size_t Id> CTRE_FORCE_INLINE constexpr regex_results & end_capture(Iterator pos) noexcept {
3621 _captures.template select<Id>().set_end(pos).matched();
3624 constexpr
auto begin()
const noexcept {
3625 return _captures.template select<0>().begin();
3627 constexpr
auto end()
const noexcept {
3628 return _captures.template select<0>().end();
3630 friend CTRE_FORCE_INLINE constexpr
bool operator==(
const regex_results & lhs, std::basic_string_view<char_type> rhs) noexcept {
3631 return bool(lhs) ? lhs.view() == rhs :
false;
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 :
true;
3636 friend CTRE_FORCE_INLINE constexpr
bool operator==(std::basic_string_view<char_type> lhs,
const regex_results & rhs) noexcept {
3637 return bool(rhs) ? lhs == rhs.view() :
false;
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() :
true;
3642 friend CTRE_FORCE_INLINE std::ostream &
operator<<(std::ostream &
str,
const regex_results & rhs) {
3643 return str << rhs.view();
3647 template <
size_t Id,
typename Iterator,
typename... Captures> constexpr
auto get(
const regex_results<Iterator, Captures...> &
results) noexcept {
3648 return results.template get<Id>();
3651 template <
typename Iterator,
typename... Captures> regex_results(Iterator,
ctll::list<Captures...>) -> regex_results<Iterator, Captures...>;
3653 template <
typename ResultIterator,
typename Pattern>
using return_type = decltype(regex_results(std::declval<ResultIterator>(), find_captures(
Pattern{})));
3661 #pragma clang diagnostic push
3662 #pragma clang diagnostic ignored "-Wmismatched-tags"
3666 template <
typename... Captures>
struct tuple_size<ctre::regex_results<Captures...>> :
public std::integral_constant<size_t, ctre::regex_results<Captures...>::count()> { };
3668 template <
size_t N,
typename... Captures>
struct tuple_element<
N, ctre::regex_results<Captures...>> {
3670 using type = decltype(
3671 std::declval<
const ctre::regex_results<Captures...> &>().
template get<N>()
3677 #pragma clang diagnostic pop
3683 #ifndef CTRE__FIND_CAPTURES__HPP
3684 #define CTRE__FIND_CAPTURES__HPP
3688 template <
typename Pattern> constexpr
auto find_captures(
Pattern) noexcept {
3696 template <
auto... String,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<string<String...>, Tail...>, Output
output) noexcept {
3700 template <
typename... Options,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<select<Options...>, Tail...>, Output
output) noexcept {
3704 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<optional<Content...>, Tail...>, Output
output) noexcept {
3708 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lazy_optional<Content...>, Tail...>, Output
output) noexcept {
3712 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<sequence<Content...>, Tail...>, Output
output) noexcept {
3733 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<plus<Content...>, Tail...>, Output
output) noexcept {
3737 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<star<Content...>, Tail...>, Output
output) noexcept {
3741 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 {
3745 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lazy_plus<Content...>, Tail...>, Output
output) noexcept {
3749 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lazy_star<Content...>, Tail...>, Output
output) noexcept {
3753 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 {
3757 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<possessive_plus<Content...>, Tail...>, Output
output) noexcept {
3761 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<possessive_star<Content...>, Tail...>, Output
output) noexcept {
3765 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 {
3769 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lookahead_positive<Content...>, Tail...>, Output
output) noexcept {
3773 template <
typename... Content,
typename... Tail,
typename Output> constexpr
auto find_captures(
ctll::list<lookahead_negative<Content...>, Tail...>, Output
output) noexcept {
3777 template <
size_t Id,
typename... Content,
typename... Tail,
typename... Output> constexpr
auto find_captures(
ctll::list<capture<Id,Content...>, Tail...>,
ctll::list<Output...>) noexcept {
3781 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 {
3789 #ifndef CTRE__FIRST__HPP
3790 #define CTRE__FIRST__HPP
3794 struct can_be_anything {};
3797 template <
typename... Content>
3802 template <
typename... Content,
typename... Tail>
3807 template <
typename... Content,
typename... Tail>
3812 template <
typename... Content,
typename... Tail>
3817 template <
typename... Content,
typename... Tail>
3822 template <
typename... Content,
size_t Id,
typename... Tail>
3828 template <
typename... Content,
typename... Tail>
3834 template <
typename... Content,
typename CharLike,
typename... Tail>
3840 template <
typename... Content,
typename... Tail>
3845 template <
typename... Content,
typename... Tail>
3850 template <
typename... Content,
typename... Tail>
3856 template <
typename... Content,
typename... Tail>
3862 template <
typename... Content,
typename... Tail>
3869 template <
typename... Content,
typename... Seq,
typename... Tail>
3875 template <
typename... Content,
typename... Seq,
typename... Tail>
3881 template <
typename... Content,
typename... Seq,
typename... Tail>
3887 template <
typename... Content,
typename... Seq,
typename... Tail>
3893 template <
typename... Content,
typename... Seq,
typename... Tail>
3899 template <
typename... Content,
typename... Seq,
typename... Tail>
3905 template <
typename... Content,
typename... Seq,
typename... Tail>
3911 template <
typename... Content,
size_t A,
size_t B,
typename... Seq,
typename... Tail>
3916 template <
typename... Content,
size_t B,
typename... Seq,
typename... Tail>
3922 template <
typename... Content,
size_t A,
size_t B,
typename... Seq,
typename... Tail>
3927 template <
typename... Content,
size_t B,
typename... Seq,
typename... Tail>
3933 template <
typename... Content,
size_t A,
size_t B,
typename... Seq,
typename... Tail>
3938 template <
typename... Content,
size_t B,
typename... Seq,
typename... Tail>
3944 template <
typename... Content,
typename... Seq,
typename... Tail>
3950 template <
typename... Content,
typename... Seq,
typename... Tail>
3956 template <
typename... Content,
typename... Seq,
typename... Tail>
3962 template <
typename... Content,
typename... Seq,
typename... Tail>
3968 template <
typename... Content,
size_t Id,
typename... Seq,
typename... Tail>
3973 template <
typename... Content,
size_t Id,
typename Name,
typename... Seq,
typename... Tail>
3979 template <
typename... Content,
size_t Id,
typename... Tail>
3984 template <
typename... Content,
typename Name,
typename... Tail>
3990 template <
typename... Content,
auto First,
auto... String,
typename... Tail>
3992 return ctll::list<Content..., character<First>>{};
3995 template <
typename... Content,
typename... Tail>
4001 template <
typename... Content,
typename... Opt,
typename... Tail>
4006 template <
typename... Content,
typename... Opt,
typename... Tail>
4012 template <
typename... Content,
typename SHead,
typename... STail,
typename... Tail>
4017 template <
typename... Content,
typename... Tail>
4023 template <
typename... Content,
typename PropertyType, PropertyType Property,
typename... Tail>
4028 template <
typename... Content,
typename PropertyType, PropertyType Property,
auto Value,
typename... Tail>
4035 template <
typename... Content,
auto V,
typename... Tail>
4037 return ctll::list<Content..., character<V>>{};
4040 template <
typename... Content,
auto... Values,
typename... Tail>
4042 return ctll::list<Content..., character<Values>...>{};
4045 template <
typename... Content,
typename... SetContent,
typename... Tail>
4047 return ctll::list<Content..., SetContent...>{};
4050 template <
typename... Content,
auto A,
auto B,
typename... Tail>
4052 return ctll::list<Content..., char_range<A,B>>{};
4055 template <
typename... Content,
typename... Tail>
4061 template <
typename... Content,
typename... SetContent,
typename... Tail>
4063 return ctll::list<Content..., negative_set<SetContent...>>{};
4066 template <
typename... Content,
typename... SetContent,
typename... Tail>
4068 return ctll::list<Content..., negative_set<SetContent...>>{};
4072 template <
typename... Content> constexpr
auto calculate_first(Content...) noexcept {
4077 template <
typename... Content> constexpr
size_t calculate_size_of_first(ctre::negative_set<Content...>) {
4078 return 1 + calculate_size_of_first(ctre::set<Content...>{});
4081 template <
auto... V> constexpr
size_t calculate_size_of_first(ctre::enumeration<V...>) {
4082 return sizeof...(V);
4085 constexpr
size_t calculate_size_of_first(...) {
4090 return (calculate_size_of_first(Content{}) + ... + 0);
4093 template <
typename... Content> constexpr
size_t calculate_size_of_first(ctre::set<Content...>) {
4094 return (calculate_size_of_first(Content{}) + ... + 0);
4097 template <auto A,
typename CB> constexpr
int64_t negative_helper(ctre::character<A>,
CB & cb,
int64_t start) {
4110 template <auto A, auto B,
typename CB> constexpr
int64_t negative_helper(ctre::char_range<A,B>,
CB & cb,
int64_t start) {
4123 template <
auto Head,
auto... Tail,
typename CB> constexpr
int64_t negative_helper(ctre::enumeration<Head, Tail...>,
CB & cb,
int64_t start) {
4124 int64_t nstart = negative_helper(ctre::character<Head>{}, cb, start);
4125 return negative_helper(ctre::enumeration<Tail...>{}, cb, nstart);
4128 template <
typename CB> constexpr
int64_t negative_helper(ctre::enumeration<>,
CB &,
int64_t start) {
4132 template <
typename CB> constexpr
int64_t negative_helper(ctre::set<>,
CB &,
int64_t start) {
4136 template <
typename PropertyType, PropertyType Property,
typename CB>
4137 constexpr
auto negative_helper(ctre::binary_property<PropertyType, Property>,
CB &&,
int64_t start) {
4141 template <
typename PropertyType, PropertyType Property, auto Value,
typename CB>
4142 constexpr
auto negative_helper(ctre::property<PropertyType, Property, Value>,
CB &&,
int64_t start) {
4146 template <
typename Head,
typename... Rest,
typename CB> constexpr
int64_t negative_helper(ctre::set<Head, Rest...>,
CB & cb,
int64_t start) {
4147 start = negative_helper(Head{}, cb, start);
4148 return negative_helper(ctre::set<Rest...>{}, cb, start);
4152 start = negative_helper(Head{}, cb, start);
4153 negative_helper(ctre::negative_set<Rest...>{}, std::forward<CB>(cb), start);
4164 template <
size_t Capacity>
class point_set {
4168 constexpr
bool operator<(
const point & rhs)
const {
4169 return low < rhs.low;
4171 constexpr point() { }
4174 point points[Capacity+1]{};
4176 constexpr point * begin() {
4179 constexpr point * begin()
const {
4182 constexpr point * end() {
4183 return points + used;
4185 constexpr point * end()
const {
4186 return points + used;
4188 constexpr point * lower_bound(point obj) {
4189 auto first = begin();
4193 while (
count != 0) {
4195 auto step =
count / 2;
4196 std::advance(it, step);
4206 constexpr point * insert_point(
int64_t position,
int64_t other) {
4207 point obj{position, other};
4208 auto it = lower_bound(obj);
4233 constexpr point_set() { }
4235 insert_point(low, high);
4239 for (
auto r: *
this) {
4240 if (
r.low <= low && low <=
r.high) {
4242 }
else if (
r.low <= high && high <=
r.high) {
4244 }
else if (low <=
r.low &&
r.low <= high) {
4246 }
else if (low <=
r.high &&
r.high <= high) {
4254 template <auto V> constexpr
bool check(ctre::character<V>) {
4257 template <auto A, auto B> constexpr
bool check(ctre::char_range<A,B>) {
4260 constexpr
bool check(can_be_anything) {
4263 template <
typename... Content> constexpr
bool check(ctre::negative_set<Content...> nset) {
4264 bool collision =
false;
4266 collision |= this->
check(low, high);
4270 template <
auto... V> constexpr
bool check(ctre::enumeration<V...>) {
4272 return (
check(V,V) || ... ||
false);
4275 return (
check(Content{}) || ... ||
false);
4277 template <
typename... Content> constexpr
bool check(ctre::set<Content...>) {
4278 return (
check(Content{}) || ... ||
false);
4282 template <auto V> constexpr
void populate(ctre::character<V>) {
4285 template <auto A, auto B> constexpr
void populate(ctre::char_range<A,B>) {
4288 constexpr
void populate(...) {
4293 template <
typename... Content> constexpr
void populate(ctre::negative_set<Content...> nset) {
4295 this->insert(low, high);
4298 template <
typename... Content> constexpr
void populate(ctre::set<Content...>) {
4299 (populate(Content{}), ...);
4302 (populate(Content{}), ...);
4307 constexpr
size_t capacity = calculate_size_of_first(rhs);
4309 point_set<capacity>
set;
4312 return set.check(lhs);
4323 #ifndef CTRE_MSVC_GREEDY_WORKAROUND
4324 #define CTRE_MSVC_GREEDY_WORKAROUND
4330 template <
size_t Limit> constexpr CTRE_FORCE_INLINE
bool less_than_or_infinite([[maybe_unused]]
size_t i) noexcept {
4331 if constexpr (Limit == 0) {
4339 template <
size_t Limit> constexpr CTRE_FORCE_INLINE
bool less_than([[maybe_unused]]
size_t i) noexcept {
4340 if constexpr (Limit == 0) {
4348 constexpr
bool is_bidirectional(
const std::bidirectional_iterator_tag &) {
return true; }
4349 constexpr
bool is_bidirectional(...) {
return false; }
4352 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator>
4353 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator, Iterator,
const EndIterator,
flags,
R, ...) noexcept {
4358 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator>
4359 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator, Iterator,
const EndIterator,
flags,
R captures,
ctll::list<accept>) noexcept {
4360 return captures.matched();
4364 template <
typename R,
typename... Rest,
typename BeginIterator,
typename Iterator,
typename EndIterator>
4370 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4376 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4382 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4383 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 {
4384 if (cannot_be_empty_match(
f)) {
4388 return captures.set_end_mark(current).matched();
4393 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>())>)>>
4395 if (current ==
last)
return not_matched;
4396 if (!CharacterLike::match_char(*current,
f))
return not_matched;
4401 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4403 if (current ==
last)
return not_matched;
4405 if (multiline_mode(
f)) {
4407 if (*current ==
'\n')
return not_matched;
4413 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) {
4414 return ((current !=
last && character<String>::match_char(*current++,
f)) && ... &&
true);
4417 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
auto... String,
typename... Tail>
4418 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 {
4419 if (!match_string<String...>(current,
last,
f)) {
4423 return evaluate(begin, current,
last, consumed_something(
f,
sizeof...(String) > 0), captures,
ctll::list<Tail...>());
4427 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename HeadOptions,
typename... TailOptions,
typename... Tail>
4428 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 {
4432 return evaluate(begin, current,
last,
f, captures,
ctll::list<select<TailOptions...>, Tail...>());
4436 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4437 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator, Iterator,
const EndIterator,
flags,
R,
ctll::list<select<>, Tail...>) noexcept {
4443 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename HeadContent,
typename... TailContent,
typename... Tail>
4444 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator begin, Iterator current,
const EndIterator
last,
const flags &
f,
R captures,
ctll::list<sequence<HeadContent, TailContent...>, Tail...>) noexcept {
4445 if constexpr (
sizeof...(TailContent) > 0) {
4446 return evaluate(begin, current,
last,
f, captures,
ctll::list<HeadContent, sequence<TailContent...>, Tail...>());
4453 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4459 template <
typename R,
typename BeginIterator,
typename Iterator,
typename EndIterator,
typename... Tail>
4460 constexpr CTRE_FORCE_INLINE
R evaluate(
const BeginIterator begin, Iterator current,
const EndIterator
last,
const