diff --git a/source/reflect.h b/source/reflect.h index 2025b2f193..91e0ed798b 100644 --- a/source/reflect.h +++ b/source/reflect.h @@ -33,77 +33,77 @@ class object_declaration; #line 467 "reflect.h2" class type_declaration; -#line 604 "reflect.h2" +#line 605 "reflect.h2" class alias_declaration; -#line 1022 "reflect.h2" +#line 1013 "reflect.h2" class value_member_info; -#line 1540 "reflect.h2" +#line 1531 "reflect.h2" class expression_flags; -#line 1556 "reflect.h2" +#line 1547 "reflect.h2" class regex_token; -#line 1582 "reflect.h2" +#line 1573 "reflect.h2" class regex_token_check; -#line 1601 "reflect.h2" +#line 1592 "reflect.h2" class regex_token_code; -#line 1620 "reflect.h2" +#line 1611 "reflect.h2" class regex_token_empty; -#line 1636 "reflect.h2" +#line 1627 "reflect.h2" class regex_token_list; -#line 1675 "reflect.h2" +#line 1666 "reflect.h2" class parse_context_group_state; -#line 1736 "reflect.h2" +#line 1727 "reflect.h2" class parse_context_branch_reset_state; -#line 1779 "reflect.h2" +#line 1770 "reflect.h2" class parse_context; -#line 2177 "reflect.h2" +#line 2168 "reflect.h2" class generation_function_context; -#line 2195 "reflect.h2" +#line 2186 "reflect.h2" class generation_context; -#line 2393 "reflect.h2" +#line 2384 "reflect.h2" class alternative_token; -#line 2408 "reflect.h2" +#line 2399 "reflect.h2" class alternative_token_gen; -#line 2460 "reflect.h2" +#line 2451 "reflect.h2" class any_token; -#line 2478 "reflect.h2" +#line 2469 "reflect.h2" class char_token; -#line 2581 "reflect.h2" +#line 2572 "reflect.h2" class class_token; -#line 2796 "reflect.h2" +#line 2787 "reflect.h2" class group_ref_token; -#line 2927 "reflect.h2" +#line 2918 "reflect.h2" class group_token; -#line 3214 "reflect.h2" +#line 3205 "reflect.h2" class lookahead_token; -#line 3295 "reflect.h2" +#line 3286 "reflect.h2" class range_token; -#line 3443 "reflect.h2" +#line 3434 "reflect.h2" class special_range_token; -#line 3510 "reflect.h2" +#line 3501 "reflect.h2" template class regex_generator; #line 3751 "reflect.h2" @@ -441,24 +441,24 @@ struct query_declared_value_set_functions_ret { bool out_this_in_that; bool out_ #line 565 "reflect.h2" public: [[nodiscard]] auto query_declared_value_set_functions() const& -> query_declared_value_set_functions_ret; -#line 580 "reflect.h2" +#line 581 "reflect.h2" public: auto add_member(cpp2::impl::in source) & -> void; -#line 594 "reflect.h2" +#line 595 "reflect.h2" public: auto remove_marked_members() & -> void; public: auto remove_all_members() & -> void; public: auto disable_member_function_generation() & -> void; public: type_declaration(type_declaration const& that); -#line 598 "reflect.h2" +#line 599 "reflect.h2" }; -#line 604 "reflect.h2" +#line 605 "reflect.h2" class alias_declaration : public declaration { -#line 608 "reflect.h2" +#line 609 "reflect.h2" public: explicit alias_declaration( declaration_node* n_, @@ -467,62 +467,62 @@ class alias_declaration public: alias_declaration(alias_declaration const& that); -#line 617 "reflect.h2" +#line 618 "reflect.h2" }; -#line 632 "reflect.h2" +#line 633 "reflect.h2" auto add_virtual_destructor(meta::type_declaration& t) -> void; -#line 650 "reflect.h2" +#line 651 "reflect.h2" auto interface(meta::type_declaration& t) -> void; -#line 696 "reflect.h2" +#line 697 "reflect.h2" auto polymorphic_base(meta::type_declaration& t) -> void; -#line 741 "reflect.h2" +#line 742 "reflect.h2" auto ordered_impl( meta::type_declaration& t, cpp2::impl::in ordering ) -> void; -#line 770 "reflect.h2" +#line 771 "reflect.h2" auto ordered(meta::type_declaration& t) -> void; -#line 778 "reflect.h2" +#line 779 "reflect.h2" auto weakly_ordered(meta::type_declaration& t) -> void; -#line 786 "reflect.h2" +#line 787 "reflect.h2" auto partially_ordered(meta::type_declaration& t) -> void; -#line 808 "reflect.h2" +#line 809 "reflect.h2" auto copyable(meta::type_declaration& t) -> void; -#line 842 "reflect.h2" +#line 843 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void; -#line 870 "reflect.h2" +#line 871 "reflect.h2" auto value(meta::type_declaration& t) -> void; -#line 876 "reflect.h2" +#line 877 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void; -#line 882 "reflect.h2" +#line 883 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void; -#line 911 "reflect.h2" +#line 912 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void; -#line 953 "reflect.h2" +#line 949 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void; -#line 1022 "reflect.h2" +#line 1013 "reflect.h2" class value_member_info { public: std::string name; public: std::string type; public: std::string value; public: value_member_info(auto const& name_, auto const& type_, auto const& value_); -#line 1026 "reflect.h2" +#line 1017 "reflect.h2" }; auto basic_enum( @@ -531,22 +531,22 @@ auto basic_enum( cpp2::impl::in bitwise ) -> void; -#line 1292 "reflect.h2" +#line 1283 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void; -#line 1319 "reflect.h2" +#line 1310 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void; -#line 1365 "reflect.h2" +#line 1356 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void; -#line 1516 "reflect.h2" +#line 1507 "reflect.h2" auto print(cpp2::impl::in t) -> void; -#line 1536 "reflect.h2" +#line 1527 "reflect.h2" using error_func = std::function x)>; -#line 1540 "reflect.h2" +#line 1531 "reflect.h2" class expression_flags { private: cpp2::u8 _value; private: constexpr expression_flags(cpp2::impl::in _val); @@ -581,20 +581,20 @@ public: [[nodiscard]] auto to_code() const& -> std::string; public: [[nodiscard]] static auto from_string(cpp2::impl::in s) -> expression_flags; public: [[nodiscard]] static auto from_code(cpp2::impl::in s) -> expression_flags; -#line 1548 "reflect.h2" +#line 1539 "reflect.h2" }; -#line 1556 "reflect.h2" +#line 1547 "reflect.h2" class regex_token { public: std::string string_rep; public: explicit regex_token(cpp2::impl::in str); -#line 1564 "reflect.h2" +#line 1555 "reflect.h2" public: explicit regex_token(); -#line 1569 "reflect.h2" +#line 1560 "reflect.h2" public: virtual auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void = 0; public: virtual auto add_groups([[maybe_unused]] std::set& unnamed_param_2) const -> void; @@ -605,24 +605,24 @@ class regex_token public: regex_token(regex_token const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(regex_token const&) -> void = delete; -#line 1574 "reflect.h2" +#line 1565 "reflect.h2" }; using token_ptr = std::shared_ptr; using token_vec = std::vector; -#line 1580 "reflect.h2" +#line 1571 "reflect.h2" // Adds a check in code generation. // class regex_token_check : public regex_token { -#line 1586 "reflect.h2" +#line 1577 "reflect.h2" private: std::string check; public: explicit regex_token_check(cpp2::impl::in str, cpp2::impl::in check_); -#line 1593 "reflect.h2" +#line 1584 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~regex_token_check() noexcept; @@ -630,21 +630,21 @@ class regex_token_check public: auto operator=(regex_token_check const&) -> void = delete; -#line 1596 "reflect.h2" +#line 1587 "reflect.h2" }; -#line 1599 "reflect.h2" +#line 1590 "reflect.h2" // Adds code in code generation. // class regex_token_code : public regex_token { -#line 1605 "reflect.h2" +#line 1596 "reflect.h2" private: std::string code; public: explicit regex_token_code(cpp2::impl::in str, cpp2::impl::in code_); -#line 1612 "reflect.h2" +#line 1603 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~regex_token_code() noexcept; @@ -652,19 +652,19 @@ class regex_token_code public: auto operator=(regex_token_code const&) -> void = delete; -#line 1615 "reflect.h2" +#line 1606 "reflect.h2" }; -#line 1618 "reflect.h2" +#line 1609 "reflect.h2" // Token that does not influence the matching. E.g. comment. // class regex_token_empty : public regex_token { -#line 1624 "reflect.h2" +#line 1615 "reflect.h2" public: explicit regex_token_empty(cpp2::impl::in str); -#line 1628 "reflect.h2" +#line 1619 "reflect.h2" public: auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void override; public: virtual ~regex_token_empty() noexcept; @@ -672,27 +672,27 @@ class regex_token_empty public: auto operator=(regex_token_empty const&) -> void = delete; -#line 1631 "reflect.h2" +#line 1622 "reflect.h2" }; -#line 1634 "reflect.h2" +#line 1625 "reflect.h2" // Represents a list of regex tokens as one token. // class regex_token_list : public regex_token { -#line 1640 "reflect.h2" +#line 1631 "reflect.h2" public: token_vec tokens; public: explicit regex_token_list(cpp2::impl::in t); -#line 1647 "reflect.h2" +#line 1638 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 1653 "reflect.h2" +#line 1644 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 1659 "reflect.h2" +#line 1650 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in vec) -> std::string; public: virtual ~regex_token_list() noexcept; @@ -700,10 +700,10 @@ class regex_token_list public: auto operator=(regex_token_list const&) -> void = delete; -#line 1666 "reflect.h2" +#line 1657 "reflect.h2" }; -#line 1669 "reflect.h2" +#line 1660 "reflect.h2" // // Parse and generation context. // @@ -719,33 +719,33 @@ class parse_context_group_state // Start a new alternative. public: auto next_alternative() & -> void; -#line 1689 "reflect.h2" - // Swap this state with the other one. +#line 1680 "reflect.h2" + // Swap this state with the other one. NOLINTNEXTLINE(performance-noexcept-swap) public: auto swap(parse_context_group_state& t) & -> void; -#line 1696 "reflect.h2" +#line 1687 "reflect.h2" // Convert this state into a regex token. public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 1708 "reflect.h2" +#line 1699 "reflect.h2" // Add a token to the current matcher list. public: auto add(cpp2::impl::in token) & -> void; -#line 1713 "reflect.h2" +#line 1704 "reflect.h2" // True if current matcher list is empty. public: [[nodiscard]] auto empty() const& -> bool; -#line 1717 "reflect.h2" +#line 1708 "reflect.h2" // Apply optimizations to the matcher list. public: static auto post_process_list(token_vec& list) -> void; public: parse_context_group_state(auto const& cur_match_list_, auto const& alternate_match_lists_, auto const& modifiers_); public: parse_context_group_state(); -#line 1731 "reflect.h2" +#line 1722 "reflect.h2" }; -#line 1734 "reflect.h2" +#line 1725 "reflect.h2" // State for the branch reset. Takes care of the group numbering. See '(|)'. // class parse_context_branch_reset_state @@ -758,25 +758,25 @@ class parse_context_branch_reset_state // Next group identifier. public: [[nodiscard]] auto next() & -> int; -#line 1752 "reflect.h2" +#line 1743 "reflect.h2" // Set next group identifier. public: auto set_next(cpp2::impl::in g) & -> void; -#line 1758 "reflect.h2" +#line 1749 "reflect.h2" // Start a new alternative branch. public: auto next_alternative() & -> void; -#line 1765 "reflect.h2" +#line 1756 "reflect.h2" // Initialize for a branch reset group. public: auto set_active_reset(cpp2::impl::in restart) & -> void; public: parse_context_branch_reset_state(auto const& is_active_, auto const& cur_group_, auto const& max_group_, auto const& from_); public: parse_context_branch_reset_state(); -#line 1772 "reflect.h2" +#line 1763 "reflect.h2" }; -#line 1775 "reflect.h2" +#line 1766 "reflect.h2" // Context during parsing of the regular expressions. // // Keeps track of the distributed group identifiers, current parsed group and branch resets. @@ -790,7 +790,7 @@ class parse_context private: parse_context_group_state cur_group_state {}; private: parse_context_branch_reset_state cur_branch_reset_state {}; -#line 1789 "reflect.h2" +#line 1780 "reflect.h2" public: std::map named_groups {}; private: error_func error_out; // TODO: Declaring std::function fails for cpp2. @@ -798,64 +798,64 @@ class parse_context public: explicit parse_context(cpp2::impl::in r, auto const& e); -#line 1800 "reflect.h2" +#line 1791 "reflect.h2" // State management functions // // Returned group state needs to be stored and provided in `end_group`. public: [[nodiscard]] auto start_group() & -> parse_context_group_state; -#line 1813 "reflect.h2" +#line 1804 "reflect.h2" // `old_state` argument needs to be from start group. public: [[nodiscard]] auto end_group(cpp2::impl::in old_state) & -> token_ptr; -#line 1821 "reflect.h2" +#line 1812 "reflect.h2" public: [[nodiscard]] auto get_modifiers() const& -> expression_flags; -#line 1825 "reflect.h2" +#line 1816 "reflect.h2" public: auto set_modifiers(cpp2::impl::in mod) & -> void; -#line 1829 "reflect.h2" +#line 1820 "reflect.h2" // Branch reset management functions // public: [[nodiscard]] auto branch_reset_new_state() & -> parse_context_branch_reset_state; -#line 1841 "reflect.h2" +#line 1832 "reflect.h2" public: auto branch_reset_restore_state(cpp2::impl::in old_state) & -> void; -#line 1848 "reflect.h2" +#line 1839 "reflect.h2" public: auto next_alternative() & -> void; -#line 1854 "reflect.h2" +#line 1845 "reflect.h2" // Regex token management // public: auto add_token(cpp2::impl::in token) & -> void; -#line 1860 "reflect.h2" +#line 1851 "reflect.h2" public: [[nodiscard]] auto has_token() const& -> bool; -#line 1864 "reflect.h2" +#line 1855 "reflect.h2" public: [[nodiscard]] auto pop_token() & -> token_ptr; -#line 1875 "reflect.h2" +#line 1866 "reflect.h2" public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 1879 "reflect.h2" +#line 1870 "reflect.h2" // Group management // public: [[nodiscard]] auto get_cur_group() const& -> int; -#line 1885 "reflect.h2" +#line 1876 "reflect.h2" public: [[nodiscard]] auto next_group() & -> int; -#line 1889 "reflect.h2" +#line 1880 "reflect.h2" public: auto set_named_group(cpp2::impl::in name, cpp2::impl::in id) & -> void; -#line 1896 "reflect.h2" +#line 1887 "reflect.h2" public: [[nodiscard]] auto get_named_group(cpp2::impl::in name) const& -> int; -#line 1907 "reflect.h2" +#line 1898 "reflect.h2" // Position management functions // public: [[nodiscard]] auto current() const& -> char; @@ -863,51 +863,51 @@ class parse_context // Get the next token in the regex, skipping spaces according to the parameters. See `x` and `xx` modifiers. private: [[nodiscard]] auto get_next_position(cpp2::impl::in in_class, cpp2::impl::in no_skip) const& -> size_t; -#line 1951 "reflect.h2" +#line 1942 "reflect.h2" // Return true if next token is available. private: [[nodiscard]] auto next_impl(cpp2::impl::in in_class, cpp2::impl::in no_skip) & -> bool; -#line 1963 "reflect.h2" +#line 1954 "reflect.h2" public: [[nodiscard]] auto next() & -> auto; public: [[nodiscard]] auto next_in_class() & -> auto; public: [[nodiscard]] auto next_no_skip() & -> auto; public: [[nodiscard]] auto next_n(cpp2::impl::in n) & -> bool; -#line 1976 "reflect.h2" +#line 1967 "reflect.h2" public: [[nodiscard]] auto has_next() const& -> bool; private: [[nodiscard]] auto grab_until_impl(cpp2::impl::in e, cpp2::impl::out r, cpp2::impl::in any) & -> bool; -#line 1999 "reflect.h2" +#line 1990 "reflect.h2" public: [[nodiscard]] auto grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> auto; public: [[nodiscard]] auto grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> auto; public: [[nodiscard]] auto grab_until_one_of(cpp2::impl::in e, cpp2::impl::out r) & -> auto; public: [[nodiscard]] auto grab_n(cpp2::impl::in n, cpp2::impl::out r) & -> bool; -#line 2016 "reflect.h2" +#line 2007 "reflect.h2" public: [[nodiscard]] auto grab_number() & -> std::string; -#line 2037 "reflect.h2" +#line 2028 "reflect.h2" private: [[nodiscard]] auto peek_impl(cpp2::impl::in in_class) const& -> char; -#line 2047 "reflect.h2" +#line 2038 "reflect.h2" public: [[nodiscard]] auto peek() const& -> auto; public: [[nodiscard]] auto peek_in_class() const& -> auto; -#line 2051 "reflect.h2" +#line 2042 "reflect.h2" // Parsing functions // public: [[nodiscard]] auto parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool; -#line 2107 "reflect.h2" +#line 2098 "reflect.h2" public: [[nodiscard]] auto parse_until(cpp2::impl::in term) & -> bool; -#line 2145 "reflect.h2" +#line 2136 "reflect.h2" public: [[nodiscard]] auto parse(cpp2::impl::in modifiers) & -> bool; -#line 2160 "reflect.h2" +#line 2151 "reflect.h2" // Misc functions public: [[nodiscard]] auto get_pos() const& -> auto; @@ -919,10 +919,10 @@ class parse_context public: auto operator=(parse_context const&) -> void = delete; -#line 2171 "reflect.h2" +#line 2162 "reflect.h2" }; -#line 2174 "reflect.h2" +#line 2165 "reflect.h2" // Context for one function generation. Generation of functions can be interleaved, // therefore we buffer the code for one function here. // @@ -932,16 +932,16 @@ class generation_function_context { public: auto add_tabs(cpp2::impl::in c) & -> void; -#line 2188 "reflect.h2" +#line 2179 "reflect.h2" public: auto remove_tabs(cpp2::impl::in c) & -> void; public: generation_function_context(auto const& code_, auto const& tabs_); public: generation_function_context(); -#line 2191 "reflect.h2" +#line 2182 "reflect.h2" }; -#line 2194 "reflect.h2" +#line 2185 "reflect.h2" // Context for generating the state machine. class generation_context { @@ -961,68 +961,68 @@ class generation_context // Add code line. public: auto add(cpp2::impl::in s) & -> void; -#line 2216 "reflect.h2" +#line 2207 "reflect.h2" // Add check for token. The check needs to be a function call that returns a boolean. public: auto add_check(cpp2::impl::in check) & -> void; -#line 2222 "reflect.h2" +#line 2213 "reflect.h2" // Add a stateful check. The check needs to return a `match_return`. public: auto add_statefull(cpp2::impl::in next_func, cpp2::impl::in check) & -> void; -#line 2231 "reflect.h2" +#line 2222 "reflect.h2" protected: auto start_func_named(cpp2::impl::in name) & -> void; -#line 2242 "reflect.h2" +#line 2233 "reflect.h2" protected: [[nodiscard]] auto start_func() & -> std::string; -#line 2249 "reflect.h2" +#line 2240 "reflect.h2" protected: auto end_func_statefull(cpp2::impl::in s) & -> void; -#line 2268 "reflect.h2" +#line 2259 "reflect.h2" // Generate the function for a token. public: [[nodiscard]] auto generate_func(cpp2::impl::in token) & -> std::string; -#line 2278 "reflect.h2" +#line 2269 "reflect.h2" // Generate the reset for a list of group identifiers. public: [[nodiscard]] auto generate_reset(cpp2::impl::in> groups) & -> std::string; -#line 2301 "reflect.h2" +#line 2292 "reflect.h2" // Name generation // protected: [[nodiscard]] auto gen_func_name() & -> std::string; -#line 2309 "reflect.h2" +#line 2300 "reflect.h2" public: [[nodiscard]] auto next_func_name() & -> std::string; -#line 2313 "reflect.h2" +#line 2304 "reflect.h2" protected: [[nodiscard]] auto gen_reset_func_name() & -> std::string; -#line 2319 "reflect.h2" +#line 2310 "reflect.h2" public: [[nodiscard]] auto gen_temp() & -> std::string; -#line 2325 "reflect.h2" +#line 2316 "reflect.h2" // Context management // public: [[nodiscard]] auto new_context() & -> generation_function_context*; -#line 2335 "reflect.h2" +#line 2326 "reflect.h2" public: auto finish_context() & -> void; -#line 2343 "reflect.h2" +#line 2334 "reflect.h2" // Misc functions // private: [[nodiscard]] auto get_current() & -> generation_function_context*; -#line 2349 "reflect.h2" +#line 2340 "reflect.h2" private: [[nodiscard]] auto get_base() & -> generation_function_context*; -#line 2353 "reflect.h2" +#line 2344 "reflect.h2" public: [[nodiscard]] auto get_entry_func() const& -> std::string; -#line 2357 "reflect.h2" +#line 2348 "reflect.h2" public: [[nodiscard]] auto create_named_group_lookup(cpp2::impl::in> named_groups) const& -> std::string; -#line 2381 "reflect.h2" +#line 2372 "reflect.h2" // Run the generation for the token. public: [[nodiscard]] auto run(cpp2::impl::in token) & -> std::string; public: generation_context() = default; @@ -1030,7 +1030,7 @@ class generation_context public: auto operator=(generation_context const&) -> void = delete; -#line 2387 "reflect.h2" +#line 2378 "reflect.h2" }; // Regex syntax: | Example: ab|ba @@ -1050,24 +1050,24 @@ class alternative_token public: auto operator=(alternative_token const&) -> void = delete; -#line 2406 "reflect.h2" +#line 2397 "reflect.h2" }; class alternative_token_gen : public regex_token { -#line 2412 "reflect.h2" +#line 2403 "reflect.h2" private: token_vec alternatives; public: explicit alternative_token_gen(cpp2::impl::in a); -#line 2419 "reflect.h2" +#line 2410 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2436 "reflect.h2" +#line 2427 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 2443 "reflect.h2" +#line 2434 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in a) -> std::string; public: virtual ~alternative_token_gen() noexcept; @@ -1075,19 +1075,19 @@ class alternative_token_gen public: auto operator=(alternative_token_gen const&) -> void = delete; -#line 2455 "reflect.h2" +#line 2446 "reflect.h2" }; -#line 2458 "reflect.h2" +#line 2449 "reflect.h2" // Regex syntax: . // class any_token : public regex_token_check { -#line 2464 "reflect.h2" +#line 2455 "reflect.h2" public: explicit any_token(cpp2::impl::in single_line); -#line 2468 "reflect.h2" +#line 2459 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~any_token() noexcept; @@ -1095,37 +1095,37 @@ class any_token public: auto operator=(any_token const&) -> void = delete; -#line 2473 "reflect.h2" +#line 2464 "reflect.h2" }; -#line 2476 "reflect.h2" +#line 2467 "reflect.h2" // Regex syntax: a // class char_token : public regex_token { -#line 2482 "reflect.h2" +#line 2473 "reflect.h2" private: std::string token; private: bool ignore_case; public: explicit char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_); -#line 2491 "reflect.h2" +#line 2482 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2495 "reflect.h2" +#line 2486 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2518 "reflect.h2" +#line 2509 "reflect.h2" public: auto gen_case_insensitive(cpp2::impl::in lower, cpp2::impl::in upper, generation_context& ctx) const& -> void; -#line 2539 "reflect.h2" +#line 2530 "reflect.h2" public: auto gen_case_sensitive(generation_context& ctx) const& -> void; -#line 2557 "reflect.h2" +#line 2548 "reflect.h2" public: [[nodiscard]] auto add_escapes(std::string str) const& -> std::string; -#line 2572 "reflect.h2" +#line 2563 "reflect.h2" public: auto append(char_token const& that) & -> void; public: virtual ~char_token() noexcept; @@ -1133,30 +1133,30 @@ class char_token public: auto operator=(char_token const&) -> void = delete; -#line 2576 "reflect.h2" +#line 2567 "reflect.h2" }; -#line 2579 "reflect.h2" +#line 2570 "reflect.h2" // Regex syntax: [] Example: [abcx-y[:digits:]] // class class_token : public regex_token { -#line 2585 "reflect.h2" +#line 2576 "reflect.h2" private: bool negate; private: bool case_insensitive; private: std::string class_str; public: explicit class_token(cpp2::impl::in negate_, cpp2::impl::in case_insensitive_, cpp2::impl::in class_str_, cpp2::impl::in str); -#line 2597 "reflect.h2" +#line 2588 "reflect.h2" // TODO: Rework class generation: Generate check functions for classes. public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2723 "reflect.h2" +#line 2714 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2728 "reflect.h2" +#line 2719 "reflect.h2" private: [[nodiscard]] static auto create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string; public: virtual ~class_token() noexcept; @@ -1164,20 +1164,20 @@ class class_token public: auto operator=(class_token const&) -> void = delete; -#line 2735 "reflect.h2" +#line 2726 "reflect.h2" }; -#line 2738 "reflect.h2" +#line 2729 "reflect.h2" // Regex syntax: \a or \n or \[ // [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr; -#line 2779 "reflect.h2" +#line 2770 "reflect.h2" // Regex syntax: \K Example: ab\Kcd // [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr; -#line 2790 "reflect.h2" +#line 2781 "reflect.h2" // Regex syntax: \ Example: \1 // \g{name_or_number} // \k{name_or_number} @@ -1187,16 +1187,16 @@ class class_token class group_ref_token : public regex_token { -#line 2800 "reflect.h2" +#line 2791 "reflect.h2" private: int id; private: bool case_insensitive; public: explicit group_ref_token(cpp2::impl::in id_, cpp2::impl::in case_insensitive_, cpp2::impl::in str); -#line 2810 "reflect.h2" +#line 2801 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2911 "reflect.h2" +#line 2902 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~group_ref_token() noexcept; @@ -1204,10 +1204,10 @@ class group_ref_token public: auto operator=(group_ref_token const&) -> void = delete; -#line 2914 "reflect.h2" +#line 2905 "reflect.h2" }; -#line 2917 "reflect.h2" +#line 2908 "reflect.h2" // Regex syntax: () Example: (abc) // (?:) (?i:abc) @@ -1221,22 +1221,22 @@ class group_ref_token class group_token : public regex_token { -#line 2931 "reflect.h2" +#line 2922 "reflect.h2" private: int number {-1}; private: token_ptr inner {nullptr}; public: [[nodiscard]] static auto parse_lookahead(parse_context& ctx, cpp2::impl::in syntax, cpp2::impl::in positive) -> token_ptr; -#line 2948 "reflect.h2" +#line 2939 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 3085 "reflect.h2" +#line 3076 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in name, cpp2::impl::in name_brackets, cpp2::impl::in has_modifier, cpp2::impl::in modifiers, cpp2::impl::in inner_) -> std::string; -#line 3103 "reflect.h2" +#line 3094 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3123 "reflect.h2" +#line 3114 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~group_token() noexcept; @@ -1245,25 +1245,25 @@ class group_token public: auto operator=(group_token const&) -> void = delete; -#line 3130 "reflect.h2" +#line 3121 "reflect.h2" }; -#line 3133 "reflect.h2" +#line 3124 "reflect.h2" // Regex syntax: \x or \x{} Example: \x{62} // [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr; -#line 3174 "reflect.h2" +#line 3165 "reflect.h2" // Regex syntax: $ Example: aa$ // [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr; -#line 3194 "reflect.h2" +#line 3185 "reflect.h2" // Regex syntax: ^ Example: ^aa // [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr; -#line 3210 "reflect.h2" +#line 3201 "reflect.h2" // Regex syntax: (?=) or (?!) or (*pla), etc. Example: (?=AA) // // Parsed in group_token. @@ -1271,16 +1271,16 @@ class group_token class lookahead_token : public regex_token { -#line 3218 "reflect.h2" +#line 3209 "reflect.h2" protected: bool positive; public: token_ptr inner {nullptr}; public: explicit lookahead_token(cpp2::impl::in positive_); -#line 3225 "reflect.h2" +#line 3216 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3231 "reflect.h2" +#line 3222 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~lookahead_token() noexcept; @@ -1288,26 +1288,26 @@ class lookahead_token public: auto operator=(lookahead_token const&) -> void = delete; -#line 3234 "reflect.h2" +#line 3225 "reflect.h2" }; -#line 3237 "reflect.h2" +#line 3228 "reflect.h2" // Named character classes // [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr; -#line 3265 "reflect.h2" +#line 3256 "reflect.h2" // Regex syntax: \o{} Example: \o{142} // [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr; -#line 3293 "reflect.h2" +#line 3284 "reflect.h2" // Regex syntax: {min, max} Example: a{2,4} // class range_token : public regex_token { -#line 3299 "reflect.h2" +#line 3290 "reflect.h2" protected: int min_count {-1}; protected: int max_count {-1}; protected: int kind {range_flags::greedy}; @@ -1317,19 +1317,19 @@ class range_token public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 3379 "reflect.h2" +#line 3370 "reflect.h2" public: auto parse_modifier(parse_context& ctx) & -> void; -#line 3391 "reflect.h2" +#line 3382 "reflect.h2" public: [[nodiscard]] auto gen_mod_string() const& -> std::string; -#line 3404 "reflect.h2" +#line 3395 "reflect.h2" public: [[nodiscard]] auto gen_range_string() const& -> std::string; -#line 3423 "reflect.h2" +#line 3414 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3434 "reflect.h2" +#line 3425 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~range_token() noexcept; @@ -1337,16 +1337,16 @@ class range_token public: auto operator=(range_token const&) -> void = delete; -#line 3438 "reflect.h2" +#line 3429 "reflect.h2" }; -#line 3441 "reflect.h2" +#line 3432 "reflect.h2" // Regex syntax: *, +, or ? Example: aa* // class special_range_token : public range_token { -#line 3447 "reflect.h2" +#line 3438 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~special_range_token() noexcept; @@ -1355,17 +1355,17 @@ class special_range_token public: auto operator=(special_range_token const&) -> void = delete; -#line 3477 "reflect.h2" +#line 3468 "reflect.h2" }; -#line 3480 "reflect.h2" +#line 3471 "reflect.h2" // Regex syntax: \b or \B Example: \bword\b // // Matches the start end end of word boundaries. // [[nodiscard]] auto word_boundary_token_parse(parse_context& ctx) -> token_ptr; -#line 3502 "reflect.h2" +#line 3493 "reflect.h2" //----------------------------------------------------------------------- // // Parser for regular expression. @@ -1386,24 +1386,24 @@ template class regex_generator public: explicit regex_generator(cpp2::impl::in r, Error_out const& e); -#line 3525 "reflect.h2" +#line 3516 "reflect.h2" public: [[nodiscard]] auto parse() & -> std::string; -#line 3560 "reflect.h2" +#line 3551 "reflect.h2" private: auto extract_modifiers() & -> void; public: regex_generator(regex_generator const&) = delete; /* No 'that' constructor, suppress copy */ public: auto operator=(regex_generator const&) -> void = delete; -#line 3574 "reflect.h2" +#line 3565 "reflect.h2" }; template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string; -#line 3586 "reflect.h2" +#line 3577 "reflect.h2" auto regex_gen(meta::type_declaration& t) -> void; -#line 3641 "reflect.h2" +#line 3632 "reflect.h2" //----------------------------------------------------------------------- // // apply_metafunctions @@ -2116,9 +2116,10 @@ declaration::declaration(declaration const& that) out_this_move_that.construct(declared.out_this_move_that != nullptr); inout_this_in_that.construct(declared.inout_this_in_that != nullptr); inout_this_move_that.construct(cpp2::move(declared).inout_this_move_that != nullptr); - return { std::move(out_this_in_that.value()), std::move(out_this_move_that.value()), std::move(inout_this_in_that.value()), std::move(inout_this_move_that.value()) }; } + return { std::move(out_this_in_that.value()), std::move(out_this_move_that.value()), std::move(inout_this_in_that.value()), std::move(inout_this_move_that.value()) }; // NOLINT(performance-move-const-arg) + } -#line 580 "reflect.h2" +#line 581 "reflect.h2" auto type_declaration::add_member(cpp2::impl::in source) & -> void { auto decl {parse_statement(source)}; @@ -2133,30 +2134,30 @@ declaration::declaration(declaration const& that) std::string("unexpected error while attempting to add member:\n") + source); } -#line 594 "reflect.h2" - auto type_declaration::remove_marked_members() & -> void { CPP2_UFCS(type_remove_marked_members)((*cpp2::impl::assert_not_null(n))); } #line 595 "reflect.h2" + auto type_declaration::remove_marked_members() & -> void { CPP2_UFCS(type_remove_marked_members)((*cpp2::impl::assert_not_null(n))); } +#line 596 "reflect.h2" auto type_declaration::remove_all_members() & -> void { CPP2_UFCS(type_remove_all_members)((*cpp2::impl::assert_not_null(n))); } -#line 597 "reflect.h2" +#line 598 "reflect.h2" auto type_declaration::disable_member_function_generation() & -> void { CPP2_UFCS(type_disable_member_function_generation)((*cpp2::impl::assert_not_null(n))); } type_declaration::type_declaration(type_declaration const& that) : declaration{ static_cast(that) }{} -#line 601 "reflect.h2" +#line 602 "reflect.h2" //----------------------------------------------------------------------- // Alias declarations // -#line 608 "reflect.h2" +#line 609 "reflect.h2" alias_declaration::alias_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 613 "reflect.h2" +#line 614 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_alias)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } @@ -2165,7 +2166,7 @@ declaration::declaration(declaration const& that) alias_declaration::alias_declaration(alias_declaration const& that) : declaration{ static_cast(that) }{} -#line 620 "reflect.h2" +#line 621 "reflect.h2" //----------------------------------------------------------------------- // // Metafunctions - these are hardwired for now until we get to the @@ -2178,13 +2179,13 @@ declaration::declaration(declaration const& that) // Some common metafunction helpers (metafunctions are just functions, // so they can be factored as usual) // -#line 632 "reflect.h2" +#line 633 "reflect.h2" auto add_virtual_destructor(meta::type_declaration& t) -> void { CPP2_UFCS(add_member)(t, "operator=: (virtual move this) = { }"); } -#line 638 "reflect.h2" +#line 639 "reflect.h2" //----------------------------------------------------------------------- // // "... an abstract base class defines an interface ..." @@ -2197,7 +2198,7 @@ auto add_virtual_destructor(meta::type_declaration& t) -> void // // an abstract base class having only pure virtual functions // -#line 650 "reflect.h2" +#line 651 "reflect.h2" auto interface(meta::type_declaration& t) -> void { auto has_dtor {false}; @@ -2224,7 +2225,7 @@ auto interface(meta::type_declaration& t) -> void } } -#line 677 "reflect.h2" +#line 678 "reflect.h2" //----------------------------------------------------------------------- // // "C.35: A base class destructor should be either public and @@ -2244,7 +2245,7 @@ auto interface(meta::type_declaration& t) -> void // // Unlike an interface, it can have nonpublic and nonvirtual functions. // -#line 696 "reflect.h2" +#line 697 "reflect.h2" auto polymorphic_base(meta::type_declaration& t) -> void { auto has_dtor {false}; @@ -2269,7 +2270,7 @@ auto polymorphic_base(meta::type_declaration& t) -> void } } -#line 721 "reflect.h2" +#line 722 "reflect.h2" //----------------------------------------------------------------------- // // "... A totally ordered type ... requires operator<=> that @@ -2290,7 +2291,7 @@ auto polymorphic_base(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // -#line 741 "reflect.h2" +#line 742 "reflect.h2" auto ordered_impl( meta::type_declaration& t, cpp2::impl::in ordering// must be "strong_ordering" etc. @@ -2320,7 +2321,7 @@ auto ordered_impl( // // Note: the ordering that should be encouraged as default gets the nice name // -#line 770 "reflect.h2" +#line 771 "reflect.h2" auto ordered(meta::type_declaration& t) -> void { ordered_impl(t, "strong_ordering"); @@ -2329,7 +2330,7 @@ auto ordered(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // weakly_ordered - a weakly ordered type // -#line 778 "reflect.h2" +#line 779 "reflect.h2" auto weakly_ordered(meta::type_declaration& t) -> void { ordered_impl(t, "weak_ordering"); @@ -2338,13 +2339,13 @@ auto weakly_ordered(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // partially_ordered - a partially ordered type // -#line 786 "reflect.h2" +#line 787 "reflect.h2" auto partially_ordered(meta::type_declaration& t) -> void { ordered_impl(t, "partial_ordering"); } -#line 792 "reflect.h2" +#line 793 "reflect.h2" //----------------------------------------------------------------------- // // "A value is ... a regular type. It must have all public @@ -2361,7 +2362,7 @@ auto partially_ordered(meta::type_declaration& t) -> void // // A type with (copy and move) x (construction and assignment) // -#line 808 "reflect.h2" +#line 809 "reflect.h2" auto copyable(meta::type_declaration& t) -> void { // If the user explicitly wrote any of the copy/move functions, @@ -2396,7 +2397,7 @@ auto copyable(meta::type_declaration& t) -> void // A regular type: copyable, plus has public default construction // and no protected or virtual functions // -#line 842 "reflect.h2" +#line 843 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void { CPP2_UFCS(copyable)(t); @@ -2425,28 +2426,28 @@ auto basic_value(meta::type_declaration& t) -> void // // Note: the ordering that should be encouraged as default gets the nice name // -#line 870 "reflect.h2" +#line 871 "reflect.h2" auto value(meta::type_declaration& t) -> void { CPP2_UFCS(ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 876 "reflect.h2" +#line 877 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(weakly_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 882 "reflect.h2" +#line 883 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(partially_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 889 "reflect.h2" +#line 890 "reflect.h2" //----------------------------------------------------------------------- // // C.20: If you can avoid defining default operations, do @@ -2469,7 +2470,7 @@ auto partially_ordered_value(meta::type_declaration& t) -> void // // a type without declared copy/move/destructor functions // -#line 911 "reflect.h2" +#line 912 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void { for ( auto& mf : CPP2_UFCS(get_member_functions)(t) ) @@ -2506,13 +2507,8 @@ auto cpp1_rule_of_zero(meta::type_declaration& t) -> void // a type with only public bases, objects, and functions, // no virtual functions, and no user-defined constructors // (i.e., no invariants) or assignment or destructors. -// -// For GCC 10 compatibility, optionally allow passing struct -// that generates a memberwise constructor with a generic deduced -// parameters instead of concrete forwarding parameters (mainly used -// for cppfront internal use, so cppfront builds under GCC 10) // -#line 953 "reflect.h2" +#line 949 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void { std::string ctor_params {}; @@ -2534,12 +2530,7 @@ auto cpp2_struct(meta::type_declaration& t) -> void else {if (CPP2_UFCS(is_object)(m)) { auto mo {CPP2_UFCS(as_object)(m)}; if (CPP2_UFCS(name)(mo) != "this") { - if (CPP2_UFCS(get_argument)(t, 0) == "noforward") { - ctor_params += "" + cpp2::to_string(CPP2_UFCS(name)(mo)) + "_, "; - } - else { - ctor_params += "forward " + cpp2::to_string(CPP2_UFCS(name)(mo)) + "_ : " + cpp2::to_string(CPP2_UFCS(type)(mo)) + ", "; - } + ctor_params += "" + cpp2::to_string(CPP2_UFCS(name)(mo)) + "_, "; ctor_inits += "" + cpp2::to_string(CPP2_UFCS(name)(mo)) + " = " + cpp2::to_string(CPP2_UFCS(name)(mo)) + "_; "; } else { @@ -2569,7 +2560,7 @@ value_member_info::value_member_info(auto const& name_, auto const& type_, auto , type{ type_ } , value{ value_ }{} -#line 1005 "reflect.h2" +#line 996 "reflect.h2" //----------------------------------------------------------------------- // // "C enumerations constitute a curiously half-baked concept. ... @@ -2588,7 +2579,7 @@ value_member_info::value_member_info(auto const& name_, auto const& type_, auto // a type together with named constants that are its possible values // -#line 1028 "reflect.h2" +#line 1019 "reflect.h2" auto basic_enum( meta::type_declaration& t, auto const& nextval, @@ -2613,7 +2604,7 @@ auto basic_enum( { std::string value{"-1"}; -#line 1051 "reflect.h2" +#line 1042 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) if ( CPP2_UFCS(is_member_object)(m)) @@ -2655,7 +2646,7 @@ std::string value{"-1"}; } } -#line 1091 "reflect.h2" +#line 1082 "reflect.h2" if ((CPP2_UFCS(empty)(enumerators))) { CPP2_UFCS(error)(t, "an enumeration must contain at least one enumerator value"); return ; @@ -2706,7 +2697,7 @@ std::string value{"-1"}; } } -#line 1142 "reflect.h2" +#line 1133 "reflect.h2" // 2. Replace: Erase the contents and replace with modified contents // // Note that most values and functions are declared as '==' compile-time values, i.e. Cpp1 'constexpr' @@ -2756,7 +2747,7 @@ std::string to_string_impl{" to_string_impl: (this, prefix: std::string_view" // Provide 'to_string' and 'to_code' functions to print enumerator // name(s) as human-readable strings or as code expressions -#line 1189 "reflect.h2" +#line 1180 "reflect.h2" { if (bitwise) { to_string_impl += ", separator: std::string_view ) -> std::string = { \n" @@ -2797,7 +2788,7 @@ std::string to_string_impl{" to_string_impl: (this, prefix: std::string_view" } } -#line 1228 "reflect.h2" +#line 1219 "reflect.h2" if (bitwise) { CPP2_UFCS(add_member)(t, " to_string: (this) -> std::string = to_string_impl( \"\", \", \" );"); CPP2_UFCS(add_member)(t, " to_code : (this) -> std::string = to_string_impl( \"" + cpp2::to_string(CPP2_UFCS(name)(t)) + "::\", \" | \" );"); @@ -2811,7 +2802,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ // Provide a 'from_string' function to parse strings into enumerators -#line 1239 "reflect.h2" +#line 1230 "reflect.h2" { std::string_view prefix {""}; std::string_view combine_op {"return"}; @@ -2833,7 +2824,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ { std::string_view else_{""}; -#line 1259 "reflect.h2" +#line 1250 "reflect.h2" for ( auto const& e : cpp2::move(enumerators) ) { from_string += " " + cpp2::to_string(else_) + "if \"" + cpp2::to_string(e.name) + "\" == x { " + cpp2::to_string(combine_op) + " " + cpp2::to_string(e.name) + "; }\n"; @@ -2841,7 +2832,7 @@ std::string_view else_{""}; } } -#line 1265 "reflect.h2" +#line 1256 "reflect.h2" if (bitwise) { from_string += " else { break outer; }\n" " }\n" @@ -2857,11 +2848,11 @@ std::string_view else_{""}; } } -#line 1279 "reflect.h2" +#line 1270 "reflect.h2" CPP2_UFCS(add_member)(t, " from_code: (s: std::string_view) -> " + cpp2::to_string(CPP2_UFCS(name)(t)) + " = { str: std::string = s; return from_string( cpp2::string_util::replace_all(str, \"" + cpp2::to_string(CPP2_UFCS(name)(t)) + "::\", \"\" ) ); }"); } -#line 1283 "reflect.h2" +#line 1274 "reflect.h2" //----------------------------------------------------------------------- // // "An enum[...] is a totally ordered value type that stores a @@ -2871,12 +2862,12 @@ std::string_view else_{""}; // // -- P0707R4, section 3 // -#line 1292 "reflect.h2" +#line 1283 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with an incrementing value generator CPP2_UFCS(basic_enum)(t, - [](std::string& value, cpp2::impl::in specified_value) -> void{ + [](std::string& value, cpp2::impl::in specified_value) mutable -> void{ if (!(CPP2_UFCS(empty)(specified_value))) { value = specified_value; }else { @@ -2888,7 +2879,7 @@ auto cpp2_enum(meta::type_declaration& t) -> void ); } -#line 1309 "reflect.h2" +#line 1300 "reflect.h2" //----------------------------------------------------------------------- // // "flag_enum expresses an enumeration that stores values @@ -2899,12 +2890,12 @@ auto cpp2_enum(meta::type_declaration& t) -> void // // -- P0707R4, section 3 // -#line 1319 "reflect.h2" +#line 1310 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with a power-of-two value generator CPP2_UFCS(basic_enum)(t, - [](std::string& value, cpp2::impl::in specified_value) -> void{ + [](std::string& value, cpp2::impl::in specified_value) mutable -> void{ if (!(CPP2_UFCS(empty)(specified_value))) { value = specified_value; }else { @@ -2921,7 +2912,7 @@ auto flag_enum(meta::type_declaration& t) -> void ); } -#line 1341 "reflect.h2" +#line 1332 "reflect.h2" //----------------------------------------------------------------------- // // "As with void*, programmers should know that unions [...] are @@ -2946,7 +2937,7 @@ auto flag_enum(meta::type_declaration& t) -> void // a type that contains exactly one of a fixed set of values at a time // -#line 1365 "reflect.h2" +#line 1356 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void { std::vector alternatives {}; @@ -2955,7 +2946,7 @@ auto value{0}; // 1. Gather: All the user-written members, and find/compute the max size -#line 1372 "reflect.h2" +#line 1363 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) { do @@ -2985,7 +2976,7 @@ auto value{0}; } while (false); ++value; } } -#line 1400 "reflect.h2" +#line 1391 "reflect.h2" std::string discriminator_type {}; if (cpp2::impl::cmp_less(CPP2_UFCS(ssize)(alternatives),std::numeric_limits::max())) { discriminator_type = "i8"; @@ -3000,7 +2991,7 @@ auto value{0}; discriminator_type = "i64"; }}} -#line 1415 "reflect.h2" +#line 1406 "reflect.h2" // 2. Replace: Erase the contents and replace with modified contents CPP2_UFCS(remove_marked_members)(t); @@ -3009,7 +3000,7 @@ std::string storage{" _storage: cpp2::aligned_storage t) -> void { std::cout << CPP2_UFCS(print)(t) << "\n"; @@ -3214,7 +3205,7 @@ return none; [[nodiscard]] auto expression_flags::from_code(cpp2::impl::in s) -> expression_flags{ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::move(str), "expression_flags::", "")); } -#line 1522 "reflect.h2" +#line 1513 "reflect.h2" //----------------------------------------------------------------------- // // regex - creates regular expressions from members @@ -3230,11 +3221,11 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov // ``` // -#line 1538 "reflect.h2" +#line 1529 "reflect.h2" // Possible modifiers for a regular expression. // -#line 1542 "reflect.h2" +#line 1533 "reflect.h2" // mod: i // mod: m // mod: s @@ -3242,106 +3233,106 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov // mod: x // mod: xx -#line 1551 "reflect.h2" +#line 1542 "reflect.h2" // Tokens for regular expressions. // // Basic class for a regex token. // -#line 1560 "reflect.h2" +#line 1551 "reflect.h2" regex_token::regex_token(cpp2::impl::in str) : string_rep{ str }{ -#line 1562 "reflect.h2" +#line 1553 "reflect.h2" } -#line 1564 "reflect.h2" +#line 1555 "reflect.h2" regex_token::regex_token() : string_rep{ "" }{ -#line 1566 "reflect.h2" +#line 1557 "reflect.h2" } //parse: (inout ctx: parse_context) -> token_ptr; // Generate the matching code. -#line 1571 "reflect.h2" +#line 1562 "reflect.h2" auto regex_token::add_groups([[maybe_unused]] std::set& unnamed_param_2) const -> void{}// Adds all group indices to the set. -#line 1572 "reflect.h2" +#line 1563 "reflect.h2" [[nodiscard]] auto regex_token::to_string() const& -> std::string{return string_rep; }// Create a string representation. -#line 1573 "reflect.h2" +#line 1564 "reflect.h2" auto regex_token::set_string(cpp2::impl::in s) & -> void{string_rep = s; } regex_token::~regex_token() noexcept{}// Set the string representation. -#line 1588 "reflect.h2" +#line 1579 "reflect.h2" regex_token_check::regex_token_check(cpp2::impl::in str, cpp2::impl::in check_) : regex_token{ str } , check{ check_ }{ -#line 1591 "reflect.h2" +#line 1582 "reflect.h2" } -#line 1593 "reflect.h2" +#line 1584 "reflect.h2" auto regex_token_check::generate_code(generation_context& ctx) const -> void{ ctx.add_check(check + "(" + ctx.match_parameters() + ")"); } regex_token_check::~regex_token_check() noexcept{} -#line 1607 "reflect.h2" +#line 1598 "reflect.h2" regex_token_code::regex_token_code(cpp2::impl::in str, cpp2::impl::in code_) : regex_token{ str } , code{ code_ }{ -#line 1610 "reflect.h2" +#line 1601 "reflect.h2" } -#line 1612 "reflect.h2" +#line 1603 "reflect.h2" auto regex_token_code::generate_code(generation_context& ctx) const -> void{ ctx.add(code); } regex_token_code::~regex_token_code() noexcept{} -#line 1624 "reflect.h2" +#line 1615 "reflect.h2" regex_token_empty::regex_token_empty(cpp2::impl::in str) : regex_token{ str }{ -#line 1626 "reflect.h2" +#line 1617 "reflect.h2" } -#line 1628 "reflect.h2" +#line 1619 "reflect.h2" auto regex_token_empty::generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void{ // Nothing. } regex_token_empty::~regex_token_empty() noexcept{} -#line 1642 "reflect.h2" +#line 1633 "reflect.h2" regex_token_list::regex_token_list(cpp2::impl::in t) : regex_token{ gen_string(t) } , tokens{ t }{ -#line 1645 "reflect.h2" +#line 1636 "reflect.h2" } -#line 1647 "reflect.h2" +#line 1638 "reflect.h2" auto regex_token_list::generate_code(generation_context& ctx) const -> void{ for ( auto const& token : tokens ) { (*cpp2::impl::assert_not_null(token)).generate_code(ctx); } } -#line 1653 "reflect.h2" +#line 1644 "reflect.h2" auto regex_token_list::add_groups(std::set& groups) const -> void{ for ( auto const& token : tokens ) { (*cpp2::impl::assert_not_null(token)).add_groups(groups); } } -#line 1659 "reflect.h2" +#line 1650 "reflect.h2" [[nodiscard]] auto regex_token_list::gen_string(cpp2::impl::in vec) -> std::string{ std::string r {""}; for ( auto const& token : vec ) { @@ -3352,7 +3343,7 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov regex_token_list::~regex_token_list() noexcept{} -#line 1682 "reflect.h2" +#line 1673 "reflect.h2" auto parse_context_group_state::next_alternative() & -> void{ token_vec new_list {}; std::swap(new_list, cur_match_list); @@ -3360,14 +3351,14 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov static_cast(alternate_match_lists.insert(alternate_match_lists.end(), CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, cpp2::move(new_list)))); } -#line 1690 "reflect.h2" - auto parse_context_group_state::swap(parse_context_group_state& t) & -> void{ +#line 1681 "reflect.h2" + auto parse_context_group_state::swap(parse_context_group_state& t) & -> void{// NOLINT(performance-noexcept-swap) std::swap(cur_match_list, t.cur_match_list); std::swap(alternate_match_lists, t.alternate_match_lists); std::swap(modifiers, t.modifiers); } -#line 1697 "reflect.h2" +#line 1688 "reflect.h2" [[nodiscard]] auto parse_context_group_state::get_as_token() & -> token_ptr{ if (alternate_match_lists.empty()) { post_process_list(cur_match_list); @@ -3379,15 +3370,15 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov } } -#line 1709 "reflect.h2" +#line 1700 "reflect.h2" auto parse_context_group_state::add(cpp2::impl::in token) & -> void{ cur_match_list.push_back(token); } -#line 1714 "reflect.h2" +#line 1705 "reflect.h2" [[nodiscard]] auto parse_context_group_state::empty() const& -> bool { return cur_match_list.empty(); } -#line 1718 "reflect.h2" +#line 1709 "reflect.h2" auto parse_context_group_state::post_process_list(token_vec& list) -> void{ // Merge all characters auto merge_pos {list.begin()}; @@ -3408,7 +3399,7 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov , modifiers{ modifiers_ }{} parse_context_group_state::parse_context_group_state(){} -#line 1744 "reflect.h2" +#line 1735 "reflect.h2" [[nodiscard]] auto parse_context_branch_reset_state::next() & -> int{ auto g {cur_group}; cur_group += 1; @@ -3417,20 +3408,20 @@ parse_context_group_state::parse_context_group_state(){} return g; } -#line 1753 "reflect.h2" +#line 1744 "reflect.h2" auto parse_context_branch_reset_state::set_next(cpp2::impl::in g) & -> void{ cur_group = g; max_group = max(max_group, g); } -#line 1759 "reflect.h2" +#line 1750 "reflect.h2" auto parse_context_branch_reset_state::next_alternative() & -> void{ if (is_active) { cur_group = from; } } -#line 1766 "reflect.h2" +#line 1757 "reflect.h2" auto parse_context_branch_reset_state::set_active_reset(cpp2::impl::in restart) & -> void{ is_active = true; cur_group = restart; @@ -3445,16 +3436,16 @@ parse_context_group_state::parse_context_group_state(){} , from{ from_ }{} parse_context_branch_reset_state::parse_context_branch_reset_state(){} -#line 1794 "reflect.h2" +#line 1785 "reflect.h2" parse_context::parse_context(cpp2::impl::in r, auto const& e) : regex{ r } , root{ CPP2_UFCS_TEMPLATE_NONLOCAL(cpp2_new)(cpp2::shared, "") } , error_out{ e }{ -#line 1798 "reflect.h2" +#line 1789 "reflect.h2" } -#line 1804 "reflect.h2" +#line 1795 "reflect.h2" [[nodiscard]] auto parse_context::start_group() & -> parse_context_group_state { parse_context_group_state old_state {}; @@ -3464,7 +3455,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 1814 "reflect.h2" +#line 1805 "reflect.h2" [[nodiscard]] auto parse_context::end_group(cpp2::impl::in old_state) & -> token_ptr { auto inner {cur_group_state.get_as_token()}; @@ -3472,17 +3463,17 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return inner; } -#line 1821 "reflect.h2" +#line 1812 "reflect.h2" [[nodiscard]] auto parse_context::get_modifiers() const& -> expression_flags{ return cur_group_state.modifiers; } -#line 1825 "reflect.h2" +#line 1816 "reflect.h2" auto parse_context::set_modifiers(cpp2::impl::in mod) & -> void{ cur_group_state.modifiers = mod; } -#line 1832 "reflect.h2" +#line 1823 "reflect.h2" [[nodiscard]] auto parse_context::branch_reset_new_state() & -> parse_context_branch_reset_state { parse_context_branch_reset_state old_state {}; @@ -3492,7 +3483,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 1841 "reflect.h2" +#line 1832 "reflect.h2" auto parse_context::branch_reset_restore_state(cpp2::impl::in old_state) & -> void { auto max_group {cur_branch_reset_state.max_group}; @@ -3500,24 +3491,24 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} cur_branch_reset_state.set_next(cpp2::move(max_group)); } -#line 1848 "reflect.h2" +#line 1839 "reflect.h2" auto parse_context::next_alternative() & -> void { cur_group_state.next_alternative(); cur_branch_reset_state.next_alternative(); } -#line 1856 "reflect.h2" +#line 1847 "reflect.h2" auto parse_context::add_token(cpp2::impl::in token) & -> void{ cur_group_state.add(token); } -#line 1860 "reflect.h2" +#line 1851 "reflect.h2" [[nodiscard]] auto parse_context::has_token() const& -> bool{ return !(cur_group_state.empty()); } -#line 1864 "reflect.h2" +#line 1855 "reflect.h2" [[nodiscard]] auto parse_context::pop_token() & -> token_ptr { token_ptr r {nullptr}; @@ -3529,22 +3520,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 1875 "reflect.h2" +#line 1866 "reflect.h2" [[nodiscard]] auto parse_context::get_as_token() & -> token_ptr{ return root; } -#line 1881 "reflect.h2" +#line 1872 "reflect.h2" [[nodiscard]] auto parse_context::get_cur_group() const& -> int{ return cur_branch_reset_state.cur_group; } -#line 1885 "reflect.h2" +#line 1876 "reflect.h2" [[nodiscard]] auto parse_context::next_group() & -> int{ return cur_branch_reset_state.next(); } -#line 1889 "reflect.h2" +#line 1880 "reflect.h2" auto parse_context::set_named_group(cpp2::impl::in name, cpp2::impl::in id) & -> void { if (!(named_groups.contains(name))) {// Redefinition of group name is not an error. The left most one is retained. @@ -3552,7 +3543,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1896 "reflect.h2" +#line 1887 "reflect.h2" [[nodiscard]] auto parse_context::get_named_group(cpp2::impl::in name) const& -> int { auto iter {named_groups.find(name)}; @@ -3564,10 +3555,10 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1909 "reflect.h2" +#line 1900 "reflect.h2" [[nodiscard]] auto parse_context::current() const& -> char{return CPP2_ASSERT_IN_BOUNDS(regex, pos); } -#line 1912 "reflect.h2" +#line 1903 "reflect.h2" [[nodiscard]] auto parse_context::get_next_position(cpp2::impl::in in_class, cpp2::impl::in no_skip) const& -> size_t { auto perl_syntax {false}; @@ -3588,7 +3579,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} continue; } else {if (!(in_class) && '#' == cpp2::move(n)) { - cur = regex.find("\n", cur); + cur = regex.find('\n', cur); if (std::string::npos == cur) { // No new line, comment runs until the end of the pattern cur = regex.size(); @@ -3607,7 +3598,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cur; } -#line 1952 "reflect.h2" +#line 1943 "reflect.h2" [[nodiscard]] auto parse_context::next_impl(cpp2::impl::in in_class, cpp2::impl::in no_skip) & -> bool { pos = get_next_position(in_class, no_skip); @@ -3619,14 +3610,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1963 "reflect.h2" +#line 1954 "reflect.h2" [[nodiscard]] auto parse_context::next() & -> auto { return next_impl(false, false); } -#line 1964 "reflect.h2" +#line 1955 "reflect.h2" [[nodiscard]] auto parse_context::next_in_class() & -> auto { return next_impl(true, false); } -#line 1965 "reflect.h2" +#line 1956 "reflect.h2" [[nodiscard]] auto parse_context::next_no_skip() & -> auto { return next_impl(false, true); } -#line 1967 "reflect.h2" +#line 1958 "reflect.h2" [[nodiscard]] auto parse_context::next_n(cpp2::impl::in n) & -> bool{ auto r {true}; auto cur {0}; @@ -3636,13 +3627,13 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 1976 "reflect.h2" +#line 1967 "reflect.h2" [[nodiscard]] auto parse_context::has_next() const& -> bool{return cpp2::impl::cmp_less(pos,regex.size()); } -#line 1978 "reflect.h2" +#line 1969 "reflect.h2" [[nodiscard]] auto parse_context::grab_until_impl(cpp2::impl::in e, cpp2::impl::out r, cpp2::impl::in any) & -> bool { - auto end {pos}; + size_t end {}; if (any) { end = regex.find_first_of(e, pos); } @@ -3661,14 +3652,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1999 "reflect.h2" +#line 1990 "reflect.h2" [[nodiscard]] auto parse_context::grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> auto { return grab_until_impl(e, cpp2::impl::out(&r), false); } -#line 2000 "reflect.h2" +#line 1991 "reflect.h2" [[nodiscard]] auto parse_context::grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> auto { return grab_until_impl(std::string(1, e), cpp2::impl::out(&r), false); } -#line 2001 "reflect.h2" +#line 1992 "reflect.h2" [[nodiscard]] auto parse_context::grab_until_one_of(cpp2::impl::in e, cpp2::impl::out r) & -> auto { return grab_until_impl(e, cpp2::impl::out(&r), true); } -#line 2003 "reflect.h2" +#line 1994 "reflect.h2" [[nodiscard]] auto parse_context::grab_n(cpp2::impl::in n, cpp2::impl::out r) & -> bool { if (cpp2::impl::cmp_less_eq(pos + cpp2::impl::as_(n),regex.size())) { @@ -3682,7 +3673,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2016 "reflect.h2" +#line 2007 "reflect.h2" [[nodiscard]] auto parse_context::grab_number() & -> std::string { auto start {pos}; @@ -3704,7 +3695,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cpp2::move(r.value()); } -#line 2037 "reflect.h2" +#line 2028 "reflect.h2" [[nodiscard]] auto parse_context::peek_impl(cpp2::impl::in in_class) const& -> char{ auto next_pos {get_next_position(in_class, false)}; if (cpp2::impl::cmp_less(next_pos,regex.size())) { @@ -3715,12 +3706,12 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2047 "reflect.h2" +#line 2038 "reflect.h2" [[nodiscard]] auto parse_context::peek() const& -> auto { return peek_impl(false); } -#line 2048 "reflect.h2" +#line 2039 "reflect.h2" [[nodiscard]] auto parse_context::peek_in_class() const& -> auto { return peek_impl(true); } -#line 2053 "reflect.h2" +#line 2044 "reflect.h2" [[nodiscard]] auto parse_context::parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool { auto is_negative {false}; @@ -3775,7 +3766,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 2107 "reflect.h2" +#line 2098 "reflect.h2" [[nodiscard]] auto parse_context::parse_until(cpp2::impl::in term) & -> bool{ token_ptr cur_token {}; @@ -3814,7 +3805,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 2145 "reflect.h2" +#line 2136 "reflect.h2" [[nodiscard]] auto parse_context::parse(cpp2::impl::in modifiers) & -> bool { @@ -3830,21 +3821,21 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 2162 "reflect.h2" +#line 2153 "reflect.h2" [[nodiscard]] auto parse_context::get_pos() const& -> auto { return pos; } -#line 2163 "reflect.h2" +#line 2154 "reflect.h2" [[nodiscard]] auto parse_context::get_range(cpp2::impl::in start, cpp2::impl::in end) const& -> auto { return std::string(regex.substr(start, end - start + 1)); } -#line 2164 "reflect.h2" +#line 2155 "reflect.h2" [[nodiscard]] auto parse_context::valid() const& -> bool{return has_next() && !(has_error); } -#line 2166 "reflect.h2" +#line 2157 "reflect.h2" [[nodiscard]] auto parse_context::error(cpp2::impl::in err) & -> token_ptr{ has_error = true; error_out("Error during parsing of regex '" + cpp2::to_string(regex) + "' at position '" + cpp2::to_string(pos) + "': " + cpp2::to_string(err) + ""); return nullptr; } -#line 2181 "reflect.h2" +#line 2172 "reflect.h2" auto generation_function_context::add_tabs(cpp2::impl::in c) & -> void{ int i {0}; for( ; cpp2::impl::cmp_less(i,c); i += 1 ) { @@ -3852,7 +3843,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2188 "reflect.h2" +#line 2179 "reflect.h2" auto generation_function_context::remove_tabs(cpp2::impl::in c) & -> void{ tabs = tabs.substr(0, (cpp2::impl::as_(c)) * 2); } @@ -3862,22 +3853,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} , tabs{ tabs_ }{} generation_function_context::generation_function_context(){} -#line 2206 "reflect.h2" +#line 2197 "reflect.h2" [[nodiscard]] auto generation_context::match_parameters() const& -> std::string{return "r.pos, ctx"; } -#line 2211 "reflect.h2" +#line 2202 "reflect.h2" auto generation_context::add(cpp2::impl::in s) & -> void{ auto cur {get_current()}; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + cpp2::to_string(s) + "\n"; } -#line 2217 "reflect.h2" +#line 2208 "reflect.h2" auto generation_context::add_check(cpp2::impl::in check) & -> void{ auto cur {get_current()}; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + "if !cpp2::regex::" + cpp2::to_string(check) + " { r.matched = false; break; }\n"; } -#line 2223 "reflect.h2" +#line 2214 "reflect.h2" auto generation_context::add_statefull(cpp2::impl::in next_func, cpp2::impl::in check) & -> void { end_func_statefull(check); @@ -3886,19 +3877,19 @@ generation_function_context::generation_function_context(){} start_func_named(cpp2::move(name)); } -#line 2231 "reflect.h2" +#line 2222 "reflect.h2" auto generation_context::start_func_named(cpp2::impl::in name) & -> void { auto cur {new_context()}; - (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + cpp2::to_string(name) + ": @struct type = {\n"; + (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + cpp2::to_string(name) + ": @struct type = {\n"; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + " operator(): (this, cur: Iter, inout ctx: context, other) -> cpp2::regex::match_return = {\n"; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + " r := ctx..pass(cur);\n"; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + " do {\n"; (*cpp2::impl::assert_not_null(cpp2::move(cur))).add_tabs(3); } -#line 2242 "reflect.h2" +#line 2233 "reflect.h2" [[nodiscard]] auto generation_context::start_func() & -> std::string { auto name {gen_func_name()}; @@ -3906,7 +3897,7 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 2249 "reflect.h2" +#line 2240 "reflect.h2" auto generation_context::end_func_statefull(cpp2::impl::in s) & -> void { auto cur {get_current()}; @@ -3926,7 +3917,7 @@ generation_function_context::generation_function_context(){} finish_context(); } -#line 2269 "reflect.h2" +#line 2260 "reflect.h2" [[nodiscard]] auto generation_context::generate_func(cpp2::impl::in token) & -> std::string { auto name {start_func()}; @@ -3936,7 +3927,7 @@ generation_function_context::generation_function_context(){} return name; } -#line 2279 "reflect.h2" +#line 2270 "reflect.h2" [[nodiscard]] auto generation_context::generate_reset(cpp2::impl::in> groups) & -> std::string { if (groups.empty()) { @@ -3946,7 +3937,7 @@ generation_function_context::generation_function_context(){} auto name {gen_reset_func_name()}; auto cur {new_context()}; - (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + cpp2::to_string(name) + ": @struct type = {\n"; + (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + cpp2::to_string(name) + ": @struct type = {\n"; (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + " operator(): (this, inout ctx) = {\n"; for ( auto const& g : groups ) { (*cpp2::impl::assert_not_null(cur)).code += "" + cpp2::to_string((*cpp2::impl::assert_not_null(cur)).tabs) + " ctx..set_group_invalid(" + cpp2::to_string(g) + ");\n"; @@ -3959,33 +3950,33 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 2303 "reflect.h2" +#line 2294 "reflect.h2" [[nodiscard]] auto generation_context::gen_func_name() & -> std::string{ auto cur_id {matcher_func}; matcher_func += 1; return "func_" + cpp2::to_string(cpp2::move(cur_id)) + ""; } -#line 2309 "reflect.h2" +#line 2300 "reflect.h2" [[nodiscard]] auto generation_context::next_func_name() & -> std::string{ return gen_func_name() + "()"; } -#line 2313 "reflect.h2" +#line 2304 "reflect.h2" [[nodiscard]] auto generation_context::gen_reset_func_name() & -> std::string{ auto cur_id {reset_func}; reset_func += 1; return "reset_" + cpp2::to_string(cpp2::move(cur_id)) + ""; } -#line 2319 "reflect.h2" +#line 2310 "reflect.h2" [[nodiscard]] auto generation_context::gen_temp() & -> std::string{ auto cur_id {temp_name}; temp_name += 1; return "tmp_" + cpp2::to_string(cpp2::move(cur_id)) + ""; } -#line 2327 "reflect.h2" +#line 2318 "reflect.h2" [[nodiscard]] auto generation_context::new_context() & -> generation_function_context*{ gen_stack.push_back(generation_function_context()); auto cur {get_current()}; @@ -3994,7 +3985,7 @@ generation_function_context::generation_function_context(){} return cur; } -#line 2335 "reflect.h2" +#line 2326 "reflect.h2" auto generation_context::finish_context() & -> void{ auto cur {get_current()}; auto base {get_base()}; @@ -4003,22 +3994,22 @@ generation_function_context::generation_function_context(){} gen_stack.pop_back(); } -#line 2345 "reflect.h2" +#line 2336 "reflect.h2" [[nodiscard]] auto generation_context::get_current() & -> generation_function_context*{ return &gen_stack.back(); } -#line 2349 "reflect.h2" +#line 2340 "reflect.h2" [[nodiscard]] auto generation_context::get_base() & -> generation_function_context*{ return &CPP2_ASSERT_IN_BOUNDS_LITERAL(gen_stack, 0); } -#line 2353 "reflect.h2" +#line 2344 "reflect.h2" [[nodiscard]] auto generation_context::get_entry_func() const& -> std::string{ return entry_func; } -#line 2357 "reflect.h2" +#line 2348 "reflect.h2" [[nodiscard]] auto generation_context::create_named_group_lookup(cpp2::impl::in> named_groups) const& -> std::string { std::string res {"get_named_group_index: (name) -> int = {\n"}; @@ -4042,18 +4033,18 @@ generation_function_context::generation_function_context(){} return res; } -#line 2382 "reflect.h2" +#line 2373 "reflect.h2" [[nodiscard]] auto generation_context::run(cpp2::impl::in token) & -> std::string{ entry_func = generate_func(token); return (*cpp2::impl::assert_not_null(get_base())).code; } -#line 2397 "reflect.h2" +#line 2388 "reflect.h2" alternative_token::alternative_token() : regex_token_empty{ "" }{} -#line 2399 "reflect.h2" +#line 2390 "reflect.h2" [[nodiscard]] auto alternative_token::parse(parse_context& ctx) -> token_ptr{ if (ctx.current() != '|') {return nullptr; } @@ -4064,15 +4055,15 @@ generation_function_context::generation_function_context(){} alternative_token::~alternative_token() noexcept{} -#line 2414 "reflect.h2" +#line 2405 "reflect.h2" alternative_token_gen::alternative_token_gen(cpp2::impl::in a) : regex_token{ gen_string(a) } , alternatives{ a }{ -#line 2417 "reflect.h2" +#line 2408 "reflect.h2" } -#line 2419 "reflect.h2" +#line 2410 "reflect.h2" auto alternative_token_gen::generate_code(generation_context& ctx) const -> void { std::string functions {""}; @@ -4090,7 +4081,7 @@ generation_function_context::generation_function_context(){} ctx.add_statefull(next_name, "cpp2::regex::alternative_token_matcher::match(" + cpp2::to_string(ctx.match_parameters()) + ", other, " + cpp2::to_string(next_name) + " " + cpp2::to_string(cpp2::move(functions)) + ")"); } -#line 2436 "reflect.h2" +#line 2427 "reflect.h2" auto alternative_token_gen::add_groups(std::set& groups) const -> void { for ( auto const& cur : alternatives ) { @@ -4098,7 +4089,7 @@ generation_function_context::generation_function_context(){} } } -#line 2443 "reflect.h2" +#line 2434 "reflect.h2" [[nodiscard]] auto alternative_token_gen::gen_string(cpp2::impl::in a) -> std::string { std::string r {""}; @@ -4114,14 +4105,14 @@ generation_function_context::generation_function_context(){} alternative_token_gen::~alternative_token_gen() noexcept{} -#line 2464 "reflect.h2" +#line 2455 "reflect.h2" any_token::any_token(cpp2::impl::in single_line) : regex_token_check{ ".", "any_token_matcher" }{ -#line 2466 "reflect.h2" +#line 2457 "reflect.h2" } -#line 2468 "reflect.h2" +#line 2459 "reflect.h2" [[nodiscard]] auto any_token::parse(parse_context& ctx) -> token_ptr{ if ('.' != ctx.current()) {return nullptr; } @@ -4130,21 +4121,21 @@ generation_function_context::generation_function_context(){} any_token::~any_token() noexcept{} -#line 2485 "reflect.h2" +#line 2476 "reflect.h2" char_token::char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_) : regex_token{ std::string(1, t) } , token{ t } , ignore_case{ ignore_case_ }{ -#line 2489 "reflect.h2" +#line 2480 "reflect.h2" } -#line 2491 "reflect.h2" +#line 2482 "reflect.h2" [[nodiscard]] auto char_token::parse(parse_context& ctx) -> token_ptr{ return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, ctx.current(), ctx.get_modifiers().has(expression_flags::case_insensitive)); } -#line 2495 "reflect.h2" +#line 2486 "reflect.h2" auto char_token::generate_code(generation_context& ctx) const -> void { if (ignore_case) { @@ -4153,14 +4144,14 @@ generation_function_context::generation_function_context(){} { size_t i{0}; -#line 2501 "reflect.h2" +#line 2492 "reflect.h2" for( ; cpp2::impl::cmp_less(i,token.size()); i += 1 ) { CPP2_ASSERT_IN_BOUNDS(lower, i) = string_util::safe_tolower(CPP2_ASSERT_IN_BOUNDS(token, i)); CPP2_ASSERT_IN_BOUNDS(upper, i) = string_util::safe_toupper(CPP2_ASSERT_IN_BOUNDS(token, i)); } } -#line 2506 "reflect.h2" +#line 2497 "reflect.h2" if (upper != lower) { gen_case_insensitive(cpp2::move(lower), cpp2::move(upper), ctx); } @@ -4173,7 +4164,7 @@ size_t i{0}; } } -#line 2518 "reflect.h2" +#line 2509 "reflect.h2" auto char_token::gen_case_insensitive(cpp2::impl::in lower, cpp2::impl::in upper, generation_context& ctx) const& -> void { std::string name {"str_" + cpp2::to_string(ctx.gen_temp()) + ""}; @@ -4195,7 +4186,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 2539 "reflect.h2" +#line 2530 "reflect.h2" auto char_token::gen_case_sensitive(generation_context& ctx) const& -> void { std::string name {"str_" + cpp2::to_string(ctx.gen_temp()) + ""}; @@ -4214,7 +4205,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 2557 "reflect.h2" +#line 2548 "reflect.h2" [[nodiscard]] auto char_token::add_escapes(std::string str) const& -> std::string { str = string_util::replace_all(str, "\\", "\\\\"); @@ -4230,7 +4221,7 @@ size_t i{0}; return cpp2::move(str); } -#line 2572 "reflect.h2" +#line 2563 "reflect.h2" auto char_token::append(char_token const& that) & -> void{ (*this).token += that.token; (*this).string_rep += that.string_rep; @@ -4238,19 +4229,19 @@ size_t i{0}; char_token::~char_token() noexcept{} -#line 2589 "reflect.h2" +#line 2580 "reflect.h2" class_token::class_token(cpp2::impl::in negate_, cpp2::impl::in case_insensitive_, cpp2::impl::in class_str_, cpp2::impl::in str) : regex_token{ str } , negate{ negate_ } , case_insensitive{ case_insensitive_ } , class_str{ class_str_ } -#line 2590 "reflect.h2" +#line 2581 "reflect.h2" { -#line 2595 "reflect.h2" +#line 2586 "reflect.h2" } -#line 2598 "reflect.h2" +#line 2589 "reflect.h2" [[nodiscard]] auto class_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '[') {return nullptr; } @@ -4376,13 +4367,13 @@ size_t i{0}; ); } -#line 2723 "reflect.h2" +#line 2714 "reflect.h2" auto class_token::generate_code(generation_context& ctx) const -> void { ctx.add_check("class_token_matcher::match(" + cpp2::to_string(ctx.match_parameters()) + ")"); } -#line 2728 "reflect.h2" +#line 2719 "reflect.h2" [[nodiscard]] auto class_token::create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string { auto sep {", "}; @@ -4393,12 +4384,12 @@ size_t i{0}; class_token::~class_token() noexcept{} -#line 2740 "reflect.h2" +#line 2731 "reflect.h2" [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } -#line 2745 "reflect.h2" +#line 2736 "reflect.h2" if (std::string::npos == std::string("afenrt^.[]()*{}?+|\\").find(ctx.peek())) { return nullptr; } @@ -4432,7 +4423,7 @@ size_t i{0}; } -#line 2781 "reflect.h2" +#line 2772 "reflect.h2" [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'K'))) {return nullptr; } @@ -4441,18 +4432,18 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, "\\K", "ctx..set_group_start(0, r.pos);"); } -#line 2803 "reflect.h2" +#line 2794 "reflect.h2" group_ref_token::group_ref_token(cpp2::impl::in id_, cpp2::impl::in case_insensitive_, cpp2::impl::in str) : regex_token{ str } , id{ id_ } , case_insensitive{ case_insensitive_ } -#line 2804 "reflect.h2" +#line 2795 "reflect.h2" { -#line 2808 "reflect.h2" +#line 2799 "reflect.h2" } -#line 2810 "reflect.h2" +#line 2801 "reflect.h2" [[nodiscard]] auto group_ref_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -4554,14 +4545,14 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, cpp2::move(group_id), ctx.get_modifiers().has(expression_flags::case_insensitive), cpp2::move(str)); } -#line 2911 "reflect.h2" +#line 2902 "reflect.h2" auto group_ref_token::generate_code(generation_context& ctx) const -> void{ ctx.add_check("group_ref_token_matcher(" + cpp2::to_string(ctx.match_parameters()) + ")"); } group_ref_token::~group_ref_token() noexcept{} -#line 2934 "reflect.h2" +#line 2925 "reflect.h2" [[nodiscard]] auto group_token::parse_lookahead(parse_context& ctx, cpp2::impl::in syntax, cpp2::impl::in positive) -> token_ptr { static_cast(ctx.next());// Skip last token defining the syntax @@ -4576,7 +4567,7 @@ size_t i{0}; return r; } -#line 2948 "reflect.h2" +#line 2939 "reflect.h2" [[nodiscard]] auto group_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '(') {return nullptr; } @@ -4714,7 +4705,7 @@ size_t i{0}; } } -#line 3085 "reflect.h2" +#line 3076 "reflect.h2" [[nodiscard]] auto group_token::gen_string(cpp2::impl::in name, cpp2::impl::in name_brackets, cpp2::impl::in has_modifier, cpp2::impl::in modifiers, cpp2::impl::in inner_) -> std::string { std::string start {"("}; @@ -4733,7 +4724,7 @@ size_t i{0}; return cpp2::move(start) + (*cpp2::impl::assert_not_null(inner_)).to_string() + ")"; } -#line 3103 "reflect.h2" +#line 3094 "reflect.h2" auto group_token::generate_code(generation_context& ctx) const -> void { if (-1 != number) { @@ -4754,7 +4745,7 @@ size_t i{0}; } } -#line 3123 "reflect.h2" +#line 3114 "reflect.h2" auto group_token::add_groups(std::set& groups) const -> void { (*cpp2::impl::assert_not_null(inner)).add_groups(groups); @@ -4765,7 +4756,7 @@ size_t i{0}; group_token::~group_token() noexcept{} -#line 3135 "reflect.h2" +#line 3126 "reflect.h2" [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'x'))) {return nullptr; } @@ -4804,7 +4795,7 @@ size_t i{0}; return r; } -#line 3176 "reflect.h2" +#line 3167 "reflect.h2" [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() == '$' || (ctx.current() == '\\' && ctx.peek() == '$')) { @@ -4822,7 +4813,7 @@ size_t i{0}; }} } -#line 3196 "reflect.h2" +#line 3187 "reflect.h2" [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '^' && !((ctx.current() == '\\' && ctx.peek() == 'A'))) {return nullptr; } @@ -4836,29 +4827,29 @@ size_t i{0}; } } -#line 3221 "reflect.h2" +#line 3212 "reflect.h2" lookahead_token::lookahead_token(cpp2::impl::in positive_) : regex_token{ "" } , positive{ positive_ }{ -#line 3223 "reflect.h2" +#line 3214 "reflect.h2" } -#line 3225 "reflect.h2" +#line 3216 "reflect.h2" auto lookahead_token::generate_code(generation_context& ctx) const -> void{ auto inner_name {ctx.generate_func(inner)}; ctx.add_check("lookahead_token_matcher(" + cpp2::to_string(ctx.match_parameters()) + ", " + cpp2::to_string(cpp2::move(inner_name)) + ")"); } -#line 3231 "reflect.h2" +#line 3222 "reflect.h2" auto lookahead_token::add_groups(std::set& groups) const -> void{ (*cpp2::impl::assert_not_null(inner)).add_groups(groups); } lookahead_token::~lookahead_token() noexcept{} -#line 3239 "reflect.h2" +#line 3230 "reflect.h2" [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -4884,7 +4875,7 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, "\\" + cpp2::to_string(ctx.current()) + "", "" + cpp2::to_string(cpp2::move(name)) + "::match"); } -#line 3267 "reflect.h2" +#line 3258 "reflect.h2" [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'o'))) {return nullptr; } @@ -4910,11 +4901,11 @@ size_t i{0}; return r; } -#line 3304 "reflect.h2" +#line 3295 "reflect.h2" range_token::range_token() : regex_token{ "" }{} -#line 3306 "reflect.h2" +#line 3297 "reflect.h2" [[nodiscard]] auto range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -4935,7 +4926,7 @@ size_t i{0}; std::string min_count_str {"-1"}; std::string max_count_str {"-1"}; - size_t sep {inner.find(",")}; + size_t sep {inner.find(',')}; if (sep == std::string::npos) { min_count_str = inner; @@ -4988,7 +4979,7 @@ size_t i{0}; return nullptr; } -#line 3379 "reflect.h2" +#line 3370 "reflect.h2" auto range_token::parse_modifier(parse_context& ctx) & -> void { if (ctx.peek() == '?') { @@ -5001,7 +4992,7 @@ size_t i{0}; }} } -#line 3391 "reflect.h2" +#line 3382 "reflect.h2" [[nodiscard]] auto range_token::gen_mod_string() const& -> std::string { if (kind == range_flags::not_greedy) { @@ -5015,7 +5006,7 @@ size_t i{0}; }} } -#line 3404 "reflect.h2" +#line 3395 "reflect.h2" [[nodiscard]] auto range_token::gen_range_string() const& -> std::string { std::string r {""}; @@ -5035,7 +5026,7 @@ size_t i{0}; return r; } -#line 3423 "reflect.h2" +#line 3414 "reflect.h2" auto range_token::generate_code(generation_context& ctx) const -> void { auto inner_name {ctx.generate_func(inner_token)}; @@ -5047,14 +5038,14 @@ size_t i{0}; ctx.add_statefull(next_name, "cpp2::regex::range_token_matcher::match(" + cpp2::to_string(ctx.match_parameters()) + ", " + cpp2::to_string(cpp2::move(inner_name)) + ", " + cpp2::to_string(cpp2::move(reset_name)) + ", other, " + cpp2::to_string(next_name) + ")"); } -#line 3434 "reflect.h2" +#line 3425 "reflect.h2" auto range_token::add_groups(std::set& groups) const -> void{ (*cpp2::impl::assert_not_null(inner_token)).add_groups(groups); } range_token::~range_token() noexcept{} -#line 3447 "reflect.h2" +#line 3438 "reflect.h2" [[nodiscard]] auto special_range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -5078,7 +5069,7 @@ size_t i{0}; if (!(ctx.has_token())) {return ctx.error("'" + cpp2::to_string(ctx.current()) + "' without previous element."); } -#line 3471 "reflect.h2" +#line 3462 "reflect.h2" (*cpp2::impl::assert_not_null(r)).parse_modifier(ctx); (*cpp2::impl::assert_not_null(r)).inner_token = ctx.pop_token(); @@ -5088,7 +5079,7 @@ size_t i{0}; special_range_token::~special_range_token() noexcept{} -#line 3484 "reflect.h2" +#line 3475 "reflect.h2" [[nodiscard]] auto word_boundary_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -5106,15 +5097,15 @@ size_t i{0}; }} } -#line 3520 "reflect.h2" +#line 3511 "reflect.h2" template regex_generator::regex_generator(cpp2::impl::in r, Error_out const& e) : regex{ r } , error_out{ e }{ -#line 3523 "reflect.h2" +#line 3514 "reflect.h2" } -#line 3525 "reflect.h2" +#line 3516 "reflect.h2" template [[nodiscard]] auto regex_generator::parse() & -> std::string { // Extract modifiers and adapt regex. @@ -5150,7 +5141,7 @@ size_t i{0}; return source; } -#line 3560 "reflect.h2" +#line 3551 "reflect.h2" template auto regex_generator::extract_modifiers() & -> void { if (regex.find_first_of("'/") == 0) { @@ -5166,7 +5157,7 @@ size_t i{0}; } } -#line 3576 "reflect.h2" +#line 3567 "reflect.h2" template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string { regex_generator parser {regex, err}; @@ -5175,7 +5166,7 @@ template [[nodiscard]] auto generate_regex(cpp2::impl::in void { auto has_default {false}; @@ -5230,7 +5221,7 @@ auto regex_gen(meta::type_declaration& t) -> void CPP2_UFCS(add_runtime_support_include)(t, "cpp2regex.h"); } -#line 3645 "reflect.h2" +#line 3636 "reflect.h2" [[nodiscard]] auto apply_metafunctions( declaration_node& n, type_declaration& rtype, @@ -5266,7 +5257,7 @@ auto regex_gen(meta::type_declaration& t) -> void auto const& arg : CPP2_UFCS(template_arguments)((*cpp2::impl::assert_not_null(meta))) ) CPP2_UFCS(push_back)(args, CPP2_UFCS(to_string)(arg)); - CPP2_UFCS(set_metafunction_name)(rtype, name, cpp2::move(args)); + CPP2_UFCS(set_metafunction_name)(rtype, name, args); // Dispatch // @@ -5322,7 +5313,7 @@ auto regex_gen(meta::type_declaration& t) -> void regex_gen(rtype); } else { - error("unrecognized metafunction name: " + cpp2::move(name)); + error("unrecognized metafunction name: " + name); error( "(temporary alpha limitation) currently the supported names are: " "interface, polymorphic_base, ordered, weakly_ordered, partially_ordered, " @@ -5331,6 +5322,15 @@ auto regex_gen(meta::type_declaration& t) -> void ); return false; }}}}}}}}}}}}}}}}} + + if (( + !(CPP2_UFCS(empty)(args)) + && !(CPP2_UFCS(arguments_were_used)(rtype)))) + + { + error(name + " did not use its template arguments - did you mean to write '" + name + " <" + CPP2_ASSERT_IN_BOUNDS_LITERAL(cpp2::move(args), 0) + "> type' (with the spaces)?"); + return false; + } } return true;