diff --git a/include/cpp2util.h b/include/cpp2util.h index 0572a9820c..7c8e71ed44 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -2813,8 +2813,6 @@ inline constexpr auto as_() -> decltype(auto) } -#include "cpp2regex.h" - using cpp2::cpp2_new; diff --git a/regression-tests/test-results/gcc-10-c++20/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp.output b/regression-tests/test-results/gcc-10-c++20/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp.output index ea1b7cfa7a..6df6e11641 100644 --- a/regression-tests/test-results/gcc-10-c++20/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp.output +++ b/regression-tests/test-results/gcc-10-c++20/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp.output @@ -6,12 +6,12 @@ pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:46: error: expect In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7: ../../../include/cpp2util.h:10005:47: error: static assertion failed: GCC 11 or higher is required to support variables and type-scope functions that have a 'requires' clause. This includes a type-scope 'forward' parameter of non-wildcard type, such as 'func: (this, forward s: std::string)', which relies on being able to add a 'requires' clause - in that case, use 'forward s: _' instead if you need the result to compile with GCC 10. pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:4:1: note: in expansion of macro ‘CPP2_REQUIRES_’ -pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:241&&) requires is_same_v::type>::type>’ +pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:3: error: no declaration matches ‘element::element(auto:95&&) requires is_same_v::type>::type>’ pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:11: note: candidates are: ‘element::element(const element&)’ -pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template element::element(auto:239&&)’ +pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:20: note: ‘template element::element(auto:93&&)’ pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:5:78: error: expected unqualified-id before ‘{’ token -pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:242&&) requires is_same_v::type>::type>’ +pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:8: error: no declaration matches ‘element& element::operator=(auto:96&&) requires is_same_v::type>::type>’ pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:6:16: note: candidates are: ‘void element::operator=(const element&)’ -pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template element& element::operator=(auto:240&&)’ +pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:16: note: ‘template element& element::operator=(auto:94&&)’ pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:1:7: note: ‘class element’ defined here diff --git a/regression-tests/test-results/gcc-10-c++20/pure2-print.cpp.output b/regression-tests/test-results/gcc-10-c++20/pure2-print.cpp.output index 6fa7637aa0..2dcc49e75e 100644 --- a/regression-tests/test-results/gcc-10-c++20/pure2-print.cpp.output +++ b/regression-tests/test-results/gcc-10-c++20/pure2-print.cpp.output @@ -9,8 +9,8 @@ pure2-print.cpp2:68:1: note: in expansion of macro ‘CPP2_REQUIRES_’ pure2-print.cpp2:97:1: note: in expansion of macro ‘CPP2_REQUIRES_’ pure2-print.cpp2:9:41: error: ‘constexpr const T outer::object_alias’ is not a static data member of ‘class outer’ pure2-print.cpp2:9:48: error: template definition of non-template ‘constexpr const T outer::object_alias’ -pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:240& ...) requires (is_convertible_v::type>::type, int> && ...)’ -pure2-print.cpp2:67:29: note: candidate is: ‘template static void outer::mytype::variadic(const auto:239& ...)’ +pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:94& ...) requires (is_convertible_v::type>::type, int> && ...)’ +pure2-print.cpp2:67:29: note: candidate is: ‘template static void outer::mytype::variadic(const auto:93& ...)’ pure2-print.cpp2:10:19: note: ‘class outer::mytype’ defined here pure2-print.cpp2:96:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::impl::cmp_greater_eq(sizeof ... (Args ...), 0)’ pure2-print.cpp2:96:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::impl::cmp_greater_eq(sizeof ... (Args ...), 0)’ diff --git a/regression-tests/test-results/gcc-14-c++2b/gcc-version.output b/regression-tests/test-results/gcc-14-c++2b/gcc-version.output index a2fc0ea249..e2db23c836 100644 --- a/regression-tests/test-results/gcc-14-c++2b/gcc-version.output +++ b/regression-tests/test-results/gcc-14-c++2b/gcc-version.output @@ -1,4 +1,4 @@ -g++ (GCC) 14.1.1 20240701 (Red Hat 14.1.1-7) +g++ (GCC) 14.2.1 20240801 (Red Hat 14.2.1-1) Copyright (C) 2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/regression-tests/test-results/gcc-14-c++2b/mixed-bounds-safety-with-assert.cpp.execution b/regression-tests/test-results/gcc-14-c++2b/mixed-bounds-safety-with-assert.cpp.execution index 149b96d909..4a8fe8c0fd 100644 --- a/regression-tests/test-results/gcc-14-c++2b/mixed-bounds-safety-with-assert.cpp.execution +++ b/regression-tests/test-results/gcc-14-c++2b/mixed-bounds-safety-with-assert.cpp.execution @@ -1 +1 @@ -mixed-bounds-safety-with-assert.cpp2(11) void print_subrange(const auto:237&, cpp2::impl::in, cpp2::impl::in) [with auto:237 = std::vector; cpp2::impl::in = const int]: Bounds safety violation +mixed-bounds-safety-with-assert.cpp2(11) void print_subrange(const auto:91&, cpp2::impl::in, cpp2::impl::in) [with auto:91 = std::vector; cpp2::impl::in = const int]: Bounds safety violation diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution index fe6e6efc96..14d06c270a 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution @@ -9,26 +9,26 @@ Running tests_10_escapes: 08_y: OK regex: foo(\h)bar parsed_regex: foo(\h)bar str: foo bar result_expr: $1 expected_results 09_y: OK regex: (\H)(\h) parsed_regex: (\H)(\h) str: foo bar result_expr: $1-$2 expected_results o- 10_y: OK regex: (\h)(\H) parsed_regex: (\h)(\H) str: foo bar result_expr: $1-$2 expected_results -b -11_y: OK regex: foo(\v+)bar parsed_regex: foo(\v+)bar str: foo +11_y: OK regex: foo(\v+)bar parsed_regex: foo(\v+)bar str: foo + +bar result_expr: $1 expected_results + -bar result_expr: $1 expected_results +12_y: OK regex: (\V+)(\v) parsed_regex: (\V+)(\v) str: foo + +bar result_expr: $1-$2 expected_results foo- +13_y: OK regex: (\v+)(\V) parsed_regex: (\v+)(\V) str: foo + -12_y: OK regex: (\V+)(\v) parsed_regex: (\V+)(\v) str: foo - - -bar result_expr: $1-$2 expected_results foo- -13_y: OK regex: (\v+)(\V) parsed_regex: (\v+)(\V) str: foo - - -bar result_expr: $1-$2 expected_results - +bar result_expr: $1-$2 expected_results + -b -14_y: OK regex: foo(\v)bar parsed_regex: foo(\v)bar str: foo bar result_expr: $1 expected_results -15_y: OK regex: (\V)(\v) parsed_regex: (\V)(\v) str: foo bar result_expr: $1-$2 expected_results o- +14_y: OK regex: foo(\v)bar parsed_regex: foo(\v)bar str: foo bar result_expr: $1 expected_results +15_y: OK regex: (\V)(\v) parsed_regex: (\V)(\v) str: foo bar result_expr: $1-$2 expected_results o- 16_y: OK regex: (\v)(\V) parsed_regex: (\v)(\V) str: foo bar result_expr: $1-$2 expected_results -b 17_y: OK regex: foo\t\n\r\f\a\ebar parsed_regex: foo\t\n\r\f\a\ebar str: foo bar result_expr: $& expected_results foo diff --git a/regression-tests/test-results/pure2-regex_01_char_matcher.cpp b/regression-tests/test-results/pure2-regex_01_char_matcher.cpp index ae3ff7ee42..13500736bc 100644 --- a/regression-tests/test-results/pure2-regex_01_char_matcher.cpp +++ b/regression-tests/test-results/pure2-regex_01_char_matcher.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_02_ranges.cpp b/regression-tests/test-results/pure2-regex_02_ranges.cpp index fb632c0370..0524a53288 100644 --- a/regression-tests/test-results/pure2-regex_02_ranges.cpp +++ b/regression-tests/test-results/pure2-regex_02_ranges.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_03_wildcard.cpp b/regression-tests/test-results/pure2-regex_03_wildcard.cpp index e6924b841e..18522d9fd5 100644 --- a/regression-tests/test-results/pure2-regex_03_wildcard.cpp +++ b/regression-tests/test-results/pure2-regex_03_wildcard.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_04_start_end.cpp b/regression-tests/test-results/pure2-regex_04_start_end.cpp index 9d53200484..0e857b7e56 100644 --- a/regression-tests/test-results/pure2-regex_04_start_end.cpp +++ b/regression-tests/test-results/pure2-regex_04_start_end.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_05_classes.cpp b/regression-tests/test-results/pure2-regex_05_classes.cpp index 7ec65ccbda..7b569df9ff 100644 --- a/regression-tests/test-results/pure2-regex_05_classes.cpp +++ b/regression-tests/test-results/pure2-regex_05_classes.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_06_boundaries.cpp b/regression-tests/test-results/pure2-regex_06_boundaries.cpp index 2f750e0815..bbca6c3ecf 100644 --- a/regression-tests/test-results/pure2-regex_06_boundaries.cpp +++ b/regression-tests/test-results/pure2-regex_06_boundaries.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_07_short_classes.cpp b/regression-tests/test-results/pure2-regex_07_short_classes.cpp index 5ae55bacd5..3e12cfef41 100644 --- a/regression-tests/test-results/pure2-regex_07_short_classes.cpp +++ b/regression-tests/test-results/pure2-regex_07_short_classes.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_08_alternatives.cpp b/regression-tests/test-results/pure2-regex_08_alternatives.cpp index 543190ff2d..923344c601 100644 --- a/regression-tests/test-results/pure2-regex_08_alternatives.cpp +++ b/regression-tests/test-results/pure2-regex_08_alternatives.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_09_groups.cpp b/regression-tests/test-results/pure2-regex_09_groups.cpp index a37dda119e..736248b87b 100644 --- a/regression-tests/test-results/pure2-regex_09_groups.cpp +++ b/regression-tests/test-results/pure2-regex_09_groups.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_10_escapes.cpp b/regression-tests/test-results/pure2-regex_10_escapes.cpp index f879aebdf9..85a101d3a0 100644 --- a/regression-tests/test-results/pure2-regex_10_escapes.cpp +++ b/regression-tests/test-results/pure2-regex_10_escapes.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_11_group_references.cpp b/regression-tests/test-results/pure2-regex_11_group_references.cpp index 3161c25782..b07ad7e01e 100644 --- a/regression-tests/test-results/pure2-regex_11_group_references.cpp +++ b/regression-tests/test-results/pure2-regex_11_group_references.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_12_case_insensitive.cpp b/regression-tests/test-results/pure2-regex_12_case_insensitive.cpp index 5fa4130efe..595e7c8c11 100644 --- a/regression-tests/test-results/pure2-regex_12_case_insensitive.cpp +++ b/regression-tests/test-results/pure2-regex_12_case_insensitive.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_13_possessive_modifier.cpp b/regression-tests/test-results/pure2-regex_13_possessive_modifier.cpp index f64ec7b70f..06c080b80b 100644 --- a/regression-tests/test-results/pure2-regex_13_possessive_modifier.cpp +++ b/regression-tests/test-results/pure2-regex_13_possessive_modifier.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_14_multiline_modifier.cpp b/regression-tests/test-results/pure2-regex_14_multiline_modifier.cpp index ed4eb5dfc6..338af1243b 100644 --- a/regression-tests/test-results/pure2-regex_14_multiline_modifier.cpp +++ b/regression-tests/test-results/pure2-regex_14_multiline_modifier.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_15_group_modifiers.cpp b/regression-tests/test-results/pure2-regex_15_group_modifiers.cpp index d8b4cf6910..b0103954a4 100644 --- a/regression-tests/test-results/pure2-regex_15_group_modifiers.cpp +++ b/regression-tests/test-results/pure2-regex_15_group_modifiers.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_16_perl_syntax_modifier.cpp b/regression-tests/test-results/pure2-regex_16_perl_syntax_modifier.cpp index f35365f506..3d81c02e7a 100644 --- a/regression-tests/test-results/pure2-regex_16_perl_syntax_modifier.cpp +++ b/regression-tests/test-results/pure2-regex_16_perl_syntax_modifier.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_17_comments.cpp b/regression-tests/test-results/pure2-regex_17_comments.cpp index 2e772618ab..a566f273c1 100644 --- a/regression-tests/test-results/pure2-regex_17_comments.cpp +++ b/regression-tests/test-results/pure2-regex_17_comments.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_18_branch_reset.cpp b/regression-tests/test-results/pure2-regex_18_branch_reset.cpp index 1e6e056785..aaf375aa2c 100644 --- a/regression-tests/test-results/pure2-regex_18_branch_reset.cpp +++ b/regression-tests/test-results/pure2-regex_18_branch_reset.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/regression-tests/test-results/pure2-regex_19_lookahead.cpp b/regression-tests/test-results/pure2-regex_19_lookahead.cpp index 78bbec6625..610330ae54 100644 --- a/regression-tests/test-results/pure2-regex_19_lookahead.cpp +++ b/regression-tests/test-results/pure2-regex_19_lookahead.cpp @@ -1,5 +1,6 @@ #define CPP2_IMPORT_STD Yes +#include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== diff --git a/source/common.h b/source/common.h index cf1d6e4881..69805f51b0 100644 --- a/source/common.h +++ b/source/common.h @@ -38,20 +38,11 @@ #ifndef CPP2_COMMON_H #define CPP2_COMMON_H -#include #include #include #include -#include -#include #include -#include -#include -#include -#include -#include #include -#include namespace cpp2 { diff --git a/source/parse.h b/source/parse.h index 3c3ca960b5..ae63565d99 100644 --- a/source/parse.h +++ b/source/parse.h @@ -5532,6 +5532,7 @@ auto pretty_print_visualize(translation_unit_node const& n) class parser { std::vector& errors; + std::set& includes; std::unique_ptr parse_tree = {}; @@ -5577,10 +5578,10 @@ class parser } }; - std::vector const* tokens = {}; + std::vector const* tokens = {}; stable_vector* generated_tokens = {}; - int pos = 0; - std::string parse_kind = {}; + int pos = 0; + std::string parse_kind = {}; // Keep track of the function bodies' locations - used to emit comments // in the right pass (decide whether it's a comment that belongs with @@ -5656,13 +5657,18 @@ class parser // // errors error list // - parser( std::vector& errors_ ) + parser( + std::vector& errors_, + std::set& includes_ + ) : errors{ errors_ } + , includes{ includes_ } , parse_tree{std::make_unique()} { } parser( parser const& that ) : errors{ that.errors } + , includes{ that.includes } , parse_tree{std::make_unique()} { } diff --git a/source/reflect.h b/source/reflect.h index 3c4b29823f..7593428450 100644 --- a/source/reflect.h +++ b/source/reflect.h @@ -10,106 +10,103 @@ #line 1 "reflect.h2" -#line 21 "reflect.h2" +#line 22 "reflect.h2" namespace cpp2 { namespace meta { -#line 33 "reflect.h2" +#line 34 "reflect.h2" class compiler_services; -#line 227 "reflect.h2" +#line 233 "reflect.h2" class declaration_base; -#line 253 "reflect.h2" +#line 259 "reflect.h2" class declaration; -#line 335 "reflect.h2" +#line 341 "reflect.h2" class function_declaration; -#line 425 "reflect.h2" +#line 431 "reflect.h2" class object_declaration; -#line 461 "reflect.h2" +#line 467 "reflect.h2" class type_declaration; -#line 598 "reflect.h2" +#line 604 "reflect.h2" class alias_declaration; -#line 1006 "reflect.h2" +#line 1012 "reflect.h2" class value_member_info; -#line 1520 "reflect.h2" -using namespace cpp2::regex; - -#line 1525 "reflect.h2" +#line 1530 "reflect.h2" class expression_flags; -#line 1541 "reflect.h2" +#line 1546 "reflect.h2" class regex_token; -#line 1567 "reflect.h2" +#line 1572 "reflect.h2" class regex_token_check; -#line 1586 "reflect.h2" +#line 1591 "reflect.h2" class regex_token_code; -#line 1605 "reflect.h2" +#line 1610 "reflect.h2" class regex_token_empty; -#line 1621 "reflect.h2" +#line 1626 "reflect.h2" class regex_token_list; -#line 1660 "reflect.h2" +#line 1665 "reflect.h2" class parse_context_group_state; -#line 1721 "reflect.h2" +#line 1726 "reflect.h2" class parse_context_branch_reset_state; -#line 1764 "reflect.h2" +#line 1769 "reflect.h2" class parse_context; -#line 2162 "reflect.h2" +#line 2167 "reflect.h2" class generation_function_context; -#line 2180 "reflect.h2" +#line 2185 "reflect.h2" class generation_context; -#line 2378 "reflect.h2" +#line 2383 "reflect.h2" class alternative_token; -#line 2393 "reflect.h2" +#line 2398 "reflect.h2" class alternative_token_gen; -#line 2445 "reflect.h2" +#line 2450 "reflect.h2" class any_token; -#line 2463 "reflect.h2" +#line 2468 "reflect.h2" class char_token; -#line 2566 "reflect.h2" +#line 2571 "reflect.h2" class class_token; -#line 2781 "reflect.h2" +#line 2786 "reflect.h2" class group_ref_token; -#line 2912 "reflect.h2" +#line 2917 "reflect.h2" class group_token; -#line 3199 "reflect.h2" +#line 3204 "reflect.h2" class lookahead_token; -#line 3280 "reflect.h2" +#line 3285 "reflect.h2" class range_token; -#line 3428 "reflect.h2" +#line 3433 "reflect.h2" class special_range_token; -#line 3495 "reflect.h2" +#line 3500 "reflect.h2" template class regex_generator; -#line 3743 "reflect.h2" +#line 3750 "reflect.h2" } } @@ -137,18 +134,20 @@ template class regex_generator; #include "parse.h" #include "cpp2regex.h" +using namespace cpp2::regex; -#line 21 "reflect.h2" +#line 22 "reflect.h2" namespace cpp2 { namespace meta { -#line 33 "reflect.h2" +#line 34 "reflect.h2" class compiler_services { -#line 37 "reflect.h2" +#line 38 "reflect.h2" private: std::vector* errors; + private: std::set* includes; private: int errors_original_size; private: stable_vector* generated_tokens; private: cpp2::parser parser; @@ -156,64 +155,67 @@ class compiler_services private: std::vector metafunction_args {}; private: bool metafunctions_used {false}; -#line 47 "reflect.h2" +#line 49 "reflect.h2" public: explicit compiler_services( std::vector* errors_, + std::set* includes_, stable_vector* generated_tokens_ ); -#line 61 "reflect.h2" +#line 65 "reflect.h2" public: auto set_metafunction_name(cpp2::impl::in name, cpp2::impl::in> args) & -> void; -#line 67 "reflect.h2" +#line 71 "reflect.h2" public: [[nodiscard]] auto get_metafunction_name() const& -> std::string_view; public: [[nodiscard]] auto get_argument(cpp2::impl::in index) & -> std::string; -#line 77 "reflect.h2" +#line 81 "reflect.h2" public: [[nodiscard]] auto get_arguments() & -> std::vector; -#line 82 "reflect.h2" +#line 86 "reflect.h2" public: [[nodiscard]] auto arguments_were_used() const& -> bool; using parse_statement_ret = std::unique_ptr; -#line 84 "reflect.h2" +#line 88 "reflect.h2" protected: [[nodiscard]] auto parse_statement( std::string_view source ) & -> parse_statement_ret; -#line 137 "reflect.h2" +#line 141 "reflect.h2" + public: auto add_runtime_support_include(cpp2::impl::in s) & -> void; + public: [[nodiscard]] virtual auto position() const -> source_position; -#line 146 "reflect.h2" +#line 152 "reflect.h2" public: auto require( cpp2::impl::in b, cpp2::impl::in msg ) const& -> void; -#line 157 "reflect.h2" +#line 163 "reflect.h2" public: auto error(cpp2::impl::in msg) const& -> void; -#line 169 "reflect.h2" +#line 175 "reflect.h2" public: auto report_violation(auto const& msg) const& -> void; -#line 177 "reflect.h2" +#line 183 "reflect.h2" public: [[nodiscard]] auto is_active() const& -> auto; public: virtual ~compiler_services() noexcept; public: compiler_services(compiler_services const& that); -#line 178 "reflect.h2" +#line 184 "reflect.h2" }; -#line 227 "reflect.h2" +#line 233 "reflect.h2" class declaration_base : public compiler_services { -#line 231 "reflect.h2" +#line 237 "reflect.h2" protected: declaration_node* n; protected: explicit declaration_base( @@ -222,28 +224,28 @@ class declaration_base cpp2::impl::in s ); -#line 244 "reflect.h2" +#line 250 "reflect.h2" public: [[nodiscard]] auto position() const -> source_position override; public: [[nodiscard]] auto print() const& -> std::string; public: virtual ~declaration_base() noexcept; public: declaration_base(declaration_base const& that); -#line 247 "reflect.h2" +#line 253 "reflect.h2" }; -#line 253 "reflect.h2" +#line 259 "reflect.h2" class declaration : public declaration_base { -#line 257 "reflect.h2" +#line 263 "reflect.h2" public: explicit declaration( declaration_node* n_, cpp2::impl::in s ); -#line 266 "reflect.h2" +#line 272 "reflect.h2" public: [[nodiscard]] auto is_public() const& -> bool; public: [[nodiscard]] auto is_protected() const& -> bool; public: [[nodiscard]] auto is_private() const& -> bool; @@ -262,7 +264,7 @@ class declaration public: [[nodiscard]] auto name() const& -> std::string_view; -#line 287 "reflect.h2" +#line 293 "reflect.h2" public: [[nodiscard]] auto has_initializer() const& -> bool; public: [[nodiscard]] auto is_global() const& -> bool; @@ -304,21 +306,21 @@ class declaration public: declaration(declaration const& that); -#line 329 "reflect.h2" +#line 335 "reflect.h2" }; -#line 335 "reflect.h2" +#line 341 "reflect.h2" class function_declaration : public declaration { -#line 339 "reflect.h2" +#line 345 "reflect.h2" public: explicit function_declaration( declaration_node* n_, cpp2::impl::in s ); -#line 349 "reflect.h2" +#line 355 "reflect.h2" public: [[nodiscard]] auto index_of_parameter_named(cpp2::impl::in s) const& -> int; public: [[nodiscard]] auto has_parameter_named(cpp2::impl::in s) const& -> bool; public: [[nodiscard]] auto has_in_parameter_named(cpp2::impl::in s) const& -> bool; @@ -358,7 +360,7 @@ class function_declaration public: [[nodiscard]] auto get_parameters() const& -> std::vector; -#line 396 "reflect.h2" +#line 402 "reflect.h2" public: [[nodiscard]] auto is_binary_comparison_function() const& -> bool; public: auto default_to_virtual() & -> void; @@ -369,94 +371,94 @@ class function_declaration public: function_declaration(function_declaration const& that); -#line 419 "reflect.h2" +#line 425 "reflect.h2" }; -#line 425 "reflect.h2" +#line 431 "reflect.h2" class object_declaration : public declaration { -#line 429 "reflect.h2" +#line 435 "reflect.h2" public: explicit object_declaration( declaration_node* n_, cpp2::impl::in s ); -#line 439 "reflect.h2" +#line 445 "reflect.h2" public: [[nodiscard]] auto is_const() const& -> bool; public: [[nodiscard]] auto has_wildcard_type() const& -> bool; public: [[nodiscard]] auto type() const& -> std::string; -#line 449 "reflect.h2" +#line 455 "reflect.h2" public: [[nodiscard]] auto initializer() const& -> std::string; public: object_declaration(object_declaration const& that); -#line 455 "reflect.h2" +#line 461 "reflect.h2" }; -#line 461 "reflect.h2" +#line 467 "reflect.h2" class type_declaration : public declaration { -#line 465 "reflect.h2" +#line 471 "reflect.h2" public: explicit type_declaration( declaration_node* n_, cpp2::impl::in s ); -#line 475 "reflect.h2" +#line 481 "reflect.h2" public: auto reserve_names(cpp2::impl::in name, auto&& ...etc) const& -> void; -#line 489 "reflect.h2" +#line 495 "reflect.h2" public: [[nodiscard]] auto is_polymorphic() const& -> bool; public: [[nodiscard]] auto is_final() const& -> bool; public: [[nodiscard]] auto make_final() & -> bool; public: [[nodiscard]] auto get_member_functions() const& -> std::vector; -#line 504 "reflect.h2" +#line 510 "reflect.h2" public: [[nodiscard]] auto get_member_functions_needing_initializer() const& -> std::vector; -#line 519 "reflect.h2" +#line 525 "reflect.h2" public: [[nodiscard]] auto get_member_objects() const& -> std::vector; -#line 529 "reflect.h2" +#line 535 "reflect.h2" public: [[nodiscard]] auto get_member_types() const& -> std::vector; -#line 539 "reflect.h2" +#line 545 "reflect.h2" public: [[nodiscard]] auto get_member_aliases() const& -> std::vector; -#line 549 "reflect.h2" +#line 555 "reflect.h2" public: [[nodiscard]] auto get_members() const& -> std::vector; struct query_declared_value_set_functions_ret { bool out_this_in_that; bool out_this_move_that; bool inout_this_in_that; bool inout_this_move_that; }; -#line 559 "reflect.h2" +#line 565 "reflect.h2" public: [[nodiscard]] auto query_declared_value_set_functions() const& -> query_declared_value_set_functions_ret; -#line 574 "reflect.h2" +#line 580 "reflect.h2" public: auto add_member(cpp2::impl::in source) & -> void; -#line 588 "reflect.h2" +#line 594 "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 592 "reflect.h2" +#line 598 "reflect.h2" }; -#line 598 "reflect.h2" +#line 604 "reflect.h2" class alias_declaration : public declaration { -#line 602 "reflect.h2" +#line 608 "reflect.h2" public: explicit alias_declaration( declaration_node* n_, @@ -465,62 +467,62 @@ class alias_declaration public: alias_declaration(alias_declaration const& that); -#line 611 "reflect.h2" +#line 617 "reflect.h2" }; -#line 626 "reflect.h2" +#line 632 "reflect.h2" auto add_virtual_destructor(meta::type_declaration& t) -> void; -#line 644 "reflect.h2" +#line 650 "reflect.h2" auto interface(meta::type_declaration& t) -> void; -#line 690 "reflect.h2" +#line 696 "reflect.h2" auto polymorphic_base(meta::type_declaration& t) -> void; -#line 735 "reflect.h2" +#line 741 "reflect.h2" auto ordered_impl( meta::type_declaration& t, cpp2::impl::in ordering ) -> void; -#line 764 "reflect.h2" +#line 770 "reflect.h2" auto ordered(meta::type_declaration& t) -> void; -#line 772 "reflect.h2" +#line 778 "reflect.h2" auto weakly_ordered(meta::type_declaration& t) -> void; -#line 780 "reflect.h2" +#line 786 "reflect.h2" auto partially_ordered(meta::type_declaration& t) -> void; -#line 802 "reflect.h2" +#line 808 "reflect.h2" auto copyable(meta::type_declaration& t) -> void; -#line 836 "reflect.h2" +#line 842 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void; -#line 864 "reflect.h2" +#line 870 "reflect.h2" auto value(meta::type_declaration& t) -> void; -#line 870 "reflect.h2" +#line 876 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void; -#line 876 "reflect.h2" +#line 882 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void; -#line 905 "reflect.h2" +#line 911 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void; -#line 942 "reflect.h2" +#line 948 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void; -#line 1006 "reflect.h2" +#line 1012 "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 1010 "reflect.h2" +#line 1016 "reflect.h2" }; auto basic_enum( @@ -529,23 +531,22 @@ auto basic_enum( cpp2::impl::in bitwise ) -> void; -#line 1276 "reflect.h2" +#line 1282 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void; -#line 1303 "reflect.h2" +#line 1309 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void; -#line 1349 "reflect.h2" +#line 1355 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void; -#line 1500 "reflect.h2" +#line 1506 "reflect.h2" auto print(cpp2::impl::in t) -> void; -#line 1520 "reflect.h2" -using namespace cpp2::regex; +#line 1526 "reflect.h2" using error_func = std::function x)>; -#line 1525 "reflect.h2" +#line 1530 "reflect.h2" class expression_flags { private: cpp2::u8 _value; private: constexpr expression_flags(cpp2::impl::in _val); @@ -580,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 1533 "reflect.h2" +#line 1538 "reflect.h2" }; -#line 1541 "reflect.h2" +#line 1546 "reflect.h2" class regex_token { public: std::string string_rep; public: explicit regex_token(cpp2::impl::in str); -#line 1549 "reflect.h2" +#line 1554 "reflect.h2" public: explicit regex_token(); -#line 1554 "reflect.h2" +#line 1559 "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; @@ -604,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 1559 "reflect.h2" +#line 1564 "reflect.h2" }; using token_ptr = std::shared_ptr; using token_vec = std::vector; -#line 1565 "reflect.h2" +#line 1570 "reflect.h2" // Adds a check in code generation. // class regex_token_check : public regex_token { -#line 1571 "reflect.h2" +#line 1576 "reflect.h2" private: std::string check; public: explicit regex_token_check(cpp2::impl::in str, cpp2::impl::in check_); -#line 1578 "reflect.h2" +#line 1583 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~regex_token_check() noexcept; @@ -629,21 +630,21 @@ class regex_token_check public: auto operator=(regex_token_check const&) -> void = delete; -#line 1581 "reflect.h2" +#line 1586 "reflect.h2" }; -#line 1584 "reflect.h2" +#line 1589 "reflect.h2" // Adds code in code generation. // class regex_token_code : public regex_token { -#line 1590 "reflect.h2" +#line 1595 "reflect.h2" private: std::string code; public: explicit regex_token_code(cpp2::impl::in str, cpp2::impl::in code_); -#line 1597 "reflect.h2" +#line 1602 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~regex_token_code() noexcept; @@ -651,19 +652,19 @@ class regex_token_code public: auto operator=(regex_token_code const&) -> void = delete; -#line 1600 "reflect.h2" +#line 1605 "reflect.h2" }; -#line 1603 "reflect.h2" +#line 1608 "reflect.h2" // Token that does not influence the matching. E.g. comment. // class regex_token_empty : public regex_token { -#line 1609 "reflect.h2" +#line 1614 "reflect.h2" public: explicit regex_token_empty(cpp2::impl::in str); -#line 1613 "reflect.h2" +#line 1618 "reflect.h2" public: auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void override; public: virtual ~regex_token_empty() noexcept; @@ -671,27 +672,27 @@ class regex_token_empty public: auto operator=(regex_token_empty const&) -> void = delete; -#line 1616 "reflect.h2" +#line 1621 "reflect.h2" }; -#line 1619 "reflect.h2" +#line 1624 "reflect.h2" // Represents a list of regex tokens as one token. // class regex_token_list : public regex_token { -#line 1625 "reflect.h2" +#line 1630 "reflect.h2" public: token_vec tokens; public: explicit regex_token_list(cpp2::impl::in t); -#line 1632 "reflect.h2" +#line 1637 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 1638 "reflect.h2" +#line 1643 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 1644 "reflect.h2" +#line 1649 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in vec) -> std::string; public: virtual ~regex_token_list() noexcept; @@ -699,10 +700,10 @@ class regex_token_list public: auto operator=(regex_token_list const&) -> void = delete; -#line 1651 "reflect.h2" +#line 1656 "reflect.h2" }; -#line 1654 "reflect.h2" +#line 1659 "reflect.h2" // // Parse and generation context. // @@ -718,33 +719,33 @@ class parse_context_group_state // Start a new alternative. public: auto next_alternative() & -> void; -#line 1674 "reflect.h2" +#line 1679 "reflect.h2" // Swap this state with the other one. public: auto swap(parse_context_group_state& t) & -> void; -#line 1681 "reflect.h2" +#line 1686 "reflect.h2" // Convert this state into a regex token. public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 1693 "reflect.h2" +#line 1698 "reflect.h2" // Add a token to the current matcher list. public: auto add(cpp2::impl::in token) & -> void; -#line 1698 "reflect.h2" +#line 1703 "reflect.h2" // True if current matcher list is empty. public: [[nodiscard]] auto empty() const& -> bool; -#line 1702 "reflect.h2" +#line 1707 "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 1716 "reflect.h2" +#line 1721 "reflect.h2" }; -#line 1719 "reflect.h2" +#line 1724 "reflect.h2" // State for the branch reset. Takes care of the group numbering. See '(|)'. // class parse_context_branch_reset_state @@ -757,25 +758,25 @@ class parse_context_branch_reset_state // Next group identifier. public: [[nodiscard]] auto next() & -> int; -#line 1737 "reflect.h2" +#line 1742 "reflect.h2" // Set next group identifier. public: auto set_next(cpp2::impl::in g) & -> void; -#line 1743 "reflect.h2" +#line 1748 "reflect.h2" // Start a new alternative branch. public: auto next_alternative() & -> void; -#line 1750 "reflect.h2" +#line 1755 "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 1757 "reflect.h2" +#line 1762 "reflect.h2" }; -#line 1760 "reflect.h2" +#line 1765 "reflect.h2" // Context during parsing of the regular expressions. // // Keeps track of the distributed group identifiers, current parsed group and branch resets. @@ -789,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 1774 "reflect.h2" +#line 1779 "reflect.h2" public: std::map named_groups {}; private: error_func error_out; // TODO: Declaring std::function fails for cpp2. @@ -797,64 +798,64 @@ class parse_context public: explicit parse_context(cpp2::impl::in r, auto const& e); -#line 1785 "reflect.h2" +#line 1790 "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 1798 "reflect.h2" +#line 1803 "reflect.h2" // `old_state` argument needs to be from start group. public: [[nodiscard]] auto end_group(cpp2::impl::in old_state) & -> token_ptr; -#line 1806 "reflect.h2" +#line 1811 "reflect.h2" public: [[nodiscard]] auto get_modifiers() const& -> expression_flags; -#line 1810 "reflect.h2" +#line 1815 "reflect.h2" public: auto set_modifiers(cpp2::impl::in mod) & -> void; -#line 1814 "reflect.h2" +#line 1819 "reflect.h2" // Branch reset management functions // public: [[nodiscard]] auto branch_reset_new_state() & -> parse_context_branch_reset_state; -#line 1826 "reflect.h2" +#line 1831 "reflect.h2" public: auto branch_reset_restore_state(cpp2::impl::in old_state) & -> void; -#line 1833 "reflect.h2" +#line 1838 "reflect.h2" public: auto next_alternative() & -> void; -#line 1839 "reflect.h2" +#line 1844 "reflect.h2" // Regex token management // public: auto add_token(cpp2::impl::in token) & -> void; -#line 1845 "reflect.h2" +#line 1850 "reflect.h2" public: [[nodiscard]] auto has_token() const& -> bool; -#line 1849 "reflect.h2" +#line 1854 "reflect.h2" public: [[nodiscard]] auto pop_token() & -> token_ptr; -#line 1860 "reflect.h2" +#line 1865 "reflect.h2" public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 1864 "reflect.h2" +#line 1869 "reflect.h2" // Group management // public: [[nodiscard]] auto get_cur_group() const& -> int; -#line 1870 "reflect.h2" +#line 1875 "reflect.h2" public: [[nodiscard]] auto next_group() & -> int; -#line 1874 "reflect.h2" +#line 1879 "reflect.h2" public: auto set_named_group(cpp2::impl::in name, cpp2::impl::in id) & -> void; -#line 1881 "reflect.h2" +#line 1886 "reflect.h2" public: [[nodiscard]] auto get_named_group(cpp2::impl::in name) const& -> int; -#line 1892 "reflect.h2" +#line 1897 "reflect.h2" // Position management functions // public: [[nodiscard]] auto current() const& -> char; @@ -862,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 1936 "reflect.h2" +#line 1941 "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 1948 "reflect.h2" +#line 1953 "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 1961 "reflect.h2" +#line 1966 "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 1984 "reflect.h2" +#line 1989 "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 2001 "reflect.h2" +#line 2006 "reflect.h2" public: [[nodiscard]] auto grab_number() & -> std::string; -#line 2022 "reflect.h2" +#line 2027 "reflect.h2" private: [[nodiscard]] auto peek_impl(cpp2::impl::in in_class) const& -> char; -#line 2032 "reflect.h2" +#line 2037 "reflect.h2" public: [[nodiscard]] auto peek() const& -> auto; public: [[nodiscard]] auto peek_in_class() const& -> auto; -#line 2036 "reflect.h2" +#line 2041 "reflect.h2" // Parsing functions // public: [[nodiscard]] auto parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool; -#line 2092 "reflect.h2" +#line 2097 "reflect.h2" public: [[nodiscard]] auto parse_until(cpp2::impl::in term) & -> bool; -#line 2130 "reflect.h2" +#line 2135 "reflect.h2" public: [[nodiscard]] auto parse(cpp2::impl::in modifiers) & -> bool; -#line 2145 "reflect.h2" +#line 2150 "reflect.h2" // Misc functions public: [[nodiscard]] auto get_pos() const& -> auto; @@ -918,10 +919,10 @@ class parse_context public: auto operator=(parse_context const&) -> void = delete; -#line 2156 "reflect.h2" +#line 2161 "reflect.h2" }; -#line 2159 "reflect.h2" +#line 2164 "reflect.h2" // Context for one function generation. Generation of functions can be interleaved, // therefore we buffer the code for one function here. // @@ -931,16 +932,16 @@ class generation_function_context { public: auto add_tabs(cpp2::impl::in c) & -> void; -#line 2173 "reflect.h2" +#line 2178 "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 2176 "reflect.h2" +#line 2181 "reflect.h2" }; -#line 2179 "reflect.h2" +#line 2184 "reflect.h2" // Context for generating the state machine. class generation_context { @@ -960,68 +961,68 @@ class generation_context // Add code line. public: auto add(cpp2::impl::in s) & -> void; -#line 2201 "reflect.h2" +#line 2206 "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 2207 "reflect.h2" +#line 2212 "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 2216 "reflect.h2" +#line 2221 "reflect.h2" protected: auto start_func_named(cpp2::impl::in name) & -> void; -#line 2227 "reflect.h2" +#line 2232 "reflect.h2" protected: [[nodiscard]] auto start_func() & -> std::string; -#line 2234 "reflect.h2" +#line 2239 "reflect.h2" protected: auto end_func_statefull(cpp2::impl::in s) & -> void; -#line 2253 "reflect.h2" +#line 2258 "reflect.h2" // Generate the function for a token. public: [[nodiscard]] auto generate_func(cpp2::impl::in token) & -> std::string; -#line 2263 "reflect.h2" +#line 2268 "reflect.h2" // Generate the reset for a list of group identifiers. public: [[nodiscard]] auto generate_reset(cpp2::impl::in> groups) & -> std::string; -#line 2286 "reflect.h2" +#line 2291 "reflect.h2" // Name generation // protected: [[nodiscard]] auto gen_func_name() & -> std::string; -#line 2294 "reflect.h2" +#line 2299 "reflect.h2" public: [[nodiscard]] auto next_func_name() & -> std::string; -#line 2298 "reflect.h2" +#line 2303 "reflect.h2" protected: [[nodiscard]] auto gen_reset_func_name() & -> std::string; -#line 2304 "reflect.h2" +#line 2309 "reflect.h2" public: [[nodiscard]] auto gen_temp() & -> std::string; -#line 2310 "reflect.h2" +#line 2315 "reflect.h2" // Context management // public: [[nodiscard]] auto new_context() & -> generation_function_context*; -#line 2320 "reflect.h2" +#line 2325 "reflect.h2" public: auto finish_context() & -> void; -#line 2328 "reflect.h2" +#line 2333 "reflect.h2" // Misc functions // private: [[nodiscard]] auto get_current() & -> generation_function_context*; -#line 2334 "reflect.h2" +#line 2339 "reflect.h2" private: [[nodiscard]] auto get_base() & -> generation_function_context*; -#line 2338 "reflect.h2" +#line 2343 "reflect.h2" public: [[nodiscard]] auto get_entry_func() const& -> std::string; -#line 2342 "reflect.h2" +#line 2347 "reflect.h2" public: [[nodiscard]] auto create_named_group_lookup(cpp2::impl::in> named_groups) const& -> std::string; -#line 2366 "reflect.h2" +#line 2371 "reflect.h2" // Run the generation for the token. public: [[nodiscard]] auto run(cpp2::impl::in token) & -> std::string; public: generation_context() = default; @@ -1029,7 +1030,7 @@ class generation_context public: auto operator=(generation_context const&) -> void = delete; -#line 2372 "reflect.h2" +#line 2377 "reflect.h2" }; // Regex syntax: | Example: ab|ba @@ -1049,24 +1050,24 @@ class alternative_token public: auto operator=(alternative_token const&) -> void = delete; -#line 2391 "reflect.h2" +#line 2396 "reflect.h2" }; class alternative_token_gen : public regex_token { -#line 2397 "reflect.h2" +#line 2402 "reflect.h2" private: token_vec alternatives; public: explicit alternative_token_gen(cpp2::impl::in a); -#line 2404 "reflect.h2" +#line 2409 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2421 "reflect.h2" +#line 2426 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 2428 "reflect.h2" +#line 2433 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in a) -> std::string; public: virtual ~alternative_token_gen() noexcept; @@ -1074,19 +1075,19 @@ class alternative_token_gen public: auto operator=(alternative_token_gen const&) -> void = delete; -#line 2440 "reflect.h2" +#line 2445 "reflect.h2" }; -#line 2443 "reflect.h2" +#line 2448 "reflect.h2" // Regex syntax: . // class any_token : public regex_token_check { -#line 2449 "reflect.h2" +#line 2454 "reflect.h2" public: explicit any_token(cpp2::impl::in single_line); -#line 2453 "reflect.h2" +#line 2458 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~any_token() noexcept; @@ -1094,37 +1095,37 @@ class any_token public: auto operator=(any_token const&) -> void = delete; -#line 2458 "reflect.h2" +#line 2463 "reflect.h2" }; -#line 2461 "reflect.h2" +#line 2466 "reflect.h2" // Regex syntax: a // class char_token : public regex_token { -#line 2467 "reflect.h2" +#line 2472 "reflect.h2" private: std::string token; private: bool ignore_case; public: explicit char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_); -#line 2476 "reflect.h2" +#line 2481 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2480 "reflect.h2" +#line 2485 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2503 "reflect.h2" +#line 2508 "reflect.h2" public: auto gen_case_insensitive(cpp2::impl::in lower, cpp2::impl::in upper, generation_context& ctx) const& -> void; -#line 2524 "reflect.h2" +#line 2529 "reflect.h2" public: auto gen_case_sensitive(generation_context& ctx) const& -> void; -#line 2542 "reflect.h2" +#line 2547 "reflect.h2" public: [[nodiscard]] auto add_escapes(std::string str) const& -> std::string; -#line 2557 "reflect.h2" +#line 2562 "reflect.h2" public: auto append(char_token const& that) & -> void; public: virtual ~char_token() noexcept; @@ -1132,30 +1133,30 @@ class char_token public: auto operator=(char_token const&) -> void = delete; -#line 2561 "reflect.h2" +#line 2566 "reflect.h2" }; -#line 2564 "reflect.h2" +#line 2569 "reflect.h2" // Regex syntax: [] Example: [abcx-y[:digits:]] // class class_token : public regex_token { -#line 2570 "reflect.h2" +#line 2575 "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 2582 "reflect.h2" +#line 2587 "reflect.h2" // TODO: Rework class generation: Generate check functions for classes. public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2708 "reflect.h2" +#line 2713 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2713 "reflect.h2" +#line 2718 "reflect.h2" private: [[nodiscard]] static auto create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string; public: virtual ~class_token() noexcept; @@ -1163,20 +1164,20 @@ class class_token public: auto operator=(class_token const&) -> void = delete; -#line 2720 "reflect.h2" +#line 2725 "reflect.h2" }; -#line 2723 "reflect.h2" +#line 2728 "reflect.h2" // Regex syntax: \a or \n or \[ // [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr; -#line 2764 "reflect.h2" +#line 2769 "reflect.h2" // Regex syntax: \K Example: ab\Kcd // [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr; -#line 2775 "reflect.h2" +#line 2780 "reflect.h2" // Regex syntax: \ Example: \1 // \g{name_or_number} // \k{name_or_number} @@ -1186,16 +1187,16 @@ class class_token class group_ref_token : public regex_token { -#line 2785 "reflect.h2" +#line 2790 "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 2795 "reflect.h2" +#line 2800 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2896 "reflect.h2" +#line 2901 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~group_ref_token() noexcept; @@ -1203,10 +1204,10 @@ class group_ref_token public: auto operator=(group_ref_token const&) -> void = delete; -#line 2899 "reflect.h2" +#line 2904 "reflect.h2" }; -#line 2902 "reflect.h2" +#line 2907 "reflect.h2" // Regex syntax: () Example: (abc) // (?:) (?i:abc) @@ -1220,22 +1221,22 @@ class group_ref_token class group_token : public regex_token { -#line 2916 "reflect.h2" +#line 2921 "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 2933 "reflect.h2" +#line 2938 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 3070 "reflect.h2" +#line 3075 "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 3088 "reflect.h2" +#line 3093 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3108 "reflect.h2" +#line 3113 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~group_token() noexcept; @@ -1244,25 +1245,25 @@ class group_token public: auto operator=(group_token const&) -> void = delete; -#line 3115 "reflect.h2" +#line 3120 "reflect.h2" }; -#line 3118 "reflect.h2" +#line 3123 "reflect.h2" // Regex syntax: \x or \x{} Example: \x{62} // [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr; -#line 3159 "reflect.h2" +#line 3164 "reflect.h2" // Regex syntax: $ Example: aa$ // [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr; -#line 3179 "reflect.h2" +#line 3184 "reflect.h2" // Regex syntax: ^ Example: ^aa // [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr; -#line 3195 "reflect.h2" +#line 3200 "reflect.h2" // Regex syntax: (?=) or (?!) or (*pla), etc. Example: (?=AA) // // Parsed in group_token. @@ -1270,16 +1271,16 @@ class group_token class lookahead_token : public regex_token { -#line 3203 "reflect.h2" +#line 3208 "reflect.h2" protected: bool positive; public: token_ptr inner {nullptr}; public: explicit lookahead_token(cpp2::impl::in positive_); -#line 3210 "reflect.h2" +#line 3215 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3216 "reflect.h2" +#line 3221 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~lookahead_token() noexcept; @@ -1287,26 +1288,26 @@ class lookahead_token public: auto operator=(lookahead_token const&) -> void = delete; -#line 3219 "reflect.h2" +#line 3224 "reflect.h2" }; -#line 3222 "reflect.h2" +#line 3227 "reflect.h2" // Named character classes // [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr; -#line 3250 "reflect.h2" +#line 3255 "reflect.h2" // Regex syntax: \o{} Example: \o{142} // [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr; -#line 3278 "reflect.h2" +#line 3283 "reflect.h2" // Regex syntax: {min, max} Example: a{2,4} // class range_token : public regex_token { -#line 3284 "reflect.h2" +#line 3289 "reflect.h2" protected: int min_count {-1}; protected: int max_count {-1}; protected: int kind {range_flags::greedy}; @@ -1316,19 +1317,19 @@ class range_token public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 3364 "reflect.h2" +#line 3369 "reflect.h2" public: auto parse_modifier(parse_context& ctx) & -> void; -#line 3376 "reflect.h2" +#line 3381 "reflect.h2" public: [[nodiscard]] auto gen_mod_string() const& -> std::string; -#line 3389 "reflect.h2" +#line 3394 "reflect.h2" public: [[nodiscard]] auto gen_range_string() const& -> std::string; -#line 3408 "reflect.h2" +#line 3413 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3419 "reflect.h2" +#line 3424 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~range_token() noexcept; @@ -1336,16 +1337,16 @@ class range_token public: auto operator=(range_token const&) -> void = delete; -#line 3423 "reflect.h2" +#line 3428 "reflect.h2" }; -#line 3426 "reflect.h2" +#line 3431 "reflect.h2" // Regex syntax: *, +, or ? Example: aa* // class special_range_token : public range_token { -#line 3432 "reflect.h2" +#line 3437 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~special_range_token() noexcept; @@ -1354,17 +1355,17 @@ class special_range_token public: auto operator=(special_range_token const&) -> void = delete; -#line 3462 "reflect.h2" +#line 3467 "reflect.h2" }; -#line 3465 "reflect.h2" +#line 3470 "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 3487 "reflect.h2" +#line 3492 "reflect.h2" //----------------------------------------------------------------------- // // Parser for regular expression. @@ -1385,24 +1386,24 @@ template class regex_generator public: explicit regex_generator(cpp2::impl::in r, Error_out const& e); -#line 3510 "reflect.h2" +#line 3515 "reflect.h2" public: [[nodiscard]] auto parse() & -> std::string; -#line 3545 "reflect.h2" +#line 3550 "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 3559 "reflect.h2" +#line 3564 "reflect.h2" }; template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string; -#line 3571 "reflect.h2" +#line 3576 "reflect.h2" auto regex_gen(meta::type_declaration& t) -> void; -#line 3624 "reflect.h2" +#line 3631 "reflect.h2" //----------------------------------------------------------------------- // // apply_metafunctions @@ -1413,7 +1414,7 @@ auto regex_gen(meta::type_declaration& t) -> void; auto const& error ) -> bool; -#line 3743 "reflect.h2" +#line 3750 "reflect.h2" } } @@ -1423,12 +1424,12 @@ auto regex_gen(meta::type_declaration& t) -> void; #line 1 "reflect.h2" -#line 21 "reflect.h2" +#line 22 "reflect.h2" namespace cpp2 { namespace meta { -#line 26 "reflect.h2" +#line 27 "reflect.h2" //----------------------------------------------------------------------- // // Compiler services @@ -1436,42 +1437,44 @@ namespace meta { //----------------------------------------------------------------------- // -#line 35 "reflect.h2" +#line 36 "reflect.h2" // Common data members // -#line 45 "reflect.h2" +#line 47 "reflect.h2" // Constructor // -#line 47 "reflect.h2" +#line 49 "reflect.h2" compiler_services::compiler_services( std::vector* errors_, + std::set* includes_, stable_vector* generated_tokens_ ) : errors{ errors_ } + , includes{ includes_ } , errors_original_size{ cpp2::unsafe_narrow(std::ssize(*cpp2::impl::assert_not_null(errors))) } , generated_tokens{ generated_tokens_ } - , parser{ *cpp2::impl::assert_not_null(errors) } -#line 52 "reflect.h2" + , parser{ *cpp2::impl::assert_not_null(errors), *cpp2::impl::assert_not_null(includes) } +#line 55 "reflect.h2" { -#line 57 "reflect.h2" +#line 61 "reflect.h2" } // Common API // -#line 61 "reflect.h2" +#line 65 "reflect.h2" auto compiler_services::set_metafunction_name(cpp2::impl::in name, cpp2::impl::in> args) & -> void{ metafunction_name = name; metafunction_args = args; metafunctions_used = CPP2_UFCS(empty)(args); } -#line 67 "reflect.h2" +#line 71 "reflect.h2" [[nodiscard]] auto compiler_services::get_metafunction_name() const& -> std::string_view { return metafunction_name; } -#line 69 "reflect.h2" +#line 73 "reflect.h2" [[nodiscard]] auto compiler_services::get_argument(cpp2::impl::in index) & -> std::string{ metafunctions_used = true; if (([_0 = 0, _1 = index, _2 = CPP2_UFCS(ssize)(metafunction_args)]{ return cpp2::impl::cmp_less_eq(_0,_1) && cpp2::impl::cmp_less(_1,_2); }())) { @@ -1480,16 +1483,16 @@ namespace meta { return ""; } -#line 77 "reflect.h2" +#line 81 "reflect.h2" [[nodiscard]] auto compiler_services::get_arguments() & -> std::vector{ metafunctions_used = true; return metafunction_args; } -#line 82 "reflect.h2" +#line 86 "reflect.h2" [[nodiscard]] auto compiler_services::arguments_were_used() const& -> bool { return metafunctions_used; } -#line 84 "reflect.h2" +#line 88 "reflect.h2" [[nodiscard]] auto compiler_services::parse_statement( std::string_view source @@ -1497,7 +1500,7 @@ namespace meta { { cpp2::impl::deferred_init> ret; -#line 90 "reflect.h2" +#line 94 "reflect.h2" auto original_source {source}; CPP2_UFCS(push_back)(generated_lines, std::vector()); @@ -1512,7 +1515,7 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; // First split this string into source_lines // -#line 102 "reflect.h2" +#line 106 "reflect.h2" if ( cpp2::impl::cmp_greater(CPP2_UFCS(ssize)(source),1) && newline_pos != source.npos) { @@ -1525,7 +1528,7 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; } } -#line 113 "reflect.h2" +#line 117 "reflect.h2" if (!(CPP2_UFCS(empty)(source))) { cpp2::move(add_line)(cpp2::move(source)); } @@ -1550,7 +1553,10 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; }return std::move(ret.value()); } -#line 137 "reflect.h2" +#line 141 "reflect.h2" + auto compiler_services::add_runtime_support_include(cpp2::impl::in s) & -> void { static_cast(CPP2_UFCS(emplace)((*cpp2::impl::assert_not_null(includes)), s)); } + +#line 143 "reflect.h2" [[nodiscard]] auto compiler_services::position() const -> source_position { @@ -1560,7 +1566,7 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; // Error diagnosis and handling, integrated with compiler output // Unlike a contract violation, .requires continues further processing // -#line 146 "reflect.h2" +#line 152 "reflect.h2" auto compiler_services::require( cpp2::impl::in b, @@ -1572,7 +1578,7 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; } } -#line 157 "reflect.h2" +#line 163 "reflect.h2" auto compiler_services::error(cpp2::impl::in msg) const& -> void { auto message {cpp2::impl::as_(msg)}; @@ -1585,7 +1591,7 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; // Enable custom contracts on this object, integrated with compiler output // Unlike .requires, a contract violation stops further processing // -#line 169 "reflect.h2" +#line 175 "reflect.h2" auto compiler_services::report_violation(auto const& msg) const& -> void{ error(msg); throw(std::runtime_error( @@ -1594,12 +1600,13 @@ auto newline_pos{CPP2_UFCS(find)(source, '\n')}; )); } -#line 177 "reflect.h2" +#line 183 "reflect.h2" [[nodiscard]] auto compiler_services::is_active() const& -> auto { return true; } compiler_services::~compiler_services() noexcept{} compiler_services::compiler_services(compiler_services const& that) : errors{ that.errors } + , includes{ that.includes } , errors_original_size{ that.errors_original_size } , generated_tokens{ that.generated_tokens } , parser{ that.parser } @@ -1607,7 +1614,7 @@ compiler_services::compiler_services(compiler_services const& that) , metafunction_args{ that.metafunction_args } , metafunctions_used{ that.metafunctions_used }{} -#line 181 "reflect.h2" +#line 187 "reflect.h2" /* //----------------------------------------------------------------------- // @@ -1644,7 +1651,7 @@ type_id: @polymorphic_base @copyable type = } */ -#line 218 "reflect.h2" +#line 224 "reflect.h2" //----------------------------------------------------------------------- // // Declarations @@ -1655,7 +1662,7 @@ type_id: @polymorphic_base @copyable type = // All declarations are wrappers around a pointer to node // -#line 233 "reflect.h2" +#line 239 "reflect.h2" declaration_base::declaration_base( declaration_node* n_, @@ -1663,17 +1670,17 @@ type_id: @polymorphic_base @copyable type = ) : compiler_services{ s } , n{ n_ } -#line 238 "reflect.h2" +#line 244 "reflect.h2" { -#line 241 "reflect.h2" +#line 247 "reflect.h2" if (cpp2::cpp2_default.is_active() && !(n) ) { cpp2::cpp2_default.report_violation(CPP2_CONTRACT_MSG("a meta::declaration must point to a valid declaration_node, not null")); } } -#line 244 "reflect.h2" +#line 250 "reflect.h2" [[nodiscard]] auto declaration_base::position() const -> source_position { return CPP2_UFCS(position)((*cpp2::impl::assert_not_null(n))); } -#line 246 "reflect.h2" +#line 252 "reflect.h2" [[nodiscard]] auto declaration_base::print() const& -> std::string { return CPP2_UFCS(pretty_print_visualize)((*cpp2::impl::assert_not_null(n)), 0); } declaration_base::~declaration_base() noexcept{} @@ -1681,126 +1688,126 @@ declaration_base::declaration_base(declaration_base const& that) : compiler_services{ static_cast(that) } , n{ that.n }{} -#line 250 "reflect.h2" +#line 256 "reflect.h2" //----------------------------------------------------------------------- // All declarations // -#line 257 "reflect.h2" +#line 263 "reflect.h2" declaration::declaration( declaration_node* n_, cpp2::impl::in s ) : declaration_base{ n_, s } -#line 262 "reflect.h2" +#line 268 "reflect.h2" { } -#line 266 "reflect.h2" +#line 272 "reflect.h2" [[nodiscard]] auto declaration::is_public() const& -> bool { return CPP2_UFCS(is_public)((*cpp2::impl::assert_not_null(n))); } -#line 267 "reflect.h2" +#line 273 "reflect.h2" [[nodiscard]] auto declaration::is_protected() const& -> bool { return CPP2_UFCS(is_protected)((*cpp2::impl::assert_not_null(n))); } -#line 268 "reflect.h2" +#line 274 "reflect.h2" [[nodiscard]] auto declaration::is_private() const& -> bool { return CPP2_UFCS(is_private)((*cpp2::impl::assert_not_null(n))); } -#line 269 "reflect.h2" +#line 275 "reflect.h2" [[nodiscard]] auto declaration::is_default_access() const& -> bool { return CPP2_UFCS(is_default_access)((*cpp2::impl::assert_not_null(n))); } -#line 271 "reflect.h2" +#line 277 "reflect.h2" auto declaration::default_to_public() & -> void { static_cast(CPP2_UFCS(make_public)((*cpp2::impl::assert_not_null(n)))); } -#line 272 "reflect.h2" +#line 278 "reflect.h2" auto declaration::default_to_protected() & -> void { static_cast(CPP2_UFCS(make_protected)((*cpp2::impl::assert_not_null(n)))); } -#line 273 "reflect.h2" +#line 279 "reflect.h2" auto declaration::default_to_private() & -> void { static_cast(CPP2_UFCS(make_private)((*cpp2::impl::assert_not_null(n)))); } -#line 275 "reflect.h2" +#line 281 "reflect.h2" [[nodiscard]] auto declaration::make_public() & -> bool { return CPP2_UFCS(make_public)((*cpp2::impl::assert_not_null(n))); } -#line 276 "reflect.h2" +#line 282 "reflect.h2" [[nodiscard]] auto declaration::make_protected() & -> bool { return CPP2_UFCS(make_protected)((*cpp2::impl::assert_not_null(n))); } -#line 277 "reflect.h2" +#line 283 "reflect.h2" [[nodiscard]] auto declaration::make_private() & -> bool { return CPP2_UFCS(make_private)((*cpp2::impl::assert_not_null(n))); } -#line 279 "reflect.h2" +#line 285 "reflect.h2" [[nodiscard]] auto declaration::has_name() const& -> bool { return CPP2_UFCS(has_name)((*cpp2::impl::assert_not_null(n))); } -#line 280 "reflect.h2" +#line 286 "reflect.h2" [[nodiscard]] auto declaration::has_name(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_name)((*cpp2::impl::assert_not_null(n)), s); } -#line 282 "reflect.h2" +#line 288 "reflect.h2" [[nodiscard]] auto declaration::name() const& -> std::string_view{ if (has_name()) {return CPP2_UFCS(as_string_view)((*cpp2::impl::assert_not_null(CPP2_UFCS(name)(*cpp2::impl::assert_not_null(n))))); } else { return ""; } } -#line 287 "reflect.h2" +#line 293 "reflect.h2" [[nodiscard]] auto declaration::has_initializer() const& -> bool { return CPP2_UFCS(has_initializer)((*cpp2::impl::assert_not_null(n))); } -#line 289 "reflect.h2" +#line 295 "reflect.h2" [[nodiscard]] auto declaration::is_global() const& -> bool { return CPP2_UFCS(is_global)((*cpp2::impl::assert_not_null(n))); } -#line 290 "reflect.h2" +#line 296 "reflect.h2" [[nodiscard]] auto declaration::is_function() const& -> bool { return CPP2_UFCS(is_function)((*cpp2::impl::assert_not_null(n))); } -#line 291 "reflect.h2" +#line 297 "reflect.h2" [[nodiscard]] auto declaration::is_object() const& -> bool { return CPP2_UFCS(is_object)((*cpp2::impl::assert_not_null(n))); } -#line 292 "reflect.h2" +#line 298 "reflect.h2" [[nodiscard]] auto declaration::is_base_object() const& -> bool { return CPP2_UFCS(is_base_object)((*cpp2::impl::assert_not_null(n))); } -#line 293 "reflect.h2" +#line 299 "reflect.h2" [[nodiscard]] auto declaration::is_member_object() const& -> bool { return CPP2_UFCS(is_member_object)((*cpp2::impl::assert_not_null(n))); } -#line 294 "reflect.h2" +#line 300 "reflect.h2" [[nodiscard]] auto declaration::is_type() const& -> bool { return CPP2_UFCS(is_type)((*cpp2::impl::assert_not_null(n))); } -#line 295 "reflect.h2" +#line 301 "reflect.h2" [[nodiscard]] auto declaration::is_namespace() const& -> bool { return CPP2_UFCS(is_namespace)((*cpp2::impl::assert_not_null(n))); } -#line 296 "reflect.h2" +#line 302 "reflect.h2" [[nodiscard]] auto declaration::is_alias() const& -> bool { return CPP2_UFCS(is_alias)((*cpp2::impl::assert_not_null(n))); } -#line 298 "reflect.h2" +#line 304 "reflect.h2" [[nodiscard]] auto declaration::is_type_alias() const& -> bool { return CPP2_UFCS(is_type_alias)((*cpp2::impl::assert_not_null(n))); } -#line 299 "reflect.h2" +#line 305 "reflect.h2" [[nodiscard]] auto declaration::is_namespace_alias() const& -> bool { return CPP2_UFCS(is_namespace_alias)((*cpp2::impl::assert_not_null(n))); } -#line 300 "reflect.h2" +#line 306 "reflect.h2" [[nodiscard]] auto declaration::is_object_alias() const& -> bool { return CPP2_UFCS(is_object_alias)((*cpp2::impl::assert_not_null(n))); } -#line 302 "reflect.h2" +#line 308 "reflect.h2" [[nodiscard]] auto declaration::is_function_expression() const& -> bool { return CPP2_UFCS(is_function_expression)((*cpp2::impl::assert_not_null(n))); } -#line 304 "reflect.h2" +#line 310 "reflect.h2" [[nodiscard]] auto declaration::as_function() const& -> function_declaration { return function_declaration(n, (*this)); } -#line 305 "reflect.h2" +#line 311 "reflect.h2" [[nodiscard]] auto declaration::as_object() const& -> object_declaration { return object_declaration(n, (*this)); } -#line 306 "reflect.h2" +#line 312 "reflect.h2" [[nodiscard]] auto declaration::as_type() const& -> type_declaration { return type_declaration(n, (*this)); } -#line 307 "reflect.h2" +#line 313 "reflect.h2" [[nodiscard]] auto declaration::as_alias() const& -> alias_declaration { return alias_declaration(n, (*this)); } -#line 309 "reflect.h2" +#line 315 "reflect.h2" [[nodiscard]] auto declaration::get_parent() const& -> declaration { return declaration((*cpp2::impl::assert_not_null(n)).parent_declaration, (*this)); } -#line 311 "reflect.h2" +#line 317 "reflect.h2" [[nodiscard]] auto declaration::parent_is_function() const& -> bool { return CPP2_UFCS(parent_is_function)((*cpp2::impl::assert_not_null(n))); } -#line 312 "reflect.h2" +#line 318 "reflect.h2" [[nodiscard]] auto declaration::parent_is_object() const& -> bool { return CPP2_UFCS(parent_is_object)((*cpp2::impl::assert_not_null(n))); } -#line 313 "reflect.h2" +#line 319 "reflect.h2" [[nodiscard]] auto declaration::parent_is_type() const& -> bool { return CPP2_UFCS(parent_is_type)((*cpp2::impl::assert_not_null(n))); } -#line 314 "reflect.h2" +#line 320 "reflect.h2" [[nodiscard]] auto declaration::parent_is_namespace() const& -> bool { return CPP2_UFCS(parent_is_namespace)((*cpp2::impl::assert_not_null(n))); } -#line 315 "reflect.h2" +#line 321 "reflect.h2" [[nodiscard]] auto declaration::parent_is_alias() const& -> bool { return CPP2_UFCS(parent_is_alias)((*cpp2::impl::assert_not_null(n))); } -#line 317 "reflect.h2" +#line 323 "reflect.h2" [[nodiscard]] auto declaration::parent_is_type_alias() const& -> bool { return CPP2_UFCS(parent_is_type_alias)((*cpp2::impl::assert_not_null(n))); } -#line 318 "reflect.h2" +#line 324 "reflect.h2" [[nodiscard]] auto declaration::parent_is_namespace_alias() const& -> bool { return CPP2_UFCS(parent_is_namespace_alias)((*cpp2::impl::assert_not_null(n))); } -#line 319 "reflect.h2" +#line 325 "reflect.h2" [[nodiscard]] auto declaration::parent_is_object_alias() const& -> bool { return CPP2_UFCS(parent_is_object_alias)((*cpp2::impl::assert_not_null(n))); } -#line 321 "reflect.h2" +#line 327 "reflect.h2" [[nodiscard]] auto declaration::parent_is_polymorphic() const& -> bool { return CPP2_UFCS(parent_is_polymorphic)((*cpp2::impl::assert_not_null(n))); } -#line 323 "reflect.h2" +#line 329 "reflect.h2" auto declaration::mark_for_removal_from_enclosing_type() & -> void // this precondition should be sufficient ... { if (cpp2::type_safety.is_active() && !(parent_is_type()) ) { cpp2::type_safety.report_violation(""); } -#line 326 "reflect.h2" +#line 332 "reflect.h2" auto test {CPP2_UFCS(type_member_mark_for_removal)((*cpp2::impl::assert_not_null(n)))}; if (cpp2::cpp2_default.is_active() && !(cpp2::move(test)) ) { cpp2::cpp2_default.report_violation(""); }// ... to ensure this assert is true } @@ -1809,93 +1816,93 @@ declaration_base::declaration_base(declaration_base const& that) declaration::declaration(declaration const& that) : declaration_base{ static_cast(that) }{} -#line 332 "reflect.h2" +#line 338 "reflect.h2" //----------------------------------------------------------------------- // Function declarations // -#line 339 "reflect.h2" +#line 345 "reflect.h2" function_declaration::function_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 344 "reflect.h2" +#line 350 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_function)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } } -#line 349 "reflect.h2" +#line 355 "reflect.h2" [[nodiscard]] auto function_declaration::index_of_parameter_named(cpp2::impl::in s) const& -> int { return CPP2_UFCS(index_of_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 350 "reflect.h2" +#line 356 "reflect.h2" [[nodiscard]] auto function_declaration::has_parameter_named(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 351 "reflect.h2" +#line 357 "reflect.h2" [[nodiscard]] auto function_declaration::has_in_parameter_named(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_in_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 352 "reflect.h2" +#line 358 "reflect.h2" [[nodiscard]] auto function_declaration::has_copy_parameter_named(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_copy_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 353 "reflect.h2" +#line 359 "reflect.h2" [[nodiscard]] auto function_declaration::has_inout_parameter_named(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_inout_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 354 "reflect.h2" +#line 360 "reflect.h2" [[nodiscard]] auto function_declaration::has_out_parameter_named(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_out_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 355 "reflect.h2" +#line 361 "reflect.h2" [[nodiscard]] auto function_declaration::has_move_parameter_named(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_move_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 356 "reflect.h2" +#line 362 "reflect.h2" [[nodiscard]] auto function_declaration::has_forward_parameter_named(cpp2::impl::in s) const& -> bool { return CPP2_UFCS(has_forward_parameter_named)((*cpp2::impl::assert_not_null(n)), s); } -#line 357 "reflect.h2" +#line 363 "reflect.h2" [[nodiscard]] auto function_declaration::first_parameter_name() const& -> std::string { return CPP2_UFCS(first_parameter_name)((*cpp2::impl::assert_not_null(n))); } -#line 359 "reflect.h2" +#line 365 "reflect.h2" [[nodiscard]] auto function_declaration::has_parameter_with_name_and_pass(cpp2::impl::in s, cpp2::impl::in pass) const& -> bool { return CPP2_UFCS(has_parameter_with_name_and_pass)((*cpp2::impl::assert_not_null(n)), s, pass); } -#line 361 "reflect.h2" +#line 367 "reflect.h2" [[nodiscard]] auto function_declaration::is_function_with_this() const& -> bool { return CPP2_UFCS(is_function_with_this)((*cpp2::impl::assert_not_null(n))); } -#line 362 "reflect.h2" +#line 368 "reflect.h2" [[nodiscard]] auto function_declaration::is_virtual() const& -> bool { return CPP2_UFCS(is_virtual_function)((*cpp2::impl::assert_not_null(n))); } -#line 363 "reflect.h2" +#line 369 "reflect.h2" [[nodiscard]] auto function_declaration::is_defaultable() const& -> bool { return CPP2_UFCS(is_defaultable_function)((*cpp2::impl::assert_not_null(n))); } -#line 364 "reflect.h2" +#line 370 "reflect.h2" [[nodiscard]] auto function_declaration::is_constructor() const& -> bool { return CPP2_UFCS(is_constructor)((*cpp2::impl::assert_not_null(n))); } -#line 365 "reflect.h2" +#line 371 "reflect.h2" [[nodiscard]] auto function_declaration::is_default_constructor() const& -> bool { return CPP2_UFCS(is_default_constructor)((*cpp2::impl::assert_not_null(n))); } -#line 366 "reflect.h2" +#line 372 "reflect.h2" [[nodiscard]] auto function_declaration::is_move() const& -> bool { return CPP2_UFCS(is_move)((*cpp2::impl::assert_not_null(n))); } -#line 367 "reflect.h2" +#line 373 "reflect.h2" [[nodiscard]] auto function_declaration::is_swap() const& -> bool { return CPP2_UFCS(is_swap)((*cpp2::impl::assert_not_null(n))); } -#line 368 "reflect.h2" +#line 374 "reflect.h2" [[nodiscard]] auto function_declaration::is_constructor_with_that() const& -> bool { return CPP2_UFCS(is_constructor_with_that)((*cpp2::impl::assert_not_null(n))); } -#line 369 "reflect.h2" +#line 375 "reflect.h2" [[nodiscard]] auto function_declaration::is_constructor_with_in_that() const& -> bool { return CPP2_UFCS(is_constructor_with_in_that)((*cpp2::impl::assert_not_null(n))); } -#line 370 "reflect.h2" +#line 376 "reflect.h2" [[nodiscard]] auto function_declaration::is_constructor_with_move_that() const& -> bool { return CPP2_UFCS(is_constructor_with_move_that)((*cpp2::impl::assert_not_null(n))); } -#line 371 "reflect.h2" +#line 377 "reflect.h2" [[nodiscard]] auto function_declaration::is_assignment() const& -> bool { return CPP2_UFCS(is_assignment)((*cpp2::impl::assert_not_null(n))); } -#line 372 "reflect.h2" +#line 378 "reflect.h2" [[nodiscard]] auto function_declaration::is_assignment_with_that() const& -> bool { return CPP2_UFCS(is_assignment_with_that)((*cpp2::impl::assert_not_null(n))); } -#line 373 "reflect.h2" +#line 379 "reflect.h2" [[nodiscard]] auto function_declaration::is_assignment_with_in_that() const& -> bool { return CPP2_UFCS(is_assignment_with_in_that)((*cpp2::impl::assert_not_null(n))); } -#line 374 "reflect.h2" +#line 380 "reflect.h2" [[nodiscard]] auto function_declaration::is_assignment_with_move_that() const& -> bool { return CPP2_UFCS(is_assignment_with_move_that)((*cpp2::impl::assert_not_null(n))); } -#line 375 "reflect.h2" +#line 381 "reflect.h2" [[nodiscard]] auto function_declaration::is_destructor() const& -> bool { return CPP2_UFCS(is_destructor)((*cpp2::impl::assert_not_null(n))); } -#line 377 "reflect.h2" +#line 383 "reflect.h2" [[nodiscard]] auto function_declaration::is_copy_or_move() const& -> bool { return is_constructor_with_that() || is_assignment_with_that(); } -#line 379 "reflect.h2" +#line 385 "reflect.h2" [[nodiscard]] auto function_declaration::has_declared_return_type() const& -> bool { return CPP2_UFCS(has_declared_return_type)((*cpp2::impl::assert_not_null(n))); } -#line 380 "reflect.h2" +#line 386 "reflect.h2" [[nodiscard]] auto function_declaration::has_deduced_return_type() const& -> bool { return CPP2_UFCS(has_deduced_return_type)((*cpp2::impl::assert_not_null(n))); } -#line 381 "reflect.h2" +#line 387 "reflect.h2" [[nodiscard]] auto function_declaration::has_bool_return_type() const& -> bool { return CPP2_UFCS(has_bool_return_type)((*cpp2::impl::assert_not_null(n))); } -#line 382 "reflect.h2" +#line 388 "reflect.h2" [[nodiscard]] auto function_declaration::has_non_void_return_type() const& -> bool { return CPP2_UFCS(has_non_void_return_type)((*cpp2::impl::assert_not_null(n))); } -#line 384 "reflect.h2" +#line 390 "reflect.h2" [[nodiscard]] auto function_declaration::unnamed_return_type() const& -> std::string { return CPP2_UFCS(unnamed_return_type_to_string)((*cpp2::impl::assert_not_null(n))); } -#line 386 "reflect.h2" +#line 392 "reflect.h2" [[nodiscard]] auto function_declaration::get_parameters() const& -> std::vector { @@ -1906,19 +1913,19 @@ declaration::declaration(declaration const& that) return ret; } -#line 396 "reflect.h2" +#line 402 "reflect.h2" [[nodiscard]] auto function_declaration::is_binary_comparison_function() const& -> bool { return CPP2_UFCS(is_binary_comparison_function)((*cpp2::impl::assert_not_null(n))); } -#line 398 "reflect.h2" +#line 404 "reflect.h2" auto function_declaration::default_to_virtual() & -> void { static_cast(CPP2_UFCS(make_function_virtual)((*cpp2::impl::assert_not_null(n)))); } -#line 400 "reflect.h2" +#line 406 "reflect.h2" [[nodiscard]] auto function_declaration::make_virtual() & -> bool { return CPP2_UFCS(make_function_virtual)((*cpp2::impl::assert_not_null(n))); } -#line 402 "reflect.h2" +#line 408 "reflect.h2" auto function_declaration::add_initializer(cpp2::impl::in source) & -> void -#line 405 "reflect.h2" +#line 411 "reflect.h2" { if ((*this).is_active() && !(!(has_initializer())) ) { (*this).report_violation(CPP2_CONTRACT_MSG("cannot add an initializer to a function that already has one")); } if ((*this).is_active() && !(parent_is_type()) ) { (*this).report_violation(CPP2_CONTRACT_MSG("cannot add an initializer to a function that isn't in a type scope")); } @@ -1927,7 +1934,7 @@ declaration::declaration(declaration const& that) //require( parent_is_type(), // "cannot add an initializer to a function that isn't in a type scope"); -#line 411 "reflect.h2" +#line 417 "reflect.h2" auto stmt {parse_statement(source)}; if (!((cpp2::impl::as_(stmt)))) { error("cannot add an initializer that is not a valid statement"); @@ -1940,30 +1947,30 @@ declaration::declaration(declaration const& that) function_declaration::function_declaration(function_declaration const& that) : declaration{ static_cast(that) }{} -#line 422 "reflect.h2" +#line 428 "reflect.h2" //----------------------------------------------------------------------- // Object declarations // -#line 429 "reflect.h2" +#line 435 "reflect.h2" object_declaration::object_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 434 "reflect.h2" +#line 440 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_object)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } } -#line 439 "reflect.h2" +#line 445 "reflect.h2" [[nodiscard]] auto object_declaration::is_const() const& -> bool { return CPP2_UFCS(is_const)((*cpp2::impl::assert_not_null(n))); } -#line 440 "reflect.h2" +#line 446 "reflect.h2" [[nodiscard]] auto object_declaration::has_wildcard_type() const& -> bool { return CPP2_UFCS(has_wildcard_type)((*cpp2::impl::assert_not_null(n))); } -#line 442 "reflect.h2" +#line 448 "reflect.h2" [[nodiscard]] auto object_declaration::type() const& -> std::string{ auto ret {CPP2_UFCS(object_type)((*cpp2::impl::assert_not_null(n)))}; require(!(contains(ret, "(*ERROR*)")), @@ -1971,7 +1978,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 449 "reflect.h2" +#line 455 "reflect.h2" [[nodiscard]] auto object_declaration::initializer() const& -> std::string{ auto ret {CPP2_UFCS(object_initializer)((*cpp2::impl::assert_not_null(n)))}; require(!(contains(ret, "(*ERROR*)")), @@ -1982,25 +1989,25 @@ declaration::declaration(declaration const& that) object_declaration::object_declaration(object_declaration const& that) : declaration{ static_cast(that) }{} -#line 458 "reflect.h2" +#line 464 "reflect.h2" //----------------------------------------------------------------------- // Type declarations // -#line 465 "reflect.h2" +#line 471 "reflect.h2" type_declaration::type_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 470 "reflect.h2" +#line 476 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_type)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } } -#line 475 "reflect.h2" +#line 481 "reflect.h2" auto type_declaration::reserve_names(cpp2::impl::in name, auto&& ...etc) const& -> void { // etc is not declared ':string_view' for compatibility with GCC 10.x for ( @@ -2015,14 +2022,14 @@ declaration::declaration(declaration const& that) } } -#line 489 "reflect.h2" +#line 495 "reflect.h2" [[nodiscard]] auto type_declaration::is_polymorphic() const& -> bool { return CPP2_UFCS(is_polymorphic)((*cpp2::impl::assert_not_null(n))); } -#line 490 "reflect.h2" +#line 496 "reflect.h2" [[nodiscard]] auto type_declaration::is_final() const& -> bool { return CPP2_UFCS(is_type_final)((*cpp2::impl::assert_not_null(n))); } -#line 491 "reflect.h2" +#line 497 "reflect.h2" [[nodiscard]] auto type_declaration::make_final() & -> bool { return CPP2_UFCS(make_type_final)((*cpp2::impl::assert_not_null(n))); } -#line 493 "reflect.h2" +#line 499 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_functions() const& -> std::vector { @@ -2034,7 +2041,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 504 "reflect.h2" +#line 510 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_functions_needing_initializer() const& -> std::vector { @@ -2050,7 +2057,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 519 "reflect.h2" +#line 525 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_objects() const& -> std::vector { @@ -2061,7 +2068,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 529 "reflect.h2" +#line 535 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_types() const& -> std::vector { @@ -2072,7 +2079,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 539 "reflect.h2" +#line 545 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_aliases() const& -> std::vector { @@ -2083,7 +2090,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 549 "reflect.h2" +#line 555 "reflect.h2" [[nodiscard]] auto type_declaration::get_members() const& -> std::vector { @@ -2094,16 +2101,16 @@ declaration::declaration(declaration const& that) return ret; } -#line 559 "reflect.h2" +#line 565 "reflect.h2" [[nodiscard]] auto type_declaration::query_declared_value_set_functions() const& -> query_declared_value_set_functions_ret -#line 566 "reflect.h2" +#line 572 "reflect.h2" { cpp2::impl::deferred_init out_this_in_that; cpp2::impl::deferred_init out_this_move_that; cpp2::impl::deferred_init inout_this_in_that; cpp2::impl::deferred_init inout_this_move_that; -#line 567 "reflect.h2" +#line 573 "reflect.h2" auto declared {CPP2_UFCS(find_declared_value_set_functions)((*cpp2::impl::assert_not_null(n)))}; out_this_in_that.construct(declared.out_this_in_that != nullptr); out_this_move_that.construct(declared.out_this_move_that != nullptr); @@ -2111,7 +2118,7 @@ declaration::declaration(declaration const& that) 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()) }; } -#line 574 "reflect.h2" +#line 580 "reflect.h2" auto type_declaration::add_member(cpp2::impl::in source) & -> void { auto decl {parse_statement(source)}; @@ -2126,30 +2133,30 @@ declaration::declaration(declaration const& that) std::string("unexpected error while attempting to add member:\n") + source); } -#line 588 "reflect.h2" +#line 594 "reflect.h2" auto type_declaration::remove_marked_members() & -> void { CPP2_UFCS(type_remove_marked_members)((*cpp2::impl::assert_not_null(n))); } -#line 589 "reflect.h2" +#line 595 "reflect.h2" auto type_declaration::remove_all_members() & -> void { CPP2_UFCS(type_remove_all_members)((*cpp2::impl::assert_not_null(n))); } -#line 591 "reflect.h2" +#line 597 "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 595 "reflect.h2" +#line 601 "reflect.h2" //----------------------------------------------------------------------- // Alias declarations // -#line 602 "reflect.h2" +#line 608 "reflect.h2" alias_declaration::alias_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 607 "reflect.h2" +#line 613 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_alias)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } @@ -2158,7 +2165,7 @@ declaration::declaration(declaration const& that) alias_declaration::alias_declaration(alias_declaration const& that) : declaration{ static_cast(that) }{} -#line 614 "reflect.h2" +#line 620 "reflect.h2" //----------------------------------------------------------------------- // // Metafunctions - these are hardwired for now until we get to the @@ -2171,13 +2178,13 @@ declaration::declaration(declaration const& that) // Some common metafunction helpers (metafunctions are just functions, // so they can be factored as usual) // -#line 626 "reflect.h2" +#line 632 "reflect.h2" auto add_virtual_destructor(meta::type_declaration& t) -> void { CPP2_UFCS(add_member)(t, "operator=: (virtual move this) = { }"); } -#line 632 "reflect.h2" +#line 638 "reflect.h2" //----------------------------------------------------------------------- // // "... an abstract base class defines an interface ..." @@ -2190,7 +2197,7 @@ auto add_virtual_destructor(meta::type_declaration& t) -> void // // an abstract base class having only pure virtual functions // -#line 644 "reflect.h2" +#line 650 "reflect.h2" auto interface(meta::type_declaration& t) -> void { auto has_dtor {false}; @@ -2217,7 +2224,7 @@ auto interface(meta::type_declaration& t) -> void } } -#line 671 "reflect.h2" +#line 677 "reflect.h2" //----------------------------------------------------------------------- // // "C.35: A base class destructor should be either public and @@ -2237,7 +2244,7 @@ auto interface(meta::type_declaration& t) -> void // // Unlike an interface, it can have nonpublic and nonvirtual functions. // -#line 690 "reflect.h2" +#line 696 "reflect.h2" auto polymorphic_base(meta::type_declaration& t) -> void { auto has_dtor {false}; @@ -2262,7 +2269,7 @@ auto polymorphic_base(meta::type_declaration& t) -> void } } -#line 715 "reflect.h2" +#line 721 "reflect.h2" //----------------------------------------------------------------------- // // "... A totally ordered type ... requires operator<=> that @@ -2283,7 +2290,7 @@ auto polymorphic_base(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // -#line 735 "reflect.h2" +#line 741 "reflect.h2" auto ordered_impl( meta::type_declaration& t, cpp2::impl::in ordering// must be "strong_ordering" etc. @@ -2313,7 +2320,7 @@ auto ordered_impl( // // Note: the ordering that should be encouraged as default gets the nice name // -#line 764 "reflect.h2" +#line 770 "reflect.h2" auto ordered(meta::type_declaration& t) -> void { ordered_impl(t, "strong_ordering"); @@ -2322,7 +2329,7 @@ auto ordered(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // weakly_ordered - a weakly ordered type // -#line 772 "reflect.h2" +#line 778 "reflect.h2" auto weakly_ordered(meta::type_declaration& t) -> void { ordered_impl(t, "weak_ordering"); @@ -2331,13 +2338,13 @@ auto weakly_ordered(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // partially_ordered - a partially ordered type // -#line 780 "reflect.h2" +#line 786 "reflect.h2" auto partially_ordered(meta::type_declaration& t) -> void { ordered_impl(t, "partial_ordering"); } -#line 786 "reflect.h2" +#line 792 "reflect.h2" //----------------------------------------------------------------------- // // "A value is ... a regular type. It must have all public @@ -2354,7 +2361,7 @@ auto partially_ordered(meta::type_declaration& t) -> void // // A type with (copy and move) x (construction and assignment) // -#line 802 "reflect.h2" +#line 808 "reflect.h2" auto copyable(meta::type_declaration& t) -> void { // If the user explicitly wrote any of the copy/move functions, @@ -2389,7 +2396,7 @@ auto copyable(meta::type_declaration& t) -> void // A regular type: copyable, plus has public default construction // and no protected or virtual functions // -#line 836 "reflect.h2" +#line 842 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void { CPP2_UFCS(copyable)(t); @@ -2418,28 +2425,28 @@ auto basic_value(meta::type_declaration& t) -> void // // Note: the ordering that should be encouraged as default gets the nice name // -#line 864 "reflect.h2" +#line 870 "reflect.h2" auto value(meta::type_declaration& t) -> void { CPP2_UFCS(ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 870 "reflect.h2" +#line 876 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(weakly_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 876 "reflect.h2" +#line 882 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(partially_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 883 "reflect.h2" +#line 889 "reflect.h2" //----------------------------------------------------------------------- // // C.20: If you can avoid defining default operations, do @@ -2462,7 +2469,7 @@ auto partially_ordered_value(meta::type_declaration& t) -> void // // a type without declared copy/move/destructor functions // -#line 905 "reflect.h2" +#line 911 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void { for ( auto& mf : CPP2_UFCS(get_member_functions)(t) ) @@ -2500,7 +2507,7 @@ auto cpp1_rule_of_zero(meta::type_declaration& t) -> void // no virtual functions, and no user-defined constructors // (i.e., no invariants) or assignment or destructors. // -#line 942 "reflect.h2" +#line 948 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void { std::string ctor_params {}; @@ -2552,7 +2559,7 @@ value_member_info::value_member_info(auto const& name_, auto const& type_, auto , type{ type_ } , value{ value_ }{} -#line 989 "reflect.h2" +#line 995 "reflect.h2" //----------------------------------------------------------------------- // // "C enumerations constitute a curiously half-baked concept. ... @@ -2571,7 +2578,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 1012 "reflect.h2" +#line 1018 "reflect.h2" auto basic_enum( meta::type_declaration& t, auto const& nextval, @@ -2596,7 +2603,7 @@ auto basic_enum( { std::string value{"-1"}; -#line 1035 "reflect.h2" +#line 1041 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) if ( CPP2_UFCS(is_member_object)(m)) @@ -2638,7 +2645,7 @@ std::string value{"-1"}; } } -#line 1075 "reflect.h2" +#line 1081 "reflect.h2" if ((CPP2_UFCS(empty)(enumerators))) { CPP2_UFCS(error)(t, "an enumeration must contain at least one enumerator value"); return ; @@ -2689,7 +2696,7 @@ std::string value{"-1"}; } } -#line 1126 "reflect.h2" +#line 1132 "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' @@ -2739,7 +2746,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 1173 "reflect.h2" +#line 1179 "reflect.h2" { if (bitwise) { to_string_impl += ", separator: std::string_view ) -> std::string = { \n" @@ -2780,7 +2787,7 @@ std::string to_string_impl{" to_string_impl: (this, prefix: std::string_view" } } -#line 1212 "reflect.h2" +#line 1218 "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)) + "::\", \" | \" );"); @@ -2794,7 +2801,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ // Provide a 'from_string' function to parse strings into enumerators -#line 1223 "reflect.h2" +#line 1229 "reflect.h2" { std::string_view prefix {""}; std::string_view combine_op {"return"}; @@ -2816,7 +2823,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ { std::string_view else_{""}; -#line 1243 "reflect.h2" +#line 1249 "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"; @@ -2824,7 +2831,7 @@ std::string_view else_{""}; } } -#line 1249 "reflect.h2" +#line 1255 "reflect.h2" if (bitwise) { from_string += " else { break outer; }\n" " }\n" @@ -2840,11 +2847,11 @@ std::string_view else_{""}; } } -#line 1263 "reflect.h2" +#line 1269 "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 1267 "reflect.h2" +#line 1273 "reflect.h2" //----------------------------------------------------------------------- // // "An enum[...] is a totally ordered value type that stores a @@ -2854,7 +2861,7 @@ std::string_view else_{""}; // // -- P0707R4, section 3 // -#line 1276 "reflect.h2" +#line 1282 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with an incrementing value generator @@ -2871,7 +2878,7 @@ auto cpp2_enum(meta::type_declaration& t) -> void ); } -#line 1293 "reflect.h2" +#line 1299 "reflect.h2" //----------------------------------------------------------------------- // // "flag_enum expresses an enumeration that stores values @@ -2882,7 +2889,7 @@ auto cpp2_enum(meta::type_declaration& t) -> void // // -- P0707R4, section 3 // -#line 1303 "reflect.h2" +#line 1309 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with a power-of-two value generator @@ -2904,7 +2911,7 @@ auto flag_enum(meta::type_declaration& t) -> void ); } -#line 1325 "reflect.h2" +#line 1331 "reflect.h2" //----------------------------------------------------------------------- // // "As with void*, programmers should know that unions [...] are @@ -2929,7 +2936,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 1349 "reflect.h2" +#line 1355 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void { std::vector alternatives {}; @@ -2938,7 +2945,7 @@ auto value{0}; // 1. Gather: All the user-written members, and find/compute the max size -#line 1356 "reflect.h2" +#line 1362 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) { do @@ -2968,7 +2975,7 @@ auto value{0}; } while (false); ++value; } } -#line 1384 "reflect.h2" +#line 1390 "reflect.h2" std::string discriminator_type {}; if (cpp2::impl::cmp_less(CPP2_UFCS(ssize)(alternatives),std::numeric_limits::max())) { discriminator_type = "i8"; @@ -2983,7 +2990,7 @@ auto value{0}; discriminator_type = "i64"; }}} -#line 1399 "reflect.h2" +#line 1405 "reflect.h2" // 2. Replace: Erase the contents and replace with modified contents CPP2_UFCS(remove_marked_members)(t); @@ -2992,7 +2999,7 @@ std::string storage{" _storage: cpp2::aligned_storage t) -> void { std::cout << CPP2_UFCS(print)(t) << "\n"; } -#line 1506 "reflect.h2" -//----------------------------------------------------------------------- -// -// regex - creates regular expressions from members -// -// Each member that starts with `regex` is replaced by a regular expression -// of the initializer string. E.g.: -// ``` -// regex := "ab"; -// ``` -// is replaced with -// ``` -// regex := ::cpp2::regex::regular_expression<...>; -// ``` -// -using namespace cpp2::regex; - constexpr expression_flags::expression_flags(cpp2::impl::in _val) : _value{ cpp2::unsafe_narrow(_val) } { } @@ -3214,11 +3204,27 @@ 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 1523 "reflect.h2" +#line 1512 "reflect.h2" +//----------------------------------------------------------------------- +// +// regex - creates regular expressions from members +// +// Each member that starts with `regex` is replaced by a regular expression +// of the initializer string. E.g.: +// ``` +// regex := "ab"; +// ``` +// is replaced with +// ``` +// regex := ::cpp2::regex::regular_expression<...>; +// ``` +// + +#line 1528 "reflect.h2" // Possible modifiers for a regular expression. // -#line 1527 "reflect.h2" +#line 1532 "reflect.h2" // mod: i // mod: m // mod: s @@ -3226,106 +3232,106 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov // mod: x // mod: xx -#line 1536 "reflect.h2" +#line 1541 "reflect.h2" // Tokens for regular expressions. // // Basic class for a regex token. // -#line 1545 "reflect.h2" +#line 1550 "reflect.h2" regex_token::regex_token(cpp2::impl::in str) : string_rep{ str }{ -#line 1547 "reflect.h2" +#line 1552 "reflect.h2" } -#line 1549 "reflect.h2" +#line 1554 "reflect.h2" regex_token::regex_token() : string_rep{ "" }{ -#line 1551 "reflect.h2" +#line 1556 "reflect.h2" } //parse: (inout ctx: parse_context) -> token_ptr; // Generate the matching code. -#line 1556 "reflect.h2" +#line 1561 "reflect.h2" auto regex_token::add_groups([[maybe_unused]] std::set& unnamed_param_2) const -> void{}// Adds all group indices to the set. -#line 1557 "reflect.h2" +#line 1562 "reflect.h2" [[nodiscard]] auto regex_token::to_string() const& -> std::string{return string_rep; }// Create a string representation. -#line 1558 "reflect.h2" +#line 1563 "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 1573 "reflect.h2" +#line 1578 "reflect.h2" regex_token_check::regex_token_check(cpp2::impl::in str, cpp2::impl::in check_) : regex_token{ str } , check{ check_ }{ -#line 1576 "reflect.h2" +#line 1581 "reflect.h2" } -#line 1578 "reflect.h2" +#line 1583 "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 1592 "reflect.h2" +#line 1597 "reflect.h2" regex_token_code::regex_token_code(cpp2::impl::in str, cpp2::impl::in code_) : regex_token{ str } , code{ code_ }{ -#line 1595 "reflect.h2" +#line 1600 "reflect.h2" } -#line 1597 "reflect.h2" +#line 1602 "reflect.h2" auto regex_token_code::generate_code(generation_context& ctx) const -> void{ ctx.add(code); } regex_token_code::~regex_token_code() noexcept{} -#line 1609 "reflect.h2" +#line 1614 "reflect.h2" regex_token_empty::regex_token_empty(cpp2::impl::in str) : regex_token{ str }{ -#line 1611 "reflect.h2" +#line 1616 "reflect.h2" } -#line 1613 "reflect.h2" +#line 1618 "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 1627 "reflect.h2" +#line 1632 "reflect.h2" regex_token_list::regex_token_list(cpp2::impl::in t) : regex_token{ gen_string(t) } , tokens{ t }{ -#line 1630 "reflect.h2" +#line 1635 "reflect.h2" } -#line 1632 "reflect.h2" +#line 1637 "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 1638 "reflect.h2" +#line 1643 "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 1644 "reflect.h2" +#line 1649 "reflect.h2" [[nodiscard]] auto regex_token_list::gen_string(cpp2::impl::in vec) -> std::string{ std::string r {""}; for ( auto const& token : vec ) { @@ -3336,7 +3342,7 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov regex_token_list::~regex_token_list() noexcept{} -#line 1667 "reflect.h2" +#line 1672 "reflect.h2" auto parse_context_group_state::next_alternative() & -> void{ token_vec new_list {}; std::swap(new_list, cur_match_list); @@ -3344,14 +3350,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 1675 "reflect.h2" +#line 1680 "reflect.h2" auto parse_context_group_state::swap(parse_context_group_state& t) & -> void{ std::swap(cur_match_list, t.cur_match_list); std::swap(alternate_match_lists, t.alternate_match_lists); std::swap(modifiers, t.modifiers); } -#line 1682 "reflect.h2" +#line 1687 "reflect.h2" [[nodiscard]] auto parse_context_group_state::get_as_token() & -> token_ptr{ if (alternate_match_lists.empty()) { post_process_list(cur_match_list); @@ -3363,15 +3369,15 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov } } -#line 1694 "reflect.h2" +#line 1699 "reflect.h2" auto parse_context_group_state::add(cpp2::impl::in token) & -> void{ cur_match_list.push_back(token); } -#line 1699 "reflect.h2" +#line 1704 "reflect.h2" [[nodiscard]] auto parse_context_group_state::empty() const& -> bool { return cur_match_list.empty(); } -#line 1703 "reflect.h2" +#line 1708 "reflect.h2" auto parse_context_group_state::post_process_list(token_vec& list) -> void{ // Merge all characters auto merge_pos {list.begin()}; @@ -3392,7 +3398,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 1729 "reflect.h2" +#line 1734 "reflect.h2" [[nodiscard]] auto parse_context_branch_reset_state::next() & -> int{ auto g {cur_group}; cur_group += 1; @@ -3401,20 +3407,20 @@ parse_context_group_state::parse_context_group_state(){} return g; } -#line 1738 "reflect.h2" +#line 1743 "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 1744 "reflect.h2" +#line 1749 "reflect.h2" auto parse_context_branch_reset_state::next_alternative() & -> void{ if (is_active) { cur_group = from; } } -#line 1751 "reflect.h2" +#line 1756 "reflect.h2" auto parse_context_branch_reset_state::set_active_reset(cpp2::impl::in restart) & -> void{ is_active = true; cur_group = restart; @@ -3429,16 +3435,16 @@ parse_context_group_state::parse_context_group_state(){} , from{ from_ }{} parse_context_branch_reset_state::parse_context_branch_reset_state(){} -#line 1779 "reflect.h2" +#line 1784 "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 1783 "reflect.h2" +#line 1788 "reflect.h2" } -#line 1789 "reflect.h2" +#line 1794 "reflect.h2" [[nodiscard]] auto parse_context::start_group() & -> parse_context_group_state { parse_context_group_state old_state {}; @@ -3448,7 +3454,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 1799 "reflect.h2" +#line 1804 "reflect.h2" [[nodiscard]] auto parse_context::end_group(cpp2::impl::in old_state) & -> token_ptr { auto inner {cur_group_state.get_as_token()}; @@ -3456,17 +3462,17 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return inner; } -#line 1806 "reflect.h2" +#line 1811 "reflect.h2" [[nodiscard]] auto parse_context::get_modifiers() const& -> expression_flags{ return cur_group_state.modifiers; } -#line 1810 "reflect.h2" +#line 1815 "reflect.h2" auto parse_context::set_modifiers(cpp2::impl::in mod) & -> void{ cur_group_state.modifiers = mod; } -#line 1817 "reflect.h2" +#line 1822 "reflect.h2" [[nodiscard]] auto parse_context::branch_reset_new_state() & -> parse_context_branch_reset_state { parse_context_branch_reset_state old_state {}; @@ -3476,7 +3482,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 1826 "reflect.h2" +#line 1831 "reflect.h2" auto parse_context::branch_reset_restore_state(cpp2::impl::in old_state) & -> void { auto max_group {cur_branch_reset_state.max_group}; @@ -3484,24 +3490,24 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} cur_branch_reset_state.set_next(cpp2::move(max_group)); } -#line 1833 "reflect.h2" +#line 1838 "reflect.h2" auto parse_context::next_alternative() & -> void { cur_group_state.next_alternative(); cur_branch_reset_state.next_alternative(); } -#line 1841 "reflect.h2" +#line 1846 "reflect.h2" auto parse_context::add_token(cpp2::impl::in token) & -> void{ cur_group_state.add(token); } -#line 1845 "reflect.h2" +#line 1850 "reflect.h2" [[nodiscard]] auto parse_context::has_token() const& -> bool{ return !(cur_group_state.empty()); } -#line 1849 "reflect.h2" +#line 1854 "reflect.h2" [[nodiscard]] auto parse_context::pop_token() & -> token_ptr { token_ptr r {nullptr}; @@ -3513,22 +3519,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 1860 "reflect.h2" +#line 1865 "reflect.h2" [[nodiscard]] auto parse_context::get_as_token() & -> token_ptr{ return root; } -#line 1866 "reflect.h2" +#line 1871 "reflect.h2" [[nodiscard]] auto parse_context::get_cur_group() const& -> int{ return cur_branch_reset_state.cur_group; } -#line 1870 "reflect.h2" +#line 1875 "reflect.h2" [[nodiscard]] auto parse_context::next_group() & -> int{ return cur_branch_reset_state.next(); } -#line 1874 "reflect.h2" +#line 1879 "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. @@ -3536,7 +3542,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1881 "reflect.h2" +#line 1886 "reflect.h2" [[nodiscard]] auto parse_context::get_named_group(cpp2::impl::in name) const& -> int { auto iter {named_groups.find(name)}; @@ -3548,10 +3554,10 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1894 "reflect.h2" +#line 1899 "reflect.h2" [[nodiscard]] auto parse_context::current() const& -> char{return CPP2_ASSERT_IN_BOUNDS(regex, pos); } -#line 1897 "reflect.h2" +#line 1902 "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}; @@ -3591,7 +3597,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cur; } -#line 1937 "reflect.h2" +#line 1942 "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); @@ -3603,14 +3609,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1948 "reflect.h2" +#line 1953 "reflect.h2" [[nodiscard]] auto parse_context::next() & -> auto { return next_impl(false, false); } -#line 1949 "reflect.h2" +#line 1954 "reflect.h2" [[nodiscard]] auto parse_context::next_in_class() & -> auto { return next_impl(true, false); } -#line 1950 "reflect.h2" +#line 1955 "reflect.h2" [[nodiscard]] auto parse_context::next_no_skip() & -> auto { return next_impl(false, true); } -#line 1952 "reflect.h2" +#line 1957 "reflect.h2" [[nodiscard]] auto parse_context::next_n(cpp2::impl::in n) & -> bool{ auto r {true}; auto cur {0}; @@ -3620,10 +3626,10 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 1961 "reflect.h2" +#line 1966 "reflect.h2" [[nodiscard]] auto parse_context::has_next() const& -> bool{return cpp2::impl::cmp_less(pos,regex.size()); } -#line 1963 "reflect.h2" +#line 1968 "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}; @@ -3645,14 +3651,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1984 "reflect.h2" +#line 1989 "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 1985 "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(std::string(1, e), cpp2::impl::out(&r), false); } -#line 1986 "reflect.h2" +#line 1991 "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 1988 "reflect.h2" +#line 1993 "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())) { @@ -3666,7 +3672,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2001 "reflect.h2" +#line 2006 "reflect.h2" [[nodiscard]] auto parse_context::grab_number() & -> std::string { auto start {pos}; @@ -3688,7 +3694,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cpp2::move(r.value()); } -#line 2022 "reflect.h2" +#line 2027 "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())) { @@ -3699,12 +3705,12 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2032 "reflect.h2" +#line 2037 "reflect.h2" [[nodiscard]] auto parse_context::peek() const& -> auto { return peek_impl(false); } -#line 2033 "reflect.h2" +#line 2038 "reflect.h2" [[nodiscard]] auto parse_context::peek_in_class() const& -> auto { return peek_impl(true); } -#line 2038 "reflect.h2" +#line 2043 "reflect.h2" [[nodiscard]] auto parse_context::parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool { auto is_negative {false}; @@ -3759,7 +3765,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 2092 "reflect.h2" +#line 2097 "reflect.h2" [[nodiscard]] auto parse_context::parse_until(cpp2::impl::in term) & -> bool{ token_ptr cur_token {}; @@ -3798,7 +3804,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 2130 "reflect.h2" +#line 2135 "reflect.h2" [[nodiscard]] auto parse_context::parse(cpp2::impl::in modifiers) & -> bool { @@ -3814,21 +3820,21 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 2147 "reflect.h2" +#line 2152 "reflect.h2" [[nodiscard]] auto parse_context::get_pos() const& -> auto { return pos; } -#line 2148 "reflect.h2" +#line 2153 "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 2149 "reflect.h2" +#line 2154 "reflect.h2" [[nodiscard]] auto parse_context::valid() const& -> bool{return has_next() && !(has_error); } -#line 2151 "reflect.h2" +#line 2156 "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 2166 "reflect.h2" +#line 2171 "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 ) { @@ -3836,7 +3842,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2173 "reflect.h2" +#line 2178 "reflect.h2" auto generation_function_context::remove_tabs(cpp2::impl::in c) & -> void{ tabs = tabs.substr(0, (cpp2::impl::as_(c)) * 2); } @@ -3846,22 +3852,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} , tabs{ tabs_ }{} generation_function_context::generation_function_context(){} -#line 2191 "reflect.h2" +#line 2196 "reflect.h2" [[nodiscard]] auto generation_context::match_parameters() const& -> std::string{return "r.pos, ctx"; } -#line 2196 "reflect.h2" +#line 2201 "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 2202 "reflect.h2" +#line 2207 "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 2208 "reflect.h2" +#line 2213 "reflect.h2" auto generation_context::add_statefull(cpp2::impl::in next_func, cpp2::impl::in check) & -> void { end_func_statefull(check); @@ -3870,7 +3876,7 @@ generation_function_context::generation_function_context(){} start_func_named(cpp2::move(name)); } -#line 2216 "reflect.h2" +#line 2221 "reflect.h2" auto generation_context::start_func_named(cpp2::impl::in name) & -> void { auto cur {new_context()}; @@ -3882,7 +3888,7 @@ generation_function_context::generation_function_context(){} (*cpp2::impl::assert_not_null(cpp2::move(cur))).add_tabs(3); } -#line 2227 "reflect.h2" +#line 2232 "reflect.h2" [[nodiscard]] auto generation_context::start_func() & -> std::string { auto name {gen_func_name()}; @@ -3890,7 +3896,7 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 2234 "reflect.h2" +#line 2239 "reflect.h2" auto generation_context::end_func_statefull(cpp2::impl::in s) & -> void { auto cur {get_current()}; @@ -3910,7 +3916,7 @@ generation_function_context::generation_function_context(){} finish_context(); } -#line 2254 "reflect.h2" +#line 2259 "reflect.h2" [[nodiscard]] auto generation_context::generate_func(cpp2::impl::in token) & -> std::string { auto name {start_func()}; @@ -3920,7 +3926,7 @@ generation_function_context::generation_function_context(){} return name; } -#line 2264 "reflect.h2" +#line 2269 "reflect.h2" [[nodiscard]] auto generation_context::generate_reset(cpp2::impl::in> groups) & -> std::string { if (groups.empty()) { @@ -3943,33 +3949,33 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 2288 "reflect.h2" +#line 2293 "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 2294 "reflect.h2" +#line 2299 "reflect.h2" [[nodiscard]] auto generation_context::next_func_name() & -> std::string{ return gen_func_name() + "()"; } -#line 2298 "reflect.h2" +#line 2303 "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 2304 "reflect.h2" +#line 2309 "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 2312 "reflect.h2" +#line 2317 "reflect.h2" [[nodiscard]] auto generation_context::new_context() & -> generation_function_context*{ gen_stack.push_back(generation_function_context()); auto cur {get_current()}; @@ -3978,7 +3984,7 @@ generation_function_context::generation_function_context(){} return cur; } -#line 2320 "reflect.h2" +#line 2325 "reflect.h2" auto generation_context::finish_context() & -> void{ auto cur {get_current()}; auto base {get_base()}; @@ -3987,22 +3993,22 @@ generation_function_context::generation_function_context(){} gen_stack.pop_back(); } -#line 2330 "reflect.h2" +#line 2335 "reflect.h2" [[nodiscard]] auto generation_context::get_current() & -> generation_function_context*{ return &gen_stack.back(); } -#line 2334 "reflect.h2" +#line 2339 "reflect.h2" [[nodiscard]] auto generation_context::get_base() & -> generation_function_context*{ return &CPP2_ASSERT_IN_BOUNDS_LITERAL(gen_stack, 0); } -#line 2338 "reflect.h2" +#line 2343 "reflect.h2" [[nodiscard]] auto generation_context::get_entry_func() const& -> std::string{ return entry_func; } -#line 2342 "reflect.h2" +#line 2347 "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"}; @@ -4026,18 +4032,18 @@ generation_function_context::generation_function_context(){} return res; } -#line 2367 "reflect.h2" +#line 2372 "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 2382 "reflect.h2" +#line 2387 "reflect.h2" alternative_token::alternative_token() : regex_token_empty{ "" }{} -#line 2384 "reflect.h2" +#line 2389 "reflect.h2" [[nodiscard]] auto alternative_token::parse(parse_context& ctx) -> token_ptr{ if (ctx.current() != '|') {return nullptr; } @@ -4048,15 +4054,15 @@ generation_function_context::generation_function_context(){} alternative_token::~alternative_token() noexcept{} -#line 2399 "reflect.h2" +#line 2404 "reflect.h2" alternative_token_gen::alternative_token_gen(cpp2::impl::in a) : regex_token{ gen_string(a) } , alternatives{ a }{ -#line 2402 "reflect.h2" +#line 2407 "reflect.h2" } -#line 2404 "reflect.h2" +#line 2409 "reflect.h2" auto alternative_token_gen::generate_code(generation_context& ctx) const -> void { std::string functions {""}; @@ -4074,7 +4080,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 2421 "reflect.h2" +#line 2426 "reflect.h2" auto alternative_token_gen::add_groups(std::set& groups) const -> void { for ( auto const& cur : alternatives ) { @@ -4082,7 +4088,7 @@ generation_function_context::generation_function_context(){} } } -#line 2428 "reflect.h2" +#line 2433 "reflect.h2" [[nodiscard]] auto alternative_token_gen::gen_string(cpp2::impl::in a) -> std::string { std::string r {""}; @@ -4098,14 +4104,14 @@ generation_function_context::generation_function_context(){} alternative_token_gen::~alternative_token_gen() noexcept{} -#line 2449 "reflect.h2" +#line 2454 "reflect.h2" any_token::any_token(cpp2::impl::in single_line) : regex_token_check{ ".", "any_token_matcher" }{ -#line 2451 "reflect.h2" +#line 2456 "reflect.h2" } -#line 2453 "reflect.h2" +#line 2458 "reflect.h2" [[nodiscard]] auto any_token::parse(parse_context& ctx) -> token_ptr{ if ('.' != ctx.current()) {return nullptr; } @@ -4114,21 +4120,21 @@ generation_function_context::generation_function_context(){} any_token::~any_token() noexcept{} -#line 2470 "reflect.h2" +#line 2475 "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 2474 "reflect.h2" +#line 2479 "reflect.h2" } -#line 2476 "reflect.h2" +#line 2481 "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 2480 "reflect.h2" +#line 2485 "reflect.h2" auto char_token::generate_code(generation_context& ctx) const -> void { if (ignore_case) { @@ -4137,14 +4143,14 @@ generation_function_context::generation_function_context(){} { size_t i{0}; -#line 2486 "reflect.h2" +#line 2491 "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 2491 "reflect.h2" +#line 2496 "reflect.h2" if (upper != lower) { gen_case_insensitive(cpp2::move(lower), cpp2::move(upper), ctx); } @@ -4157,7 +4163,7 @@ size_t i{0}; } } -#line 2503 "reflect.h2" +#line 2508 "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()) + ""}; @@ -4179,7 +4185,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 2524 "reflect.h2" +#line 2529 "reflect.h2" auto char_token::gen_case_sensitive(generation_context& ctx) const& -> void { std::string name {"str_" + cpp2::to_string(ctx.gen_temp()) + ""}; @@ -4198,7 +4204,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 2542 "reflect.h2" +#line 2547 "reflect.h2" [[nodiscard]] auto char_token::add_escapes(std::string str) const& -> std::string { str = string_util::replace_all(str, "\\", "\\\\"); @@ -4214,7 +4220,7 @@ size_t i{0}; return cpp2::move(str); } -#line 2557 "reflect.h2" +#line 2562 "reflect.h2" auto char_token::append(char_token const& that) & -> void{ (*this).token += that.token; (*this).string_rep += that.string_rep; @@ -4222,19 +4228,19 @@ size_t i{0}; char_token::~char_token() noexcept{} -#line 2574 "reflect.h2" +#line 2579 "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 2575 "reflect.h2" +#line 2580 "reflect.h2" { -#line 2580 "reflect.h2" +#line 2585 "reflect.h2" } -#line 2583 "reflect.h2" +#line 2588 "reflect.h2" [[nodiscard]] auto class_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '[') {return nullptr; } @@ -4360,13 +4366,13 @@ size_t i{0}; ); } -#line 2708 "reflect.h2" +#line 2713 "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 2713 "reflect.h2" +#line 2718 "reflect.h2" [[nodiscard]] auto class_token::create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string { auto sep {", "}; @@ -4377,12 +4383,12 @@ size_t i{0}; class_token::~class_token() noexcept{} -#line 2725 "reflect.h2" +#line 2730 "reflect.h2" [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } -#line 2730 "reflect.h2" +#line 2735 "reflect.h2" if (std::string::npos == std::string("afenrt^.[]()*{}?+|\\").find(ctx.peek())) { return nullptr; } @@ -4416,7 +4422,7 @@ size_t i{0}; } -#line 2766 "reflect.h2" +#line 2771 "reflect.h2" [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'K'))) {return nullptr; } @@ -4425,18 +4431,18 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, "\\K", "ctx..set_group_start(0, r.pos);"); } -#line 2788 "reflect.h2" +#line 2793 "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 2789 "reflect.h2" +#line 2794 "reflect.h2" { -#line 2793 "reflect.h2" +#line 2798 "reflect.h2" } -#line 2795 "reflect.h2" +#line 2800 "reflect.h2" [[nodiscard]] auto group_ref_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -4538,14 +4544,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 2896 "reflect.h2" +#line 2901 "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 2919 "reflect.h2" +#line 2924 "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 @@ -4560,7 +4566,7 @@ size_t i{0}; return r; } -#line 2933 "reflect.h2" +#line 2938 "reflect.h2" [[nodiscard]] auto group_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '(') {return nullptr; } @@ -4698,7 +4704,7 @@ size_t i{0}; } } -#line 3070 "reflect.h2" +#line 3075 "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 {"("}; @@ -4717,7 +4723,7 @@ size_t i{0}; return cpp2::move(start) + (*cpp2::impl::assert_not_null(inner_)).to_string() + ")"; } -#line 3088 "reflect.h2" +#line 3093 "reflect.h2" auto group_token::generate_code(generation_context& ctx) const -> void { if (-1 != number) { @@ -4738,7 +4744,7 @@ size_t i{0}; } } -#line 3108 "reflect.h2" +#line 3113 "reflect.h2" auto group_token::add_groups(std::set& groups) const -> void { (*cpp2::impl::assert_not_null(inner)).add_groups(groups); @@ -4749,7 +4755,7 @@ size_t i{0}; group_token::~group_token() noexcept{} -#line 3120 "reflect.h2" +#line 3125 "reflect.h2" [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'x'))) {return nullptr; } @@ -4788,7 +4794,7 @@ size_t i{0}; return r; } -#line 3161 "reflect.h2" +#line 3166 "reflect.h2" [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() == '$' || (ctx.current() == '\\' && ctx.peek() == '$')) { @@ -4806,7 +4812,7 @@ size_t i{0}; }} } -#line 3181 "reflect.h2" +#line 3186 "reflect.h2" [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '^' && !((ctx.current() == '\\' && ctx.peek() == 'A'))) {return nullptr; } @@ -4820,29 +4826,29 @@ size_t i{0}; } } -#line 3206 "reflect.h2" +#line 3211 "reflect.h2" lookahead_token::lookahead_token(cpp2::impl::in positive_) : regex_token{ "" } , positive{ positive_ }{ -#line 3208 "reflect.h2" +#line 3213 "reflect.h2" } -#line 3210 "reflect.h2" +#line 3215 "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 3216 "reflect.h2" +#line 3221 "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 3224 "reflect.h2" +#line 3229 "reflect.h2" [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -4868,7 +4874,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 3252 "reflect.h2" +#line 3257 "reflect.h2" [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'o'))) {return nullptr; } @@ -4894,11 +4900,11 @@ size_t i{0}; return r; } -#line 3289 "reflect.h2" +#line 3294 "reflect.h2" range_token::range_token() : regex_token{ "" }{} -#line 3291 "reflect.h2" +#line 3296 "reflect.h2" [[nodiscard]] auto range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -4972,7 +4978,7 @@ size_t i{0}; return nullptr; } -#line 3364 "reflect.h2" +#line 3369 "reflect.h2" auto range_token::parse_modifier(parse_context& ctx) & -> void { if (ctx.peek() == '?') { @@ -4985,7 +4991,7 @@ size_t i{0}; }} } -#line 3376 "reflect.h2" +#line 3381 "reflect.h2" [[nodiscard]] auto range_token::gen_mod_string() const& -> std::string { if (kind == range_flags::not_greedy) { @@ -4999,7 +5005,7 @@ size_t i{0}; }} } -#line 3389 "reflect.h2" +#line 3394 "reflect.h2" [[nodiscard]] auto range_token::gen_range_string() const& -> std::string { std::string r {""}; @@ -5019,7 +5025,7 @@ size_t i{0}; return r; } -#line 3408 "reflect.h2" +#line 3413 "reflect.h2" auto range_token::generate_code(generation_context& ctx) const -> void { auto inner_name {ctx.generate_func(inner_token)}; @@ -5031,14 +5037,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 3419 "reflect.h2" +#line 3424 "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 3432 "reflect.h2" +#line 3437 "reflect.h2" [[nodiscard]] auto special_range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -5062,7 +5068,7 @@ size_t i{0}; if (!(ctx.has_token())) {return ctx.error("'" + cpp2::to_string(ctx.current()) + "' without previous element."); } -#line 3456 "reflect.h2" +#line 3461 "reflect.h2" (*cpp2::impl::assert_not_null(r)).parse_modifier(ctx); (*cpp2::impl::assert_not_null(r)).inner_token = ctx.pop_token(); @@ -5072,7 +5078,7 @@ size_t i{0}; special_range_token::~special_range_token() noexcept{} -#line 3469 "reflect.h2" +#line 3474 "reflect.h2" [[nodiscard]] auto word_boundary_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -5090,15 +5096,15 @@ size_t i{0}; }} } -#line 3505 "reflect.h2" +#line 3510 "reflect.h2" template regex_generator::regex_generator(cpp2::impl::in r, Error_out const& e) : regex{ r } , error_out{ e }{ -#line 3508 "reflect.h2" +#line 3513 "reflect.h2" } -#line 3510 "reflect.h2" +#line 3515 "reflect.h2" template [[nodiscard]] auto regex_generator::parse() & -> std::string { // Extract modifiers and adapt regex. @@ -5134,7 +5140,7 @@ size_t i{0}; return source; } -#line 3545 "reflect.h2" +#line 3550 "reflect.h2" template auto regex_generator::extract_modifiers() & -> void { if (regex.find_first_of("'/") == 0) { @@ -5150,7 +5156,7 @@ size_t i{0}; } } -#line 3561 "reflect.h2" +#line 3566 "reflect.h2" template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string { regex_generator parser {regex, err}; @@ -5159,7 +5165,7 @@ template [[nodiscard]] auto generate_regex(cpp2::impl::in void { auto has_default {false}; @@ -5210,9 +5216,11 @@ auto regex_gen(meta::type_declaration& t) -> void CPP2_UFCS(add_member)(t, "public " + cpp2::to_string(expr.first) + ": cpp2::regex::regular_expression = ();"); } } + + CPP2_UFCS(add_runtime_support_include)(t, "cpp2regex.h"); } -#line 3628 "reflect.h2" +#line 3635 "reflect.h2" [[nodiscard]] auto apply_metafunctions( declaration_node& n, type_declaration& rtype, @@ -5327,7 +5335,7 @@ auto regex_gen(meta::type_declaration& t) -> void return true; } -#line 3743 "reflect.h2" +#line 3750 "reflect.h2" } } diff --git a/source/reflect.h2 b/source/reflect.h2 index 1557f7d4c9..e9830f4f8f 100644 --- a/source/reflect.h2 +++ b/source/reflect.h2 @@ -16,7 +16,8 @@ //=========================================================================== #include "parse.h" -#include "cpp2regex.h2" +#include "cpp2regex.h" +using namespace cpp2::regex; cpp2: namespace = { @@ -35,6 +36,7 @@ compiler_services: @polymorphic_base @copyable type = // Common data members // errors : *std::vector; + includes : *std::set; errors_original_size : int; generated_tokens : *stable_vector; parser : cpp2::parser; @@ -47,13 +49,15 @@ compiler_services: @polymorphic_base @copyable type = operator=: ( out this, errors_ : *std::vector, + includes_ : *std::set, generated_tokens_: *stable_vector ) = { - errors = errors_; + errors = errors_; + includes = includes_; errors_original_size = cpp2::unsafe_narrow(std::ssize(errors*)); - generated_tokens = generated_tokens_; - parser = errors*; + generated_tokens = generated_tokens_; + parser = (errors*, includes*); } // Common API @@ -134,6 +138,8 @@ compiler_services: @polymorphic_base @copyable type = } } + add_runtime_support_include: (inout this, s: std::string_view) = _=includes*.emplace( s ); + position: (virtual this) -> source_position = { @@ -1517,7 +1523,6 @@ print: (t: meta::type_declaration) = // regex := ::cpp2::regex::regular_expression<...>; // ``` // -using namespace cpp2::regex; error_func: type == std::function< (x: std::string) -> void >; // Possible modifiers for a regular expression. @@ -3618,6 +3623,8 @@ regex_gen: (inout t: meta::type_declaration) = t.add_member("public (expr.first)$: cpp2::regex::regular_expression = ();"); } } + + t.add_runtime_support_include( "cpp2regex.h" ); } diff --git a/source/sema.h b/source/sema.h index 8c54f3b0e3..a5888dae3f 100644 --- a/source/sema.h +++ b/source/sema.h @@ -29,7 +29,7 @@ auto parser::apply_type_metafunctions( declaration_node& n ) assert(n.is_type()); // Get the reflection state ready to pass to the function - auto cs = meta::compiler_services{ &errors, generated_tokens }; + auto cs = meta::compiler_services{ &errors, &includes, generated_tokens }; auto rtype = meta::type_declaration{ &n, cs }; return apply_metafunctions( diff --git a/source/to_cpp1.h b/source/to_cpp1.h index 011a1e0aca..9ee5be40dc 100644 --- a/source/to_cpp1.h +++ b/source/to_cpp1.h @@ -1014,6 +1014,7 @@ class cppfront { std::string sourcefile; std::vector errors; + std::set includes; // For building // @@ -1166,7 +1167,7 @@ class cppfront : sourcefile{ filename } , source { errors } , tokens { errors } - , parser { errors } + , parser { errors, includes } , sema { errors } { // "Constraints enable creativity in the right directions" @@ -1323,6 +1324,10 @@ class cppfront if (flag_no_rtti) { printer.print_extra( "#define CPP2_NO_RTTI Yes\n" ); } + + for (auto& h: includes) { + printer.print_extra( "#include \"" + h + "\"\n" ); + } } auto map_iter = tokens.get_map().cbegin();