/* Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --- LLVM Exceptions to the Apache 2.0 License ---- As an exception, if, as a result of your compiling your source code, portions of this Software are embedded into an Object form of such source code, you may redistribute such embedded portions in such Object form without complying with the conditions of Sections 4(a), 4(b) and 4(d) of the License. In addition, if you combine or link compiled forms of this Software with software that is licensed under the GPLv2 ("Combined Software") and if a court of competent jurisdiction determines that the patent provision (Section 3), the indemnity provision (Section 9) or other Section of the License conflicts with the conditions of the GPLv2, you may retroactively and prospectively choose to deem waived or otherwise exclude such Section(s) of the License, but only in their entirety and only with respect to the Combined Software. */ #ifndef CTRE_V2__CTRE__HPP #define CTRE_V2__CTRE__HPP #ifndef CTRE_V2__CTRE__LITERALS__HPP #define CTRE_V2__CTRE__LITERALS__HPP #ifndef CTRE_V2__CTLL__HPP #define CTRE_V2__CTLL__HPP #ifndef CTLL__PARSER__HPP #define CTLL__PARSER__HPP #ifndef CTLL__FIXED_STRING__GPP #define CTLL__FIXED_STRING__GPP #include #include #include #include namespace ctll { struct length_value_t { uint32_t value; uint8_t length; }; constexpr length_value_t length_and_value_of_utf8_code_point(uint8_t first_unit) noexcept { if ((first_unit & 0b1000'0000) == 0b0000'0000) return {static_cast(first_unit), 1}; else if ((first_unit & 0b1110'0000) == 0b1100'0000) return {static_cast(first_unit & 0b0001'1111), 2}; else if ((first_unit & 0b1111'0000) == 0b1110'0000) return {static_cast(first_unit & 0b0000'1111), 3}; else if ((first_unit & 0b1111'1000) == 0b1111'0000) return {static_cast(first_unit & 0b0000'0111), 4}; else if ((first_unit & 0b1111'1100) == 0b1111'1000) return {static_cast(first_unit & 0b0000'0011), 5}; else if ((first_unit & 0b1111'1100) == 0b1111'1100) return {static_cast(first_unit & 0b0000'0001), 6}; else return {0, 0}; } constexpr char32_t value_of_trailing_utf8_code_point(uint8_t unit, bool & correct) noexcept { if ((unit & 0b1100'0000) == 0b1000'0000) return unit & 0b0011'1111; else { correct = false; return 0; } } constexpr length_value_t length_and_value_of_utf16_code_point(uint16_t first_unit) noexcept { if ((first_unit & 0b1111110000000000) == 0b1101'1000'0000'0000) return {static_cast(first_unit & 0b0000001111111111), 2}; else return {first_unit, 1}; } template struct fixed_string { char32_t content[N] = {}; size_t real_size{0}; bool correct_flag{true}; template constexpr fixed_string(const T (&input)[N+1]) noexcept { if constexpr (std::is_same_v) { #if CTRE_STRING_IS_UTF8 size_t out{0}; for (size_t i{0}; i < N; ++i) { if ((i == (N-1)) && (input[i] == 0)) break; length_value_t info = length_and_value_of_utf8_code_point(input[i]); switch (info.length) { case 6: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 5: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 4: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 3: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 2: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 1: content[out++] = static_cast(info.value); real_size++; break; default: correct_flag = false; return; } } #else for (size_t i{0}; i < N; ++i) { content[i] = static_cast(input[i]); if ((i == (N-1)) && (input[i] == 0)) break; real_size++; } #endif #if __cpp_char8_t } else if constexpr (std::is_same_v) { size_t out{0}; for (size_t i{0}; i < N; ++i) { if ((i == (N-1)) && (input[i] == 0)) break; length_value_t info = length_and_value_of_utf8_code_point(input[i]); switch (info.length) { case 6: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 5: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 4: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 3: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 2: if (++i < N) info.value = (info.value << 6) | value_of_trailing_utf8_code_point(input[i], correct_flag); [[fallthrough]]; case 1: content[out++] = static_cast(info.value); real_size++; break; default: correct_flag = false; return; } } #endif } else if constexpr (std::is_same_v) { size_t out{0}; for (size_t i{0}; i < N; ++i) { length_value_t info = length_and_value_of_utf16_code_point(input[i]); if (info.length == 2) { if (++i < N) { if ((input[i] & 0b1111'1100'0000'0000) == 0b1101'1100'0000'0000) { content[out++] = (info.value << 10) | (input[i] & 0b0000'0011'1111'1111); } else { correct_flag = false; break; } } } else { if ((i == (N-1)) && (input[i] == 0)) break; content[out++] = info.value; } } real_size = out; } else if constexpr (std::is_same_v || std::is_same_v) { for (size_t i{0}; i < N; ++i) { content[i] = input[i]; if ((i == (N-1)) && (input[i] == 0)) break; real_size++; } } } constexpr fixed_string(const fixed_string & other) noexcept { for (size_t i{0}; i < N; ++i) { content[i] = other.content[i]; } real_size = other.real_size; correct_flag = other.correct_flag; } constexpr bool correct() const noexcept { return correct_flag; } constexpr size_t size() const noexcept { return real_size; } constexpr const char32_t * begin() const noexcept { return content; } constexpr const char32_t * end() const noexcept { return content + size(); } constexpr char32_t operator[](size_t i) const noexcept { return content[i]; } template constexpr bool is_same_as(const fixed_string & rhs) const noexcept { if (real_size != rhs.size()) return false; for (size_t i{0}; i != real_size; ++i) { if (content[i] != rhs[i]) return false; } return true; } constexpr operator std::basic_string_view() const noexcept { return std::basic_string_view{content, size()}; } }; template <> class fixed_string<0> { static constexpr char32_t empty[1] = {0}; public: template constexpr fixed_string(const T *) noexcept { } constexpr fixed_string(std::initializer_list) noexcept { } constexpr fixed_string(const fixed_string &) noexcept { } constexpr bool correct() const noexcept { return true; } constexpr size_t size() const noexcept { return 0; } constexpr const char32_t * begin() const noexcept { return empty; } constexpr const char32_t * end() const noexcept { return empty + size(); } constexpr char32_t operator[](size_t) const noexcept { return 0; } constexpr operator std::basic_string_view() const noexcept { return std::basic_string_view{empty, 0}; } }; template fixed_string(const CharT (&)[N]) -> fixed_string; template fixed_string(fixed_string) -> fixed_string; } #if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L)) #define CTLL_FIXED_STRING ctll::fixed_string #else #define CTLL_FIXED_STRING const auto & #endif #endif #ifndef CTLL__TYPE_STACK__HPP #define CTLL__TYPE_STACK__HPP #ifndef CTLL__UTILITIES__HPP #define CTLL__UTILITIES__HPP #include #ifdef _MSC_VER #define CTLL_FORCE_INLINE __forceinline #else #define CTLL_FORCE_INLINE __attribute__((always_inline)) #endif namespace ctll { template struct conditional_helper; template <> struct conditional_helper { template using type = A; }; template <> struct conditional_helper { template using type = B; }; template using conditional = typename conditional_helper::template type; } #endif namespace ctll { template struct list { }; struct _nothing { }; using empty_list = list<>; // calculate size of list content template constexpr auto size(list) noexcept { return sizeof...(Ts); } // check if the list is empty template constexpr bool empty(list) noexcept { return false; } constexpr bool empty(empty_list) { return true; } // concat two lists together left to right template constexpr auto concat(list, list) noexcept -> list { return {}; } // push something to the front of a list template constexpr auto push_front(T, list) noexcept -> list { return {}; } // pop element from the front of a list template constexpr auto pop_front(list) noexcept -> list { return {}; } constexpr auto pop_front(empty_list) -> empty_list; // pop element from the front of a list and return new typelist too template struct list_pop_pair { Front front{}; List list{}; constexpr list_pop_pair() = default; }; template constexpr auto pop_and_get_front(list, T = T()) noexcept -> list_pop_pair> { return {}; } template constexpr auto pop_and_get_front(empty_list, T = T()) noexcept -> list_pop_pair { return {}; } // return front of the list template constexpr auto front(list, T = T()) noexcept -> Head { return {}; } template constexpr auto front(empty_list, T = T()) noexcept -> T { return {}; } } #endif #ifndef CTLL__GRAMMARS__HPP #define CTLL__GRAMMARS__HPP namespace ctll { // terminal type representing symbol / character of any type template struct term { static constexpr auto value = v; }; // epsilon = nothing on input tape // also used as an command for parsing means "do nothing" struct epsilon { static constexpr auto value = '-'; }; // empty_stack_symbol = nothing on stack struct empty_stack_symbol {}; // push is alias to list template using push = list; // accept/reject type for controlling output of LL1 machine struct accept { constexpr explicit operator bool() noexcept { return true; } }; struct reject { constexpr explicit operator bool() noexcept { return false; } }; // action type, every action item in grammar must inherit from struct action { struct action_tag { }; }; // move one character forward and pop it from stack command struct pop_input { struct pop_input_tag { }; }; // additional overloads for type list template constexpr auto push_front(pop_input, list) -> list { return {}; } template constexpr auto push_front(epsilon, list) -> list { return {}; } template constexpr auto push_front(list, list) -> list { return {}; } template constexpr auto pop_front_and_push_front(T item, list l) { return push_front(item, pop_front(l)); } // SPECIAL matching types for nicer grammars // match any term struct anything { constexpr inline anything() noexcept { } template constexpr anything(term) noexcept; }; // match range of term A-B template struct range { constexpr inline range() noexcept { } //template constexpr range(term) noexcept requires (A <= V) && (V <= B); template > constexpr inline range(term) noexcept; }; #ifdef __EDG__ template struct contains { static constexpr bool value = ((Set == V) || ... || false); }; #endif // match terms defined in set template struct set { constexpr inline set() noexcept { } #ifdef __EDG__ template ::value>> constexpr inline set(term) noexcept; #else template > constexpr inline set(term) noexcept; #endif }; // match terms not defined in set template struct neg_set { constexpr inline neg_set() noexcept { } #ifdef __EDG__ template ::value>> constexpr inline neg_set(term) noexcept; #else template > constexpr inline neg_set(term) noexcept; #endif }; // AUGMENTED grammar which completes user-defined grammar for all other cases template struct augment_grammar: public Grammar { // start nonterminal is defined in parent type using typename Grammar::_start; // grammar rules are inherited from Grammar parent type using Grammar::rule; // term on stack and on input means pop_input; template static constexpr auto rule(term, term) -> ctll::pop_input; // if the type on stack (range, set, neg_set, anything) is constructible from the terminal => pop_input template static constexpr auto rule(Expected, term) -> std::enable_if_t>, ctll::pop_input>; // empty stack and empty input means we are accepting static constexpr auto rule(empty_stack_symbol, epsilon) -> ctll::accept; // not matching anything else => reject static constexpr auto rule(...) -> ctll::reject; // start stack is just a list; using start_stack = list; }; } #endif #ifndef CTLL__ACTIONS__HPP #define CTLL__ACTIONS__HPP namespace ctll { struct empty_subject { }; struct empty_actions { // dummy operator so using Actions::operator() later will not give error template static constexpr auto apply(Action, InputSymbol, Subject subject) { return subject; } }; template struct identity: public Actions { using Actions::apply; // allow empty_subject to exists template constexpr static auto apply(Action, term, empty_subject) -> empty_subject { return {}; } template constexpr static auto apply(Action, epsilon, empty_subject) -> empty_subject { return {}; } }; template struct ignore_unknown: public Actions { using Actions::apply; // allow flow thru unknown actions template constexpr static auto apply(Action, term, Subject) -> Subject { return {}; } template constexpr static auto apply(Action, epsilon, Subject) -> Subject { return {}; } }; } #endif #include namespace ctll { enum class decision { reject, accept, undecided }; struct placeholder { }; template using index_placeholder = placeholder; #if ((__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L)) || (__cpp_nontype_template_args >= 201911L)) template struct parser { // in c++20 #else template struct parser { #endif #ifdef __GNUC__ // workaround to GCC bug #if ((__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L)) || (__cpp_nontype_template_args >= 201911L)) static constexpr auto _input = input; // c++20 mode #else static constexpr auto & _input = input; // c++17 mode #endif #else static constexpr auto _input = input; // everyone else #endif using Actions = ctll::conditional, identity>; using grammar = augment_grammar; template struct results { constexpr inline CTLL_FORCE_INLINE operator bool() const noexcept { return Decision == decision::accept; } #ifdef __GNUC__ // workaround to GCC bug #if ((__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L)) || (__cpp_nontype_template_args >= 201911L)) static constexpr auto _input = input; // c++20 mode #else static constexpr auto & _input = input; // c++17 mode #endif #else static constexpr auto _input = input; // everyone else #endif using output_type = Subject; constexpr auto operator+(placeholder) const noexcept { if constexpr (Decision == decision::undecided) { // parse for current char (RPos) with previous stack and subject :) return parser::template decide({}, {}); } else { // if there is decision already => just push it to the end of fold expression return *this; } } }; template static constexpr auto get_current_term() noexcept { if constexpr (Pos < input.size()) { constexpr auto value = input[Pos]; if constexpr (value <= std::numeric_limits::max()) { return term(value)>{}; } else { return term{}; } } else { // return epsilon if we are past the input return epsilon{}; } } template static constexpr auto get_previous_term() noexcept { if constexpr (Pos == 0) { // there is no previous character on input if we are on start return epsilon{}; } else if constexpr ((Pos-1) < input.size()) { constexpr auto value = input[Pos-1]; if constexpr (value <= std::numeric_limits::max()) { return term(value)>{}; } else { return term{}; } } else { return epsilon{}; } } // if rule is accept => return true and subject template static constexpr auto move(ctll::accept, Terminal, Stack, Subject) noexcept { return typename parser::template results(); } // if rule is reject => return false and subject template static constexpr auto move(ctll::reject, Terminal, Stack, Subject) noexcept { return typename parser::template results(); } // if rule is pop_input => move to next character template static constexpr auto move(ctll::pop_input, Terminal, Stack, Subject) noexcept { return typename parser::template results(); } // if rule is string => push it to the front of stack template static constexpr auto move(push string, Terminal, Stack stack, Subject subject) noexcept { return decide(push_front(string, stack), subject); } // if rule is epsilon (empty string) => continue template static constexpr auto move(epsilon, Terminal, Stack stack, Subject subject) noexcept { return decide(stack, subject); } // if rule is string with current character at the beginning (term) => move to next character // and push string without the character (quick LL(1)) template static constexpr auto move(push, Content...>, term, Stack stack, Subject) noexcept { constexpr auto _input = input; return typename parser::template results(), stack)), Subject, decision::undecided>(); } // if rule is string with any character at the beginning (compatible with current term) => move to next character // and push string without the character (quick LL(1)) template static constexpr auto move(push, term, Stack stack, Subject) noexcept { constexpr auto _input = input; return typename parser::template results(), stack)), Subject, decision::undecided>(); } // decide if we need to take action or move template static constexpr auto decide(Stack previous_stack, Subject previous_subject) noexcept { // each call means we pop something from stack auto top_symbol = decltype(ctll::front(previous_stack, empty_stack_symbol()))(); // gcc pedantic warning [[maybe_unused]] auto stack = decltype(ctll::pop_front(previous_stack))(); // in case top_symbol is action type (apply it on previous subject and get new one) if constexpr (std::is_base_of_v) { auto subject = Actions::apply(top_symbol, get_previous_term(), previous_subject); // in case that semantic action is error => reject input if constexpr (std::is_same_v) { return typename parser::template results(); } else { return decide(stack, subject); } } else { // all other cases are ordinary for LL(1) parser auto current_term = get_current_term(); auto rule = decltype(grammar::rule(top_symbol,current_term))(); return move(rule, current_term, stack, previous_subject); } } // trampolines with folded expression template static constexpr auto trampoline_decide(Subject, std::index_sequence) noexcept { // parse everything for first char and than for next and next ... // Pos+1 is needed as we want to finish calculation with epsilons on stack auto v = (decide<0, typename grammar::start_stack, Subject>({}, {}) + ... + index_placeholder()); return v; } template static constexpr auto trampoline_decide(Subject subject = {}) noexcept { // there will be no recursion, just sequence long as the input return trampoline_decide(subject, std::make_index_sequence()); } template using output = decltype(trampoline_decide()); template static inline constexpr bool correct_with = trampoline_decide(); }; } // end of ctll namespace #endif #endif #ifndef CTRE__PCRE_ACTIONS__HPP #define CTRE__PCRE_ACTIONS__HPP #ifndef CTRE__PCRE__HPP #define CTRE__PCRE__HPP // THIS FILE WAS GENERATED BY DESATOMAT TOOL, DO NOT MODIFY THIS FILE namespace ctre { struct pcre { // NONTERMINALS: struct a {}; struct b {}; struct backslash {}; struct backslash_range {}; struct block {}; struct block_name2 {}; struct block_name {}; struct c {}; struct class_named_name {}; struct content2 {}; struct content_in_capture {}; struct d {}; struct e {}; struct f {}; struct g {}; struct h {}; struct hexdec_repeat {}; struct i {}; struct j {}; struct k {}; struct l {}; struct m {}; struct mod {}; struct mod_opt {}; struct n {}; struct number2 {}; struct number {}; struct o {}; struct p {}; struct property_name2 {}; struct property_name {}; struct property_value2 {}; struct property_value {}; struct q {}; struct range {}; struct repeat {}; struct s {}; using _start = s; struct set2a {}; struct set2b {}; struct string2 {}; // 'action' types: struct class_digit: ctll::action {}; struct class_named_alnum: ctll::action {}; struct class_named_alpha: ctll::action {}; struct class_named_ascii: ctll::action {}; struct class_named_blank: ctll::action {}; struct class_named_cntrl: ctll::action {}; struct class_named_digit: ctll::action {}; struct class_named_graph: ctll::action {}; struct class_named_lower: ctll::action {}; struct class_named_print: ctll::action {}; struct class_named_punct: ctll::action {}; struct class_named_space: ctll::action {}; struct class_named_upper: ctll::action {}; struct class_named_word: ctll::action {}; struct class_named_xdigit: ctll::action {}; struct class_nondigit: ctll::action {}; struct class_nonnewline: ctll::action {}; struct class_nonspace: ctll::action {}; struct class_nonword: ctll::action {}; struct class_space: ctll::action {}; struct class_word: ctll::action {}; struct create_hexdec: ctll::action {}; struct create_number: ctll::action {}; struct finish_hexdec: ctll::action {}; struct look_finish: ctll::action {}; struct make_alternate: ctll::action {}; struct make_back_reference: ctll::action {}; struct make_capture: ctll::action {}; struct make_capture_with_name: ctll::action {}; struct make_lazy: ctll::action {}; struct make_optional: ctll::action {}; struct make_possessive: ctll::action {}; struct make_property: ctll::action {}; struct make_property_negative: ctll::action {}; struct make_range: ctll::action {}; struct make_relative_back_reference: ctll::action {}; struct make_sequence: ctll::action {}; struct negate_class_named: ctll::action {}; struct prepare_capture: ctll::action {}; struct push_assert_begin: ctll::action {}; struct push_assert_end: ctll::action {}; struct push_character: ctll::action {}; struct push_character_alarm: ctll::action {}; struct push_character_anything: ctll::action {}; struct push_character_escape: ctll::action {}; struct push_character_formfeed: ctll::action {}; struct push_character_newline: ctll::action {}; struct push_character_null: ctll::action {}; struct push_character_return_carriage: ctll::action {}; struct push_character_tab: ctll::action {}; struct push_empty: ctll::action {}; struct push_hexdec: ctll::action {}; struct push_name: ctll::action {}; struct push_number: ctll::action {}; struct push_property_name: ctll::action {}; struct push_property_value: ctll::action {}; struct repeat_ab: ctll::action {}; struct repeat_at_least: ctll::action {}; struct repeat_exactly: ctll::action {}; struct repeat_plus: ctll::action {}; struct repeat_star: ctll::action {}; struct reset_capture: ctll::action {}; struct set_combine: ctll::action {}; struct set_make: ctll::action {}; struct set_make_negative: ctll::action {}; struct set_start: ctll::action {}; struct start_lookahead_negative: ctll::action {}; struct start_lookahead_positive: ctll::action {}; // (q)LL1 function: 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','[','\\',']','^','_','a','b','c','d','e','f','g','h','0','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'>; static constexpr auto rule(s, ctll::term<'\\'>) -> ctll::push; static constexpr auto rule(s, ctll::term<'['>) -> ctll::push; static constexpr auto rule(s, ctll::term<'\x28'>) -> ctll::push; static constexpr auto rule(s, ctll::term<'^'>) -> ctll::push; static constexpr auto rule(s, ctll::term<'$'>) -> ctll::push; static constexpr auto rule(s, ctll::set<'!',',','-',':','<','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',']','_','0','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; static constexpr auto rule(s, _others) -> ctll::push; static constexpr auto rule(s, ctll::term<'.'>) -> ctll::push; static constexpr auto rule(s, ctll::epsilon) -> ctll::push; static constexpr auto rule(s, ctll::set<'\x29','*','+','?','\x7B','|','\x7D'>) -> ctll::reject; static constexpr auto rule(a, ctll::term<'\\'>) -> ctll::push; static constexpr auto rule(a, ctll::term<'['>) -> ctll::push; static constexpr auto rule(a, ctll::term<'\x28'>) -> ctll::push; static constexpr auto rule(a, ctll::term<'^'>) -> ctll::push; static constexpr auto rule(a, ctll::term<'$'>) -> ctll::push; static constexpr auto rule(a, ctll::set<'!',',','-',':','<','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',']','_','0','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; static constexpr auto rule(a, _others) -> ctll::push; static constexpr auto rule(a, ctll::term<'.'>) -> ctll::push; static constexpr auto rule(a, ctll::term<'\x29'>) -> ctll::push; static constexpr auto rule(a, ctll::epsilon) -> ctll::push; static constexpr auto rule(a, ctll::set<'*','+','?','\x7B','|','\x7D'>) -> ctll::reject; static constexpr auto rule(b, ctll::term<','>) -> ctll::push; static constexpr auto rule(b, ctll::term<'\x7D'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'d'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'D'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'N'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'S'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'W'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'s'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'w'>) -> ctll::push; static constexpr auto rule(backslash, ctll::set<'1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'g'>) -> ctll::push, m>; static constexpr auto rule(backslash, ctll::term<'p'>) -> ctll::push, property_name, ctll::term<'\x7D'>, make_property>; static constexpr auto rule(backslash, ctll::term<'P'>) -> ctll::push, property_name, ctll::term<'\x7D'>, make_property_negative>; static constexpr auto rule(backslash, ctll::term<'u'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'x'>) -> ctll::push; static constexpr auto rule(backslash, ctll::set<'$','\x28','\x29','*','+','-','.','?','[','\\',']','^','\x7B','|','\x7D'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'a'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'e'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'f'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'n'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'0'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'r'>) -> ctll::push; static constexpr auto rule(backslash, ctll::term<'t'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'u'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'x'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'-'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'a'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'e'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'f'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'n'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'0'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'r'>) -> ctll::push; static constexpr auto rule(backslash_range, ctll::term<'t'>) -> ctll::push; static constexpr auto rule(block, ctll::term<'\\'>) -> ctll::push>; static constexpr auto rule(block, ctll::term<'['>) -> ctll::push>; static constexpr auto rule(block, ctll::term<'?'>) -> ctll::push; static constexpr auto rule(block, ctll::term<'\x28'>) -> ctll::push>; static constexpr auto rule(block, ctll::term<'^'>) -> ctll::push>; static constexpr auto rule(block, ctll::term<'$'>) -> ctll::push>; static constexpr auto rule(block, ctll::set<'!',',','-',':','<','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',']','_','0','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>; static constexpr auto rule(block, _others) -> ctll::push>; static constexpr auto rule(block, ctll::term<'.'>) -> ctll::push>; static constexpr auto rule(block, ctll::term<'\x29'>) -> ctll::push; static constexpr auto rule(block, ctll::set<'*','+','\x7B','|','\x7D'>) -> ctll::reject; static constexpr auto rule(block_name2, ctll::set<'>','\x7D'>) -> ctll::epsilon; 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; static constexpr auto rule(block_name, 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; static constexpr auto rule(c, ctll::term<'['>) -> ctll::push, i, range, set_start, set2b, set_make, ctll::term<']'>>; static constexpr auto rule(c, ctll::term<'\\'>) -> ctll::push>; static constexpr auto rule(c, 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','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','0','s','t','u','v','w','x','y','z','\x7B','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::push>; static constexpr auto rule(c, _others) -> ctll::push>; static constexpr auto rule(c, ctll::term<'^'>) -> ctll::push>; static constexpr auto rule(c, ctll::set<'-',']','|'>) -> ctll::reject; static constexpr auto rule(class_named_name, ctll::term<'x'>) -> ctll::push, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_xdigit>; static constexpr auto rule(class_named_name, ctll::term<'d'>) -> ctll::push, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_digit>; static constexpr auto rule(class_named_name, ctll::term<'b'>) -> ctll::push, ctll::term<'a'>, ctll::term<'n'>, ctll::term<'k'>, class_named_blank>; static constexpr auto rule(class_named_name, ctll::term<'c'>) -> ctll::push, ctll::term<'t'>, ctll::term<'r'>, ctll::term<'l'>, class_named_cntrl>; static constexpr auto rule(class_named_name, ctll::term<'w'>) -> ctll::push, ctll::term<'r'>, ctll::term<'d'>, class_named_word>; static constexpr auto rule(class_named_name, ctll::term<'l'>) -> ctll::push, ctll::term<'w'>, ctll::term<'e'>, ctll::term<'r'>, class_named_lower>; static constexpr auto rule(class_named_name, ctll::term<'s'>) -> ctll::push, ctll::term<'a'>, ctll::term<'c'>, ctll::term<'e'>, class_named_space>; static constexpr auto rule(class_named_name, ctll::term<'u'>) -> ctll::push, ctll::term<'p'>, ctll::term<'e'>, ctll::term<'r'>, class_named_upper>; static constexpr auto rule(class_named_name, ctll::term<'g'>) -> ctll::push, ctll::term<'a'>, ctll::term<'p'>, ctll::term<'h'>, class_named_graph>; static constexpr auto rule(class_named_name, ctll::term<'a'>) -> ctll::push; static constexpr auto rule(class_named_name, ctll::term<'p'>) -> ctll::push; static constexpr auto rule(content2, ctll::term<'\x29'>) -> ctll::epsilon; static constexpr auto rule(content2, ctll::epsilon) -> ctll::epsilon; static constexpr auto rule(content2, ctll::term<'|'>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::term<'\\'>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::term<'['>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::term<'\x28'>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::term<'^'>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::term<'$'>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::set<'!',',','-',':','<','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',']','_','0','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; static constexpr auto rule(content_in_capture, _others) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::term<'.'>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::term<'\x29'>) -> ctll::push; static constexpr auto rule(content_in_capture, ctll::set<'*','+','?','\x7B','|','\x7D'>) -> ctll::reject; static constexpr auto rule(d, ctll::term<'<'>) -> ctll::push'>, content_in_capture, make_capture_with_name, ctll::term<'\x29'>>; static constexpr auto rule(d, ctll::term<':'>) -> ctll::push>; static constexpr auto rule(d, ctll::term<'!'>) -> ctll::push>; static constexpr auto rule(d, ctll::term<'='>) -> ctll::push>; static constexpr auto rule(e, ctll::term<'d'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'D'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'N'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'S'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'W'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'s'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'w'>) -> ctll::push; static constexpr auto rule(e, ctll::set<'1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'p'>) -> ctll::push, property_name, ctll::term<'\x7D'>, make_property>; static constexpr auto rule(e, ctll::term<'P'>) -> ctll::push, property_name, ctll::term<'\x7D'>, make_property_negative>; static constexpr auto rule(e, ctll::term<'u'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'x'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'-'>) -> ctll::push; static constexpr auto rule(e, ctll::set<'$','\x28','\x29','*','+','.','?','[','\\',']','^','\x7B','|','\x7D'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'a'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'e'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'f'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'n'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'0'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'r'>) -> ctll::push; static constexpr auto rule(e, ctll::term<'t'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'d'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'D'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'N'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'S'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'W'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'s'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'w'>) -> ctll::push; static constexpr auto rule(f, ctll::set<'1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'p'>) -> ctll::push, property_name, ctll::term<'\x7D'>, make_property>; static constexpr auto rule(f, ctll::term<'P'>) -> ctll::push, property_name, ctll::term<'\x7D'>, make_property_negative>; static constexpr auto rule(f, ctll::term<'u'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'x'>) -> ctll::push; static constexpr auto rule(f, ctll::set<'$','\x28','\x29','*','+','.','?','[','\\',']','^','\x7B','|','\x7D'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'a'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'e'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'f'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'n'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'0'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'r'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'t'>) -> ctll::push; static constexpr auto rule(f, ctll::term<'-'>) -> ctll::push; static constexpr auto rule(g, ctll::term<'s'>) -> ctll::push, ctll::term<'i'>, ctll::term<'i'>, class_named_ascii>; static constexpr auto rule(g, ctll::term<'l'>) -> ctll::push; static constexpr auto rule(h, ctll::term<'r'>) -> ctll::push, ctll::term<'n'>, ctll::term<'t'>, class_named_print>; static constexpr auto rule(h, ctll::term<'u'>) -> ctll::push, ctll::term<'c'>, ctll::term<'t'>, class_named_punct>; static constexpr auto rule(hexdec_repeat, ctll::term<'\x7D'>) -> ctll::epsilon; 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; static constexpr auto rule(i, ctll::term<'^'>) -> ctll::push, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'x'>) -> ctll::push, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_xdigit, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'d'>) -> ctll::push, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_digit, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'b'>) -> ctll::push, ctll::term<'a'>, ctll::term<'n'>, ctll::term<'k'>, class_named_blank, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'c'>) -> ctll::push, ctll::term<'t'>, ctll::term<'r'>, ctll::term<'l'>, class_named_cntrl, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'w'>) -> ctll::push, ctll::term<'r'>, ctll::term<'d'>, class_named_word, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'l'>) -> ctll::push, ctll::term<'w'>, ctll::term<'e'>, ctll::term<'r'>, class_named_lower, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'s'>) -> ctll::push, ctll::term<'a'>, ctll::term<'c'>, ctll::term<'e'>, class_named_space, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'u'>) -> ctll::push, ctll::term<'p'>, ctll::term<'e'>, ctll::term<'r'>, class_named_upper, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'g'>) -> ctll::push, ctll::term<'a'>, ctll::term<'p'>, ctll::term<'h'>, class_named_graph, ctll::term<':'>, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'a'>) -> ctll::push, ctll::term<']'>>; static constexpr auto rule(i, ctll::term<'p'>) -> ctll::push, ctll::term<']'>>; static constexpr auto rule(j, ctll::term<'\\'>) -> ctll::push; 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','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','0','s','t','u','v','w','x','y','z','\x7B','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(j, _others) -> ctll::push; static constexpr auto rule(j, ctll::set<'-','[',']','^','|'>) -> ctll::reject; static constexpr auto rule(k, ctll::term<'\x7B'>) -> ctll::push, push_hexdec, hexdec_repeat, ctll::term<'\x7D'>, finish_hexdec>; 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, 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>; static constexpr auto rule(l, ctll::term<'\x7B'>) -> ctll::push, push_hexdec, hexdec_repeat, ctll::term<'\x7D'>, finish_hexdec>; 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, push_hexdec, finish_hexdec>; static constexpr auto rule(m, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push, make_back_reference>; static constexpr auto rule(m, ctll::term<'-'>) -> ctll::push, make_relative_back_reference>; 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, make_back_reference>; static constexpr auto rule(mod, 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','[','\\',']','^','_','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','1','2','3','4','5','6','7','8','9'>) -> ctll::epsilon; static constexpr auto rule(mod, ctll::epsilon) -> ctll::epsilon; static constexpr auto rule(mod, _others) -> ctll::epsilon; static constexpr auto rule(mod, ctll::term<'?'>) -> ctll::push; static constexpr auto rule(mod, ctll::term<'+'>) -> ctll::push; static constexpr auto rule(mod, ctll::set<'*','\x7B','\x7D'>) -> ctll::reject; static constexpr auto rule(mod_opt, 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','[','\\',']','^','_','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','1','2','3','4','5','6','7','8','9'>) -> ctll::epsilon; static constexpr auto rule(mod_opt, ctll::epsilon) -> ctll::epsilon; static constexpr auto rule(mod_opt, _others) -> ctll::epsilon; static constexpr auto rule(mod_opt, ctll::term<'?'>) -> ctll::push; static constexpr auto rule(mod_opt, ctll::set<'*','+','\x7B','\x7D'>) -> ctll::reject; static constexpr auto rule(n, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push, mod>; static constexpr auto rule(n, ctll::term<'\x7D'>) -> ctll::push; static constexpr auto rule(number2, ctll::set<',','\x7D'>) -> ctll::epsilon; static constexpr auto rule(number2, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(number, ctll::set<'0','1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(o, ctll::term<'p'>) -> ctll::push, ctll::term<'a'>, class_named_alpha>; static constexpr auto rule(o, ctll::term<'n'>) -> ctll::push, ctll::term<'m'>, class_named_alnum>; static constexpr auto rule(p, ctll::term<'-'>) -> ctll::push; static constexpr auto rule(p, 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','[','\\',']','^','_','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','0','1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(p, ctll::epsilon) -> ctll::push; static constexpr auto rule(p, _others) -> ctll::push; static constexpr auto rule(p, ctll::term<'|'>) -> ctll::reject; static constexpr auto rule(property_name2, ctll::term<'\x7D'>) -> ctll::epsilon; static constexpr auto rule(property_name2, ctll::term<'='>) -> ctll::push; 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; 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; static constexpr auto rule(property_value2, ctll::term<'\x7D'>) -> ctll::epsilon; 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; 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; static constexpr auto rule(q, ctll::term<'-'>) -> ctll::push; static constexpr auto rule(q, 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','[','\\',']','^','_','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','0','1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(q, ctll::epsilon) -> ctll::push; static constexpr auto rule(q, _others) -> ctll::push; static constexpr auto rule(q, ctll::term<'|'>) -> ctll::reject; static constexpr auto rule(range, 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','[','\\',']','^','_','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','0','1','2','3','4','5','6','7','8','9'>) -> ctll::epsilon; static constexpr auto rule(range, ctll::epsilon) -> ctll::epsilon; static constexpr auto rule(range, _others) -> ctll::epsilon; static constexpr auto rule(range, ctll::term<'-'>) -> ctll::push; static constexpr auto rule(range, ctll::term<'|'>) -> ctll::reject; static constexpr auto rule(repeat, 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','[','\\',']','^','_','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','1','2','3','4','5','6','7','8','9'>) -> ctll::epsilon; static constexpr auto rule(repeat, ctll::epsilon) -> ctll::epsilon; static constexpr auto rule(repeat, _others) -> ctll::epsilon; static constexpr auto rule(repeat, ctll::term<'?'>) -> ctll::push; static constexpr auto rule(repeat, ctll::term<'\x7B'>) -> ctll::push; static constexpr auto rule(repeat, ctll::term<'+'>) -> ctll::push; static constexpr auto rule(repeat, ctll::term<'*'>) -> ctll::push; static constexpr auto rule(repeat, ctll::term<'\x7D'>) -> ctll::reject; static constexpr auto rule(set2a, ctll::term<']'>) -> ctll::epsilon; static constexpr auto rule(set2a, ctll::term<'['>) -> ctll::push, i, range, set_start, set2b>; static constexpr auto rule(set2a, ctll::term<'\\'>) -> ctll::push; 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','^','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','0','s','t','u','v','w','x','y','z','\x7B','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(set2a, _others) -> ctll::push; static constexpr auto rule(set2a, ctll::set<'-','|'>) -> ctll::reject; static constexpr auto rule(set2b, ctll::term<']'>) -> ctll::epsilon; static constexpr auto rule(set2b, ctll::term<'['>) -> ctll::push, i, range, set_combine, set2b>; static constexpr auto rule(set2b, ctll::term<'\\'>) -> ctll::push; 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','^','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','0','s','t','u','v','w','x','y','z','\x7B','\x7D','1','2','3','4','5','6','7','8','9'>) -> ctll::push; static constexpr auto rule(set2b, _others) -> ctll::push; static constexpr auto rule(set2b, ctll::set<'-','|'>) -> ctll::reject; static constexpr auto rule(string2, ctll::set<'\x29','|'>) -> ctll::epsilon; static constexpr auto rule(string2, ctll::epsilon) -> ctll::epsilon; static constexpr auto rule(string2, ctll::term<'\\'>) -> ctll::push; static constexpr auto rule(string2, ctll::term<'['>) -> ctll::push; static constexpr auto rule(string2, ctll::term<'\x28'>) -> ctll::push; static constexpr auto rule(string2, ctll::term<'^'>) -> ctll::push; static constexpr auto rule(string2, ctll::term<'$'>) -> ctll::push; static constexpr auto rule(string2, ctll::set<'!',',','-',':','<','=','>','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',']','_','0','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; static constexpr auto rule(string2, _others) -> ctll::push; static constexpr auto rule(string2, ctll::term<'.'>) -> ctll::push; static constexpr auto rule(string2, ctll::set<'*','+','?','\x7B','\x7D'>) -> ctll::reject; }; } #endif //CTRE__PCRE__HPP #ifndef CTRE__ATOMS__HPP #define CTRE__ATOMS__HPP #include namespace ctre { // special helpers for matching struct accept { }; struct reject { }; struct start_mark { }; struct end_mark { }; struct end_cycle_mark { }; struct end_lookahead_mark { }; template struct numeric_mark { }; // actual AST of regexp template struct string { }; template struct select { }; template struct optional { }; template struct lazy_optional { }; template struct sequence { }; struct empty { }; template struct plus { }; template struct star { }; template struct repeat { }; template struct lazy_plus { }; template struct lazy_star { }; template struct lazy_repeat { }; template struct possessive_plus { }; template struct possessive_star { }; template struct possessive_repeat { }; template struct capture { }; template struct capture_with_name { }; template struct back_reference { }; template struct back_reference_with_name { }; template struct look_start { }; template struct lookahead_positive { }; template struct lookahead_negative { }; struct assert_begin { }; struct assert_end { }; } #endif #ifndef CTRE__ATOMS_CHARACTERS__HPP #define CTRE__ATOMS_CHARACTERS__HPP #ifndef CTRE__UTILITY__HPP #define CTRE__UTILITY__HPP #ifdef _MSC_VER #define CTRE_FORCE_INLINE __forceinline #define CTRE_FLATTEN #else #define CTRE_FORCE_INLINE inline __attribute__((always_inline)) #define CTRE_FLATTEN __attribute__((flatten)) #endif #endif #include namespace ctre { // sfinae check for types here template class MatchesCharacter { template static auto test(CharT c) -> decltype(Y::match_char(c), std::true_type()); template static auto test(...) -> std::false_type; public: template static inline constexpr bool value = decltype(test(std::declval()))(); }; template struct character { template CTRE_FORCE_INLINE static constexpr bool match_char(CharT value) noexcept { return value == V; } }; struct any { template CTRE_FORCE_INLINE static constexpr bool match_char(CharT) noexcept { return true; } }; template struct negative_set { template inline static constexpr bool match_char(CharT value) noexcept { return !(Content::match_char(value) || ... || false); } }; template struct set { template inline static constexpr bool match_char(CharT value) noexcept { return (Content::match_char(value) || ... || false); } }; template struct enumeration : set...> { }; template struct negate { template inline static constexpr bool match_char(CharT value) noexcept { return !(Content::match_char(value) || ... || false); } }; template struct char_range { template CTRE_FORCE_INLINE static constexpr bool match_char(CharT value) noexcept { return (value >= A) && (value <= B); } }; using word_chars = set, char_range<'a','z'>, char_range<'0','9'>, character<'_'> >; using space_chars = enumeration<' ', '\t', '\n', '\v', '\f', '\r'>; using alphanum_chars = set, char_range<'a','z'>, char_range<'0','9'> >; using alpha_chars = set, char_range<'a','z'> >; using xdigit_chars = set, char_range<'a','f'>, char_range<'0','9'> >; using punct_chars = enumeration<'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`', '{', '|', '}', '~'>; using digit_chars = char_range<'0','9'>; using ascii_chars = char_range<'\x00','\x7F'>; } #endif #ifndef CTRE__ATOMS_UNICODE__HPP #define CTRE__ATOMS_UNICODE__HPP // master branch is not including unicode db (for now) // #include "../unicode-db/unicode.hpp" #include namespace ctre { // properties name & value template struct property_name { }; template struct property_value { }; template constexpr std::string_view get_string_view(const std::array & arr) noexcept { return std::string_view(arr.data(), arr.size()); } // basic support for binary and type-value properties template struct binary_property; template struct property; // unicode TS#18 level 1.2 general_category //template struct binary_property { // template inline static constexpr bool match_char(CharT) noexcept { // return uni::__get_binary_prop(c); // } //}; // unicode TS#18 level 1.2.2 enum class property_type { script, script_extension, age, block, unknown }; // unicode TS#18 level 1.2.2 //template struct binary_property