diff --git a/include/cpp2regex.h b/include/cpp2regex.h index ee0fd2c543..27b4f2b9b3 100644 --- a/include/cpp2regex.h +++ b/include/cpp2regex.h @@ -149,7 +149,7 @@ template class match_context private: std::array,max_groups> groups {}; - public: explicit match_context(Iter const& begin_, Iter const& end_); + public: match_context(Iter const& begin_, Iter const& end_); #line 68 "cpp2regex.h2" public: match_context(match_context const& that); @@ -212,7 +212,7 @@ template class on_return { private: Func func; - public: explicit on_return(Func const& f); + public: on_return(Func const& f); #line 136 "cpp2regex.h2" public: auto operator=(Func const& f) -> on_return& ; @@ -577,7 +577,7 @@ template class regular_expression public: context ctx; public: int pos; - public: explicit search_return(cpp2::impl::in matched_, context const& ctx_, Iter const& pos_); + public: search_return(cpp2::impl::in matched_, context const& ctx_, Iter const& pos_); #line 690 "cpp2regex.h2" public: [[nodiscard]] auto group_number() const& -> decltype(auto); 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 af2fe25541..861317781c 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 @@ -1,4 +1,4 @@ -pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:36: error: expected ‘;’ at end of member declaration +pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:27: error: expected ‘;’ at end of member declaration In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cpp:7: ../../../include/cpp2util.h:10106: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_’ @@ -8,7 +8,7 @@ In file included from pure2-bugfix-for-requires-clause-in-forward-declaration.cp 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:112&&) requires is_convertible_v::type>::type, const std::__cxx11::add_const_t, std::allocator > >&>’ 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:110&&)’ +pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2:3:11: note: ‘template element::element(auto:110&&)’ 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:113&&) requires is_convertible_v::type>::type, const std::__cxx11::add_const_t, std::allocator > >&>’ diff --git a/regression-tests/test-results/pure2-bugfix-for-discard-precedence.cpp b/regression-tests/test-results/pure2-bugfix-for-discard-precedence.cpp index eccd841323..553c507e36 100644 --- a/regression-tests/test-results/pure2-bugfix-for-discard-precedence.cpp +++ b/regression-tests/test-results/pure2-bugfix-for-discard-precedence.cpp @@ -17,7 +17,7 @@ class quantity; class quantity { #line 2 "pure2-bugfix-for-discard-precedence.cpp2" private: cpp2::i32 number; - public: explicit quantity(cpp2::impl::in x); + public: quantity(cpp2::impl::in x); #line 3 "pure2-bugfix-for-discard-precedence.cpp2" public: auto operator=(cpp2::impl::in x) -> quantity& ; public: [[nodiscard]] auto operator+(quantity const& that) & -> quantity; diff --git a/regression-tests/test-results/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp b/regression-tests/test-results/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp index b0a265afa3..840ae9d29d 100644 --- a/regression-tests/test-results/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp +++ b/regression-tests/test-results/pure2-bugfix-for-requires-clause-in-forward-declaration.cpp @@ -17,7 +17,7 @@ class element; class element { #line 2 "pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2" private: std::string name; - public: explicit element(auto&& n) + public: element(auto&& n) CPP2_REQUIRES_ (std::is_convertible_v&>) ; #line 3 "pure2-bugfix-for-requires-clause-in-forward-declaration.cpp2" public: auto operator=(auto&& n) -> element& diff --git a/regression-tests/test-results/pure2-defaulted-comparisons-and-final-types.cpp b/regression-tests/test-results/pure2-defaulted-comparisons-and-final-types.cpp index bd5c9275a9..12b70a8523 100644 --- a/regression-tests/test-results/pure2-defaulted-comparisons-and-final-types.cpp +++ b/regression-tests/test-results/pure2-defaulted-comparisons-and-final-types.cpp @@ -21,7 +21,7 @@ class widget final { private: int v; - public: explicit widget(cpp2::impl::in value); + public: widget(cpp2::impl::in value); #line 6 "pure2-defaulted-comparisons-and-final-types.cpp2" public: auto operator=(cpp2::impl::in value) -> widget& ; diff --git a/regression-tests/test-results/pure2-last-use.cpp b/regression-tests/test-results/pure2-last-use.cpp index 992c82e9c2..40556c0f93 100644 --- a/regression-tests/test-results/pure2-last-use.cpp +++ b/regression-tests/test-results/pure2-last-use.cpp @@ -397,7 +397,7 @@ class issue_857_9: public issue_857_8 { }; class issue_869_0 { - public: explicit issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2); + public: issue_869_0([[maybe_unused]] std::unique_ptr&& unnamed_param_2); #line 366 "pure2-last-use.cpp2" public: auto operator=([[maybe_unused]] std::unique_ptr&& unnamed_param_2) -> issue_869_0& ; public: [[nodiscard]] auto operator<=>([[maybe_unused]] issue_869_0 const& that) const& -> std::strong_ordering = default; diff --git a/regression-tests/test-results/pure2-types-basics.cpp b/regression-tests/test-results/pure2-types-basics.cpp index 48c87a5aa5..c939baf067 100644 --- a/regression-tests/test-results/pure2-types-basics.cpp +++ b/regression-tests/test-results/pure2-types-basics.cpp @@ -31,12 +31,12 @@ class myclass { public: auto operator=(cpp2::impl::in x) -> myclass& ; #line 13 "pure2-types-basics.cpp2" - public: explicit myclass(cpp2::impl::in s); + public: myclass(cpp2::impl::in s); #line 13 "pure2-types-basics.cpp2" public: auto operator=(cpp2::impl::in s) -> myclass& ; #line 20 "pure2-types-basics.cpp2" - public: explicit myclass(cpp2::impl::in x, cpp2::impl::in s); + public: myclass(cpp2::impl::in x, cpp2::impl::in s); #line 27 "pure2-types-basics.cpp2" public: explicit myclass(); diff --git a/regression-tests/test-results/pure2-types-inheritance.cpp b/regression-tests/test-results/pure2-types-inheritance.cpp index cca47eb155..b039f18d25 100644 --- a/regression-tests/test-results/pure2-types-inheritance.cpp +++ b/regression-tests/test-results/pure2-types-inheritance.cpp @@ -41,7 +41,7 @@ class Human { namespace N { template class Machine { - public: explicit Machine([[maybe_unused]] cpp2::impl::in unnamed_param_2); + public: Machine([[maybe_unused]] cpp2::impl::in unnamed_param_2); public: virtual auto work() const -> void = 0; public: virtual ~Machine() noexcept; @@ -58,7 +58,7 @@ struct Cyborg_address_as_base { std::string address; }; class Cyborg: public Cyborg_name_as_base, public Human, public Cyborg_address_as_base, public N::Machine<99> { #line 19 "pure2-types-inheritance.cpp2" - public: explicit Cyborg(cpp2::impl::in n); + public: Cyborg(cpp2::impl::in n); #line 25 "pure2-types-inheritance.cpp2" public: auto speak() const -> void override; diff --git a/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp b/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp index 00efe82bfe..98b955e2cd 100644 --- a/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp +++ b/regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp @@ -45,7 +45,7 @@ class X { private: Y* py; // Note: A constructor with an 'out' parameter - public: explicit X(cpp2::impl::out y); + public: X(cpp2::impl::out y); #line 10 "pure2-types-order-independence-and-nesting.cpp2" public: auto operator=(cpp2::impl::out y) -> X& ; @@ -64,7 +64,7 @@ class X { class Y { private: X* px; - public: explicit Y(X* x); + public: Y(X* x); #line 49 "pure2-types-order-independence-and-nesting.cpp2" public: auto operator=(X* x) -> Y& ; diff --git a/regression-tests/test-results/pure2-types-ordering-via-meta-functions.cpp b/regression-tests/test-results/pure2-types-ordering-via-meta-functions.cpp index befac11e9d..4e87514f26 100644 --- a/regression-tests/test-results/pure2-types-ordering-via-meta-functions.cpp +++ b/regression-tests/test-results/pure2-types-ordering-via-meta-functions.cpp @@ -31,7 +31,7 @@ class mystruct; #line 2 "pure2-types-ordering-via-meta-functions.cpp2" class my_integer { private: int v; - public: explicit my_integer(cpp2::impl::in val); + public: my_integer(cpp2::impl::in val); #line 4 "pure2-types-ordering-via-meta-functions.cpp2" public: auto operator=(cpp2::impl::in val) -> my_integer& ; public: [[nodiscard]] auto operator<=>(my_integer const& that) const& -> std::strong_ordering = default; @@ -44,7 +44,7 @@ class my_integer { class case_insensitive_string { private: std::string v; // case insensitive - public: explicit case_insensitive_string(cpp2::impl::in val); + public: case_insensitive_string(cpp2::impl::in val); #line 9 "pure2-types-ordering-via-meta-functions.cpp2" public: auto operator=(cpp2::impl::in val) -> case_insensitive_string& ; public: [[nodiscard]] auto operator<=>(case_insensitive_string const& that) const& -> std::weak_ordering = default; @@ -57,7 +57,7 @@ class case_insensitive_string { class person_in_family_tree { private: int dummy_data; - public: explicit person_in_family_tree(cpp2::impl::in parents); + public: person_in_family_tree(cpp2::impl::in parents); #line 14 "pure2-types-ordering-via-meta-functions.cpp2" public: auto operator=(cpp2::impl::in parents) -> person_in_family_tree& ; public: [[nodiscard]] auto operator<=>(person_in_family_tree const& that) const& -> std::partial_ordering = default; diff --git a/regression-tests/test-results/pure2-types-smf-and-that-1-provide-everything.cpp b/regression-tests/test-results/pure2-types-smf-and-that-1-provide-everything.cpp index dc292e92ed..2424fe2c09 100644 --- a/regression-tests/test-results/pure2-types-smf-and-that-1-provide-everything.cpp +++ b/regression-tests/test-results/pure2-types-smf-and-that-1-provide-everything.cpp @@ -31,7 +31,7 @@ class myclass { public: auto operator=(myclass&& that) noexcept -> myclass& ; #line 22 "pure2-types-smf-and-that-1-provide-everything.cpp2" - public: explicit myclass(cpp2::impl::in x); + public: myclass(cpp2::impl::in x); #line 22 "pure2-types-smf-and-that-1-provide-everything.cpp2" public: auto operator=(cpp2::impl::in x) -> myclass& ; diff --git a/regression-tests/test-results/pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign.cpp b/regression-tests/test-results/pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign.cpp index c1ba2f5e2c..274b123a9d 100644 --- a/regression-tests/test-results/pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign.cpp +++ b/regression-tests/test-results/pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign.cpp @@ -34,7 +34,7 @@ class myclass { // std::cout << "assign - move "; // } - public: explicit myclass(cpp2::impl::in x); + public: myclass(cpp2::impl::in x); #line 22 "pure2-types-smf-and-that-2-provide-mvconstruct-and-cpassign.cpp2" public: auto operator=(cpp2::impl::in x) -> myclass& ; diff --git a/regression-tests/test-results/pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign.cpp b/regression-tests/test-results/pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign.cpp index 5861b559c1..84df682849 100644 --- a/regression-tests/test-results/pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign.cpp +++ b/regression-tests/test-results/pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign.cpp @@ -35,7 +35,7 @@ class myclass { public: auto operator=(myclass&& that) noexcept -> myclass& ; #line 22 "pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign.cpp2" - public: explicit myclass(cpp2::impl::in x); + public: myclass(cpp2::impl::in x); #line 22 "pure2-types-smf-and-that-3-provide-mvconstruct-and-mvassign.cpp2" public: auto operator=(cpp2::impl::in x) -> myclass& ; diff --git a/regression-tests/test-results/pure2-types-smf-and-that-4-provide-cpassign-and-mvassign.cpp b/regression-tests/test-results/pure2-types-smf-and-that-4-provide-cpassign-and-mvassign.cpp index eeb1bd2f6e..2784417718 100644 --- a/regression-tests/test-results/pure2-types-smf-and-that-4-provide-cpassign-and-mvassign.cpp +++ b/regression-tests/test-results/pure2-types-smf-and-that-4-provide-cpassign-and-mvassign.cpp @@ -35,7 +35,7 @@ class myclass { public: auto operator=(myclass&& that) noexcept -> myclass& ; #line 22 "pure2-types-smf-and-that-4-provide-cpassign-and-mvassign.cpp2" - public: explicit myclass(cpp2::impl::in x); + public: myclass(cpp2::impl::in x); #line 22 "pure2-types-smf-and-that-4-provide-cpassign-and-mvassign.cpp2" public: auto operator=(cpp2::impl::in x) -> myclass& ; diff --git a/regression-tests/test-results/pure2-types-smf-and-that-5-provide-nothing-but-general-case.cpp b/regression-tests/test-results/pure2-types-smf-and-that-5-provide-nothing-but-general-case.cpp index d6b3133fef..d919e9f58b 100644 --- a/regression-tests/test-results/pure2-types-smf-and-that-5-provide-nothing-but-general-case.cpp +++ b/regression-tests/test-results/pure2-types-smf-and-that-5-provide-nothing-but-general-case.cpp @@ -42,7 +42,7 @@ class myclass { // std::cout << "assign - move "; // } - public: explicit myclass(cpp2::impl::in x); + public: myclass(cpp2::impl::in x); #line 22 "pure2-types-smf-and-that-5-provide-nothing-but-general-case.cpp2" public: auto operator=(cpp2::impl::in x) -> myclass& ; diff --git a/regression-tests/test-results/pure2-types-value-types-via-meta-functions.cpp b/regression-tests/test-results/pure2-types-value-types-via-meta-functions.cpp index 24fc822630..b2e26aeb59 100644 --- a/regression-tests/test-results/pure2-types-value-types-via-meta-functions.cpp +++ b/regression-tests/test-results/pure2-types-value-types-via-meta-functions.cpp @@ -27,7 +27,7 @@ class p_widget; #line 2 "pure2-types-value-types-via-meta-functions.cpp2" class widget { private: int val {0}; - public: explicit widget(cpp2::impl::in i); + public: widget(cpp2::impl::in i); #line 4 "pure2-types-value-types-via-meta-functions.cpp2" public: auto operator=(cpp2::impl::in i) -> widget& ; public: [[nodiscard]] auto operator<=>(widget const& that) const& -> std::strong_ordering = default; @@ -43,7 +43,7 @@ public: explicit widget(); class w_widget { private: int val {0}; - public: explicit w_widget(cpp2::impl::in i); + public: w_widget(cpp2::impl::in i); #line 9 "pure2-types-value-types-via-meta-functions.cpp2" public: auto operator=(cpp2::impl::in i) -> w_widget& ; public: [[nodiscard]] auto operator<=>(w_widget const& that) const& -> std::weak_ordering = default; @@ -59,7 +59,7 @@ public: explicit w_widget(); class p_widget { private: int val {0}; - public: explicit p_widget(cpp2::impl::in i); + public: p_widget(cpp2::impl::in i); #line 14 "pure2-types-value-types-via-meta-functions.cpp2" public: auto operator=(cpp2::impl::in i) -> p_widget& ; public: [[nodiscard]] auto operator<=>(p_widget const& that) const& -> std::partial_ordering = default; diff --git a/source/parse.h b/source/parse.h index c08bde5166..d3f61f0f21 100644 --- a/source/parse.h +++ b/source/parse.h @@ -1897,6 +1897,16 @@ struct compound_statement_node compound_statement_node(source_position o = source_position{}); + auto get_statements() + -> std::vector + { + auto ret = std::vector{}; + for (auto const& stmt : statements) { + ret.push_back( stmt.get() ); + } + return ret; + } + auto position() const -> source_position { diff --git a/source/reflect.h b/source/reflect.h index 5fd28567f7..aa9a4962af 100644 --- a/source/reflect.h +++ b/source/reflect.h @@ -27,86 +27,92 @@ class declaration; #line 304 "reflect.h2" class function_declaration; -#line 403 "reflect.h2" +#line 393 "reflect.h2" class object_declaration; -#line 439 "reflect.h2" +#line 429 "reflect.h2" class type_declaration; -#line 577 "reflect.h2" +#line 567 "reflect.h2" class alias_declaration; -#line 1032 "reflect.h2" +#line 593 "reflect.h2" +class statement; + +#line 635 "reflect.h2" +class compound_statement; + +#line 1094 "reflect.h2" class value_member_info; -#line 1550 "reflect.h2" +#line 1612 "reflect.h2" class expression_flags; -#line 1566 "reflect.h2" +#line 1628 "reflect.h2" class regex_token; -#line 1592 "reflect.h2" +#line 1654 "reflect.h2" class regex_token_check; -#line 1611 "reflect.h2" +#line 1673 "reflect.h2" class regex_token_code; -#line 1630 "reflect.h2" +#line 1692 "reflect.h2" class regex_token_empty; -#line 1646 "reflect.h2" +#line 1708 "reflect.h2" class regex_token_list; -#line 1685 "reflect.h2" +#line 1747 "reflect.h2" class parse_context_group_state; -#line 1746 "reflect.h2" +#line 1808 "reflect.h2" class parse_context_branch_reset_state; -#line 1789 "reflect.h2" +#line 1851 "reflect.h2" class parse_context; -#line 2187 "reflect.h2" +#line 2249 "reflect.h2" class generation_function_context; -#line 2205 "reflect.h2" +#line 2267 "reflect.h2" class generation_context; -#line 2403 "reflect.h2" +#line 2465 "reflect.h2" class alternative_token; -#line 2418 "reflect.h2" +#line 2480 "reflect.h2" class alternative_token_gen; -#line 2470 "reflect.h2" +#line 2532 "reflect.h2" class any_token; -#line 2488 "reflect.h2" +#line 2550 "reflect.h2" class char_token; -#line 2591 "reflect.h2" +#line 2653 "reflect.h2" class class_token; -#line 2806 "reflect.h2" +#line 2868 "reflect.h2" class group_ref_token; -#line 2937 "reflect.h2" +#line 2999 "reflect.h2" class group_token; -#line 3224 "reflect.h2" +#line 3286 "reflect.h2" class lookahead_token; -#line 3305 "reflect.h2" +#line 3367 "reflect.h2" class range_token; -#line 3453 "reflect.h2" +#line 3515 "reflect.h2" class special_range_token; -#line 3520 "reflect.h2" +#line 3582 "reflect.h2" template class regex_generator; -#line 3767 "reflect.h2" +#line 3829 "reflect.h2" } } @@ -151,7 +157,7 @@ class compiler_services private: bool metafunctions_used {false}; #line 44 "reflect.h2" - public: explicit compiler_services( + public: compiler_services( std::vector* errors_, std::set* includes_, @@ -213,7 +219,7 @@ template class reflection_base #line 193 "reflect.h2" protected: T* n; - protected: explicit reflection_base( + protected: reflection_base( T* n_, cpp2::impl::in s @@ -234,7 +240,7 @@ class declaration : public reflection_base { #line 226 "reflect.h2" - public: explicit declaration( + public: declaration( declaration_node* n_, cpp2::impl::in s @@ -309,7 +315,7 @@ class function_declaration : public declaration { #line 308 "reflect.h2" - public: explicit function_declaration( + public: function_declaration( declaration_node* n_, cpp2::impl::in s @@ -359,7 +365,7 @@ class function_declaration public: [[nodiscard]] auto get_parameters() const& -> std::vector; -#line 381 "reflect.h2" +#line 371 "reflect.h2" public: [[nodiscard]] auto default_to_virtual() & -> decltype(auto); public: [[nodiscard]] auto make_virtual() & -> bool; @@ -368,95 +374,95 @@ class function_declaration public: function_declaration(function_declaration const& that); -#line 397 "reflect.h2" +#line 387 "reflect.h2" }; -#line 403 "reflect.h2" +#line 393 "reflect.h2" class object_declaration : public declaration { -#line 407 "reflect.h2" - public: explicit object_declaration( +#line 397 "reflect.h2" + public: object_declaration( declaration_node* n_, cpp2::impl::in s ); -#line 417 "reflect.h2" +#line 407 "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 427 "reflect.h2" +#line 417 "reflect.h2" public: [[nodiscard]] auto initializer() const& -> std::string; public: object_declaration(object_declaration const& that); -#line 433 "reflect.h2" +#line 423 "reflect.h2" }; -#line 439 "reflect.h2" +#line 429 "reflect.h2" class type_declaration : public declaration { -#line 443 "reflect.h2" - public: explicit type_declaration( +#line 433 "reflect.h2" + public: type_declaration( declaration_node* n_, cpp2::impl::in s ); -#line 453 "reflect.h2" +#line 443 "reflect.h2" public: auto reserve_names(cpp2::impl::in name, auto&& ...etc) const& -> void; -#line 467 "reflect.h2" +#line 457 "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 482 "reflect.h2" +#line 472 "reflect.h2" public: [[nodiscard]] auto get_member_functions_needing_initializer() const& -> std::vector; -#line 497 "reflect.h2" +#line 487 "reflect.h2" public: [[nodiscard]] auto get_member_objects() const& -> std::vector; -#line 507 "reflect.h2" +#line 497 "reflect.h2" public: [[nodiscard]] auto get_member_types() const& -> std::vector; -#line 517 "reflect.h2" +#line 507 "reflect.h2" public: [[nodiscard]] auto get_member_aliases() const& -> std::vector; -#line 527 "reflect.h2" +#line 517 "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 537 "reflect.h2" +#line 527 "reflect.h2" public: [[nodiscard]] auto query_declared_value_set_functions() const& -> query_declared_value_set_functions_ret; -#line 553 "reflect.h2" +#line 543 "reflect.h2" public: auto add_member(cpp2::impl::in source) & -> void; -#line 567 "reflect.h2" +#line 557 "reflect.h2" public: [[nodiscard]] auto remove_marked_members() & -> decltype(auto); public: [[nodiscard]] auto remove_all_members() & -> decltype(auto); public: [[nodiscard]] auto disable_member_function_generation() & -> decltype(auto); public: type_declaration(type_declaration const& that); -#line 571 "reflect.h2" +#line 561 "reflect.h2" }; -#line 577 "reflect.h2" +#line 567 "reflect.h2" class alias_declaration : public declaration { -#line 581 "reflect.h2" - public: explicit alias_declaration( +#line 571 "reflect.h2" + public: alias_declaration( declaration_node* n_, cpp2::impl::in s @@ -464,65 +470,118 @@ class alias_declaration public: alias_declaration(alias_declaration const& that); -#line 590 "reflect.h2" +#line 580 "reflect.h2" }; -#line 610 "reflect.h2" -auto add_virtual_destructor(meta::type_declaration& t) -> void; +#line 593 "reflect.h2" +class statement +: public reflection_base { + +#line 597 "reflect.h2" + public: statement( + + statement_node* n_, + cpp2::impl::in s + ); + +#line 606 "reflect.h2" + public: [[nodiscard]] auto is_expression_statement() const& -> bool; + public: [[nodiscard]] auto is_compound_statement() const& -> bool; + public: [[nodiscard]] auto is_selection_statement() const& -> bool; + public: [[nodiscard]] auto is_declaration_statement() const& -> bool; + public: [[nodiscard]] auto is_return_statement() const& -> bool; + public: [[nodiscard]] auto is_iteration_statement() const& -> bool; + public: [[nodiscard]] auto is_using_statement() const& -> bool; + public: [[nodiscard]] auto is_contract() const& -> bool; + public: [[nodiscard]] auto is_inspect_expression() const& -> bool; + public: [[nodiscard]] auto is_jump_statement() const& -> bool; + +#line 618 "reflect.h2" + public: [[nodiscard]] auto as_compound_statement() const& -> compound_statement; #line 628 "reflect.h2" + public: [[nodiscard]] auto to_string() const& -> std::string; + public: virtual ~statement() noexcept; +public: statement(statement const& that); + +#line 629 "reflect.h2" +}; + +#line 635 "reflect.h2" +class compound_statement +: public reflection_base { + +#line 639 "reflect.h2" + public: compound_statement( + + compound_statement_node* n_, + cpp2::impl::in s + ); + +#line 648 "reflect.h2" + public: [[nodiscard]] auto get_statements() const& -> std::vector; + public: compound_statement(compound_statement const& that); + + +#line 657 "reflect.h2" +}; + +#line 672 "reflect.h2" +auto add_virtual_destructor(meta::type_declaration& t) -> void; + +#line 690 "reflect.h2" auto interface(meta::type_declaration& t) -> void; -#line 674 "reflect.h2" +#line 736 "reflect.h2" auto polymorphic_base(meta::type_declaration& t) -> void; -#line 719 "reflect.h2" +#line 781 "reflect.h2" auto ordered_impl( meta::type_declaration& t, cpp2::impl::in ordering ) -> void; -#line 748 "reflect.h2" +#line 810 "reflect.h2" auto ordered(meta::type_declaration& t) -> void; -#line 756 "reflect.h2" +#line 818 "reflect.h2" auto weakly_ordered(meta::type_declaration& t) -> void; -#line 764 "reflect.h2" +#line 826 "reflect.h2" auto partially_ordered(meta::type_declaration& t) -> void; -#line 786 "reflect.h2" +#line 848 "reflect.h2" auto copyable(meta::type_declaration& t) -> void; -#line 819 "reflect.h2" +#line 881 "reflect.h2" auto hashable(meta::type_declaration& t) -> void; -#line 852 "reflect.h2" +#line 914 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void; -#line 880 "reflect.h2" +#line 942 "reflect.h2" auto value(meta::type_declaration& t) -> void; -#line 886 "reflect.h2" +#line 948 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void; -#line 892 "reflect.h2" +#line 954 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void; -#line 921 "reflect.h2" +#line 983 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void; -#line 963 "reflect.h2" +#line 1025 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void; -#line 1032 "reflect.h2" +#line 1094 "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 1036 "reflect.h2" +#line 1098 "reflect.h2" }; auto basic_enum( @@ -531,22 +590,22 @@ auto basic_enum( cpp2::impl::in bitwise ) -> void; -#line 1302 "reflect.h2" +#line 1364 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void; -#line 1329 "reflect.h2" +#line 1391 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void; -#line 1375 "reflect.h2" +#line 1437 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void; -#line 1526 "reflect.h2" +#line 1588 "reflect.h2" auto print(cpp2::impl::in t) -> void; -#line 1546 "reflect.h2" +#line 1608 "reflect.h2" using error_func = std::function x)>; -#line 1550 "reflect.h2" +#line 1612 "reflect.h2" class expression_flags { private: cpp2::u8 _value; private: constexpr expression_flags(cpp2::impl::in _val); @@ -581,20 +640,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 1558 "reflect.h2" +#line 1620 "reflect.h2" }; -#line 1566 "reflect.h2" +#line 1628 "reflect.h2" class regex_token { public: std::string string_rep; - public: explicit regex_token(cpp2::impl::in str); + public: regex_token(cpp2::impl::in str); -#line 1574 "reflect.h2" +#line 1636 "reflect.h2" public: explicit regex_token(); -#line 1579 "reflect.h2" +#line 1641 "reflect.h2" public: virtual auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void = 0; public: virtual auto add_groups([[maybe_unused]] std::set& unnamed_param_2) const -> void; @@ -605,24 +664,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 1584 "reflect.h2" +#line 1646 "reflect.h2" }; using token_ptr = std::shared_ptr; using token_vec = std::vector; -#line 1590 "reflect.h2" +#line 1652 "reflect.h2" // Adds a check in code generation. // class regex_token_check : public regex_token { -#line 1596 "reflect.h2" +#line 1658 "reflect.h2" private: std::string check; - public: explicit regex_token_check(cpp2::impl::in str, cpp2::impl::in check_); + public: regex_token_check(cpp2::impl::in str, cpp2::impl::in check_); -#line 1603 "reflect.h2" +#line 1665 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~regex_token_check() noexcept; @@ -630,21 +689,21 @@ class regex_token_check public: auto operator=(regex_token_check const&) -> void = delete; -#line 1606 "reflect.h2" +#line 1668 "reflect.h2" }; -#line 1609 "reflect.h2" +#line 1671 "reflect.h2" // Adds code in code generation. // class regex_token_code : public regex_token { -#line 1615 "reflect.h2" +#line 1677 "reflect.h2" private: std::string code; - public: explicit regex_token_code(cpp2::impl::in str, cpp2::impl::in code_); + public: regex_token_code(cpp2::impl::in str, cpp2::impl::in code_); -#line 1622 "reflect.h2" +#line 1684 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~regex_token_code() noexcept; @@ -652,19 +711,19 @@ class regex_token_code public: auto operator=(regex_token_code const&) -> void = delete; -#line 1625 "reflect.h2" +#line 1687 "reflect.h2" }; -#line 1628 "reflect.h2" +#line 1690 "reflect.h2" // Token that does not influence the matching. E.g. comment. // class regex_token_empty : public regex_token { -#line 1634 "reflect.h2" - public: explicit regex_token_empty(cpp2::impl::in str); +#line 1696 "reflect.h2" + public: regex_token_empty(cpp2::impl::in str); -#line 1638 "reflect.h2" +#line 1700 "reflect.h2" public: auto generate_code([[maybe_unused]] generation_context& unnamed_param_2) const -> void override; public: virtual ~regex_token_empty() noexcept; @@ -672,27 +731,27 @@ class regex_token_empty public: auto operator=(regex_token_empty const&) -> void = delete; -#line 1641 "reflect.h2" +#line 1703 "reflect.h2" }; -#line 1644 "reflect.h2" +#line 1706 "reflect.h2" // Represents a list of regex tokens as one token. // class regex_token_list : public regex_token { -#line 1650 "reflect.h2" +#line 1712 "reflect.h2" public: token_vec tokens; - public: explicit regex_token_list(cpp2::impl::in t); + public: regex_token_list(cpp2::impl::in t); -#line 1657 "reflect.h2" +#line 1719 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 1663 "reflect.h2" +#line 1725 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 1669 "reflect.h2" +#line 1731 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in vec) -> std::string; public: virtual ~regex_token_list() noexcept; @@ -700,10 +759,10 @@ class regex_token_list public: auto operator=(regex_token_list const&) -> void = delete; -#line 1676 "reflect.h2" +#line 1738 "reflect.h2" }; -#line 1679 "reflect.h2" +#line 1741 "reflect.h2" // // Parse and generation context. // @@ -719,33 +778,33 @@ class parse_context_group_state // Start a new alternative. public: auto next_alternative() & -> void; -#line 1699 "reflect.h2" +#line 1761 "reflect.h2" // Swap this state with the other one. NOLINTNEXTLINE(performance-noexcept-swap) public: auto swap(parse_context_group_state& t) & -> void; -#line 1706 "reflect.h2" +#line 1768 "reflect.h2" // Convert this state into a regex token. public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 1718 "reflect.h2" +#line 1780 "reflect.h2" // Add a token to the current matcher list. public: auto add(cpp2::impl::in token) & -> void; -#line 1723 "reflect.h2" +#line 1785 "reflect.h2" // True if current matcher list is empty. public: [[nodiscard]] auto empty() const& -> bool; -#line 1727 "reflect.h2" +#line 1789 "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 1741 "reflect.h2" +#line 1803 "reflect.h2" }; -#line 1744 "reflect.h2" +#line 1806 "reflect.h2" // State for the branch reset. Takes care of the group numbering. See '(|)'. // class parse_context_branch_reset_state @@ -758,25 +817,25 @@ class parse_context_branch_reset_state // Next group identifier. public: [[nodiscard]] auto next() & -> int; -#line 1762 "reflect.h2" +#line 1824 "reflect.h2" // Set next group identifier. public: auto set_next(cpp2::impl::in g) & -> void; -#line 1768 "reflect.h2" +#line 1830 "reflect.h2" // Start a new alternative branch. public: auto next_alternative() & -> void; -#line 1775 "reflect.h2" +#line 1837 "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 1782 "reflect.h2" +#line 1844 "reflect.h2" }; -#line 1785 "reflect.h2" +#line 1847 "reflect.h2" // Context during parsing of the regular expressions. // // Keeps track of the distributed group identifiers, current parsed group and branch resets. @@ -790,72 +849,72 @@ class parse_context private: parse_context_group_state cur_group_state {}; private: parse_context_branch_reset_state cur_branch_reset_state {}; -#line 1799 "reflect.h2" +#line 1861 "reflect.h2" public: std::map named_groups {}; private: error_func error_out; // TODO: Declaring std::function fails for cpp2. private: bool has_error {false}; - public: explicit parse_context(cpp2::impl::in r, auto const& e); + public: parse_context(cpp2::impl::in r, auto const& e); -#line 1810 "reflect.h2" +#line 1872 "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 1823 "reflect.h2" +#line 1885 "reflect.h2" // `old_state` argument needs to be from start group. public: [[nodiscard]] auto end_group(cpp2::impl::in old_state) & -> token_ptr; -#line 1831 "reflect.h2" +#line 1893 "reflect.h2" public: [[nodiscard]] auto get_modifiers() const& -> expression_flags; -#line 1835 "reflect.h2" +#line 1897 "reflect.h2" public: auto set_modifiers(cpp2::impl::in mod) & -> void; -#line 1839 "reflect.h2" +#line 1901 "reflect.h2" // Branch reset management functions // public: [[nodiscard]] auto branch_reset_new_state() & -> parse_context_branch_reset_state; -#line 1851 "reflect.h2" +#line 1913 "reflect.h2" public: auto branch_reset_restore_state(cpp2::impl::in old_state) & -> void; -#line 1858 "reflect.h2" +#line 1920 "reflect.h2" public: auto next_alternative() & -> void; -#line 1864 "reflect.h2" +#line 1926 "reflect.h2" // Regex token management // public: auto add_token(cpp2::impl::in token) & -> void; -#line 1870 "reflect.h2" +#line 1932 "reflect.h2" public: [[nodiscard]] auto has_token() const& -> bool; -#line 1874 "reflect.h2" +#line 1936 "reflect.h2" public: [[nodiscard]] auto pop_token() & -> token_ptr; -#line 1885 "reflect.h2" +#line 1947 "reflect.h2" public: [[nodiscard]] auto get_as_token() & -> token_ptr; -#line 1889 "reflect.h2" +#line 1951 "reflect.h2" // Group management // public: [[nodiscard]] auto get_cur_group() const& -> int; -#line 1895 "reflect.h2" +#line 1957 "reflect.h2" public: [[nodiscard]] auto next_group() & -> int; -#line 1899 "reflect.h2" +#line 1961 "reflect.h2" public: auto set_named_group(cpp2::impl::in name, cpp2::impl::in id) & -> void; -#line 1906 "reflect.h2" +#line 1968 "reflect.h2" public: [[nodiscard]] auto get_named_group(cpp2::impl::in name) const& -> int; -#line 1917 "reflect.h2" +#line 1979 "reflect.h2" // Position management functions // public: [[nodiscard]] auto current() const& -> char; @@ -863,51 +922,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 1961 "reflect.h2" +#line 2023 "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 1973 "reflect.h2" +#line 2035 "reflect.h2" public: [[nodiscard]] auto next() & -> decltype(auto); public: [[nodiscard]] auto next_in_class() & -> decltype(auto); public: [[nodiscard]] auto next_no_skip() & -> decltype(auto); public: [[nodiscard]] auto next_n(cpp2::impl::in n) & -> bool; -#line 1986 "reflect.h2" +#line 2048 "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 2009 "reflect.h2" +#line 2071 "reflect.h2" public: [[nodiscard]] auto grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto); public: [[nodiscard]] auto grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto); public: [[nodiscard]] auto grab_until_one_of(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto); public: [[nodiscard]] auto grab_n(cpp2::impl::in n, cpp2::impl::out r) & -> bool; -#line 2026 "reflect.h2" +#line 2088 "reflect.h2" public: [[nodiscard]] auto grab_number() & -> std::string; -#line 2047 "reflect.h2" +#line 2109 "reflect.h2" private: [[nodiscard]] auto peek_impl(cpp2::impl::in in_class) const& -> char; -#line 2057 "reflect.h2" +#line 2119 "reflect.h2" public: [[nodiscard]] auto peek() const& -> decltype(auto); public: [[nodiscard]] auto peek_in_class() const& -> decltype(auto); -#line 2061 "reflect.h2" +#line 2123 "reflect.h2" // Parsing functions // public: [[nodiscard]] auto parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool; -#line 2117 "reflect.h2" +#line 2179 "reflect.h2" public: [[nodiscard]] auto parse_until(cpp2::impl::in term) & -> bool; -#line 2155 "reflect.h2" +#line 2217 "reflect.h2" public: [[nodiscard]] auto parse(cpp2::impl::in modifiers) & -> bool; -#line 2170 "reflect.h2" +#line 2232 "reflect.h2" // Misc functions public: [[nodiscard]] auto get_pos() const& -> decltype(auto); @@ -919,10 +978,10 @@ class parse_context public: auto operator=(parse_context const&) -> void = delete; -#line 2181 "reflect.h2" +#line 2243 "reflect.h2" }; -#line 2184 "reflect.h2" +#line 2246 "reflect.h2" // Context for one function generation. Generation of functions can be interleaved, // therefore we buffer the code for one function here. // @@ -932,16 +991,16 @@ class generation_function_context { public: auto add_tabs(cpp2::impl::in c) & -> void; -#line 2198 "reflect.h2" +#line 2260 "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 2201 "reflect.h2" +#line 2263 "reflect.h2" }; -#line 2204 "reflect.h2" +#line 2266 "reflect.h2" // Context for generating the state machine. class generation_context { @@ -961,68 +1020,68 @@ class generation_context // Add code line. public: auto add(cpp2::impl::in s) & -> void; -#line 2226 "reflect.h2" +#line 2288 "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 2232 "reflect.h2" +#line 2294 "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 2241 "reflect.h2" +#line 2303 "reflect.h2" protected: auto start_func_named(cpp2::impl::in name) & -> void; -#line 2252 "reflect.h2" +#line 2314 "reflect.h2" protected: [[nodiscard]] auto start_func() & -> std::string; -#line 2259 "reflect.h2" +#line 2321 "reflect.h2" protected: auto end_func_statefull(cpp2::impl::in s) & -> void; -#line 2278 "reflect.h2" +#line 2340 "reflect.h2" // Generate the function for a token. public: [[nodiscard]] auto generate_func(cpp2::impl::in token) & -> std::string; -#line 2288 "reflect.h2" +#line 2350 "reflect.h2" // Generate the reset for a list of group identifiers. public: [[nodiscard]] auto generate_reset(cpp2::impl::in> groups) & -> std::string; -#line 2311 "reflect.h2" +#line 2373 "reflect.h2" // Name generation // protected: [[nodiscard]] auto gen_func_name() & -> std::string; -#line 2319 "reflect.h2" +#line 2381 "reflect.h2" public: [[nodiscard]] auto next_func_name() & -> std::string; -#line 2323 "reflect.h2" +#line 2385 "reflect.h2" protected: [[nodiscard]] auto gen_reset_func_name() & -> std::string; -#line 2329 "reflect.h2" +#line 2391 "reflect.h2" public: [[nodiscard]] auto gen_temp() & -> std::string; -#line 2335 "reflect.h2" +#line 2397 "reflect.h2" // Context management // public: [[nodiscard]] auto new_context() & -> generation_function_context*; -#line 2345 "reflect.h2" +#line 2407 "reflect.h2" public: auto finish_context() & -> void; -#line 2353 "reflect.h2" +#line 2415 "reflect.h2" // Misc functions // private: [[nodiscard]] auto get_current() & -> generation_function_context*; -#line 2359 "reflect.h2" +#line 2421 "reflect.h2" private: [[nodiscard]] auto get_base() & -> generation_function_context*; -#line 2363 "reflect.h2" +#line 2425 "reflect.h2" public: [[nodiscard]] auto get_entry_func() const& -> std::string; -#line 2367 "reflect.h2" +#line 2429 "reflect.h2" public: [[nodiscard]] auto create_named_group_lookup(cpp2::impl::in> named_groups) const& -> std::string; -#line 2391 "reflect.h2" +#line 2453 "reflect.h2" // Run the generation for the token. public: [[nodiscard]] auto run(cpp2::impl::in token) & -> std::string; public: generation_context() = default; @@ -1030,7 +1089,7 @@ class generation_context public: auto operator=(generation_context const&) -> void = delete; -#line 2397 "reflect.h2" +#line 2459 "reflect.h2" }; // Regex syntax: | Example: ab|ba @@ -1050,24 +1109,24 @@ class alternative_token public: auto operator=(alternative_token const&) -> void = delete; -#line 2416 "reflect.h2" +#line 2478 "reflect.h2" }; class alternative_token_gen : public regex_token { -#line 2422 "reflect.h2" +#line 2484 "reflect.h2" private: token_vec alternatives; - public: explicit alternative_token_gen(cpp2::impl::in a); + public: alternative_token_gen(cpp2::impl::in a); -#line 2429 "reflect.h2" +#line 2491 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2446 "reflect.h2" +#line 2508 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; -#line 2453 "reflect.h2" +#line 2515 "reflect.h2" public: [[nodiscard]] static auto gen_string(cpp2::impl::in a) -> std::string; public: virtual ~alternative_token_gen() noexcept; @@ -1075,19 +1134,19 @@ class alternative_token_gen public: auto operator=(alternative_token_gen const&) -> void = delete; -#line 2465 "reflect.h2" +#line 2527 "reflect.h2" }; -#line 2468 "reflect.h2" +#line 2530 "reflect.h2" // Regex syntax: . // class any_token : public regex_token_check { -#line 2474 "reflect.h2" - public: explicit any_token(cpp2::impl::in single_line); +#line 2536 "reflect.h2" + public: any_token(cpp2::impl::in single_line); -#line 2478 "reflect.h2" +#line 2540 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~any_token() noexcept; @@ -1095,37 +1154,37 @@ class any_token public: auto operator=(any_token const&) -> void = delete; -#line 2483 "reflect.h2" +#line 2545 "reflect.h2" }; -#line 2486 "reflect.h2" +#line 2548 "reflect.h2" // Regex syntax: a // class char_token : public regex_token { -#line 2492 "reflect.h2" +#line 2554 "reflect.h2" private: std::string token; private: bool ignore_case; - public: explicit char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_); + public: char_token(cpp2::impl::in t, cpp2::impl::in ignore_case_); -#line 2501 "reflect.h2" +#line 2563 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2505 "reflect.h2" +#line 2567 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2528 "reflect.h2" +#line 2590 "reflect.h2" public: auto gen_case_insensitive(cpp2::impl::in lower, cpp2::impl::in upper, generation_context& ctx) const& -> void; -#line 2549 "reflect.h2" +#line 2611 "reflect.h2" public: auto gen_case_sensitive(generation_context& ctx) const& -> void; -#line 2567 "reflect.h2" +#line 2629 "reflect.h2" public: [[nodiscard]] auto add_escapes(std::string str) const& -> std::string; -#line 2582 "reflect.h2" +#line 2644 "reflect.h2" public: auto append(char_token const& that) & -> void; public: virtual ~char_token() noexcept; @@ -1133,30 +1192,30 @@ class char_token public: auto operator=(char_token const&) -> void = delete; -#line 2586 "reflect.h2" +#line 2648 "reflect.h2" }; -#line 2589 "reflect.h2" +#line 2651 "reflect.h2" // Regex syntax: [] Example: [abcx-y[:digits:]] // class class_token : public regex_token { -#line 2595 "reflect.h2" +#line 2657 "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); + public: class_token(cpp2::impl::in negate_, cpp2::impl::in case_insensitive_, cpp2::impl::in class_str_, cpp2::impl::in str); -#line 2607 "reflect.h2" +#line 2669 "reflect.h2" // TODO: Rework class generation: Generate check functions for classes. public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2733 "reflect.h2" +#line 2795 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 2738 "reflect.h2" +#line 2800 "reflect.h2" private: [[nodiscard]] static auto create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string; public: virtual ~class_token() noexcept; @@ -1164,20 +1223,20 @@ class class_token public: auto operator=(class_token const&) -> void = delete; -#line 2745 "reflect.h2" +#line 2807 "reflect.h2" }; -#line 2748 "reflect.h2" +#line 2810 "reflect.h2" // Regex syntax: \a or \n or \[ // [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr; -#line 2789 "reflect.h2" +#line 2851 "reflect.h2" // Regex syntax: \K Example: ab\Kcd // [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr; -#line 2800 "reflect.h2" +#line 2862 "reflect.h2" // Regex syntax: \ Example: \1 // \g{name_or_number} // \k{name_or_number} @@ -1187,16 +1246,16 @@ class class_token class group_ref_token : public regex_token { -#line 2810 "reflect.h2" +#line 2872 "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); + public: group_ref_token(cpp2::impl::in id_, cpp2::impl::in case_insensitive_, cpp2::impl::in str); -#line 2820 "reflect.h2" +#line 2882 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 2921 "reflect.h2" +#line 2983 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; public: virtual ~group_ref_token() noexcept; @@ -1204,10 +1263,10 @@ class group_ref_token public: auto operator=(group_ref_token const&) -> void = delete; -#line 2924 "reflect.h2" +#line 2986 "reflect.h2" }; -#line 2927 "reflect.h2" +#line 2989 "reflect.h2" // Regex syntax: () Example: (abc) // (?:) (?i:abc) @@ -1221,22 +1280,22 @@ class group_ref_token class group_token : public regex_token { -#line 2941 "reflect.h2" +#line 3003 "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 2958 "reflect.h2" +#line 3020 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 3095 "reflect.h2" +#line 3157 "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 3113 "reflect.h2" +#line 3175 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3133 "reflect.h2" +#line 3195 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~group_token() noexcept; @@ -1245,25 +1304,25 @@ class group_token public: auto operator=(group_token const&) -> void = delete; -#line 3140 "reflect.h2" +#line 3202 "reflect.h2" }; -#line 3143 "reflect.h2" +#line 3205 "reflect.h2" // Regex syntax: \x or \x{} Example: \x{62} // [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr; -#line 3184 "reflect.h2" +#line 3246 "reflect.h2" // Regex syntax: $ Example: aa$ // [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr; -#line 3204 "reflect.h2" +#line 3266 "reflect.h2" // Regex syntax: ^ Example: ^aa // [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr; -#line 3220 "reflect.h2" +#line 3282 "reflect.h2" // Regex syntax: (?=) or (?!) or (*pla), etc. Example: (?=AA) // // Parsed in group_token. @@ -1271,16 +1330,16 @@ class group_token class lookahead_token : public regex_token { -#line 3228 "reflect.h2" +#line 3290 "reflect.h2" protected: bool positive; public: token_ptr inner {nullptr}; - public: explicit lookahead_token(cpp2::impl::in positive_); + public: lookahead_token(cpp2::impl::in positive_); -#line 3235 "reflect.h2" +#line 3297 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3241 "reflect.h2" +#line 3303 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~lookahead_token() noexcept; @@ -1288,26 +1347,26 @@ class lookahead_token public: auto operator=(lookahead_token const&) -> void = delete; -#line 3244 "reflect.h2" +#line 3306 "reflect.h2" }; -#line 3247 "reflect.h2" +#line 3309 "reflect.h2" // Named character classes // [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr; -#line 3275 "reflect.h2" +#line 3337 "reflect.h2" // Regex syntax: \o{} Example: \o{142} // [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr; -#line 3303 "reflect.h2" +#line 3365 "reflect.h2" // Regex syntax: {min, max} Example: a{2,4} // class range_token : public regex_token { -#line 3309 "reflect.h2" +#line 3371 "reflect.h2" protected: int min_count {-1}; protected: int max_count {-1}; protected: int kind {range_flags::greedy}; @@ -1317,19 +1376,19 @@ class range_token public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; -#line 3389 "reflect.h2" +#line 3451 "reflect.h2" public: auto parse_modifier(parse_context& ctx) & -> void; -#line 3401 "reflect.h2" +#line 3463 "reflect.h2" public: [[nodiscard]] auto gen_mod_string() const& -> std::string; -#line 3414 "reflect.h2" +#line 3476 "reflect.h2" public: [[nodiscard]] auto gen_range_string() const& -> std::string; -#line 3433 "reflect.h2" +#line 3495 "reflect.h2" public: auto generate_code(generation_context& ctx) const -> void override; -#line 3444 "reflect.h2" +#line 3506 "reflect.h2" public: auto add_groups(std::set& groups) const -> void override; public: virtual ~range_token() noexcept; @@ -1337,16 +1396,16 @@ class range_token public: auto operator=(range_token const&) -> void = delete; -#line 3448 "reflect.h2" +#line 3510 "reflect.h2" }; -#line 3451 "reflect.h2" +#line 3513 "reflect.h2" // Regex syntax: *, +, or ? Example: aa* // class special_range_token : public range_token { -#line 3457 "reflect.h2" +#line 3519 "reflect.h2" public: [[nodiscard]] static auto parse(parse_context& ctx) -> token_ptr; public: virtual ~special_range_token() noexcept; @@ -1355,17 +1414,17 @@ class special_range_token public: auto operator=(special_range_token const&) -> void = delete; -#line 3487 "reflect.h2" +#line 3549 "reflect.h2" }; -#line 3490 "reflect.h2" +#line 3552 "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 3512 "reflect.h2" +#line 3574 "reflect.h2" //----------------------------------------------------------------------- // // Parser for regular expression. @@ -1384,26 +1443,26 @@ template class regex_generator private: std::string source {""}; - public: explicit regex_generator(cpp2::impl::in r, Error_out const& e); + public: regex_generator(cpp2::impl::in r, Error_out const& e); -#line 3535 "reflect.h2" +#line 3597 "reflect.h2" public: [[nodiscard]] auto parse() & -> std::string; -#line 3570 "reflect.h2" +#line 3632 "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 3584 "reflect.h2" +#line 3646 "reflect.h2" }; template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string; -#line 3596 "reflect.h2" +#line 3658 "reflect.h2" auto regex_gen(meta::type_declaration& t) -> void; -#line 3651 "reflect.h2" +#line 3713 "reflect.h2" //----------------------------------------------------------------------- // // apply_metafunctions @@ -1414,7 +1473,7 @@ auto regex_gen(meta::type_declaration& t) -> void; auto const& error ) -> bool; -#line 3767 "reflect.h2" +#line 3829 "reflect.h2" } } @@ -1737,13 +1796,13 @@ template reflection_base::reflection_base(reflection_base const& [[nodiscard]] auto declaration::is_function_expression() const& -> bool { return CPP2_UFCS(is_function_expression)((*cpp2::impl::assert_not_null(n))); } #line 273 "reflect.h2" - [[nodiscard]] auto declaration::as_function() const& -> function_declaration { return function_declaration(n, (*this)); } + [[nodiscard]] auto declaration::as_function() const& -> function_declaration { return { n, (*this) }; } #line 274 "reflect.h2" - [[nodiscard]] auto declaration::as_object() const& -> object_declaration { return object_declaration(n, (*this)); } + [[nodiscard]] auto declaration::as_object() const& -> object_declaration { return { n, (*this) }; } #line 275 "reflect.h2" - [[nodiscard]] auto declaration::as_type() const& -> type_declaration { return type_declaration(n, (*this)); } + [[nodiscard]] auto declaration::as_type() const& -> type_declaration { return { n, (*this) }; } #line 276 "reflect.h2" - [[nodiscard]] auto declaration::as_alias() const& -> alias_declaration { return alias_declaration(n, (*this)); } + [[nodiscard]] auto declaration::as_alias() const& -> alias_declaration { return { n, (*this) }; } #line 278 "reflect.h2" [[nodiscard]] auto declaration::get_parent() const& -> declaration { return declaration((*cpp2::impl::assert_not_null(n)).parent_declaration, (*this)); } @@ -1882,37 +1941,27 @@ declaration::declaration(declaration const& that) { std::vector ret {}; for ( auto const& param : CPP2_UFCS(get_function_parameters)((*cpp2::impl::assert_not_null(n))) ) { - static_cast(CPP2_UFCS(emplace_back)(ret, &*cpp2::impl::assert_not_null((*cpp2::impl::assert_not_null(param)).declaration), (*this))); + static_cast(CPP2_UFCS(emplace_back)(ret, CPP2_UFCS(get)((*cpp2::impl::assert_not_null(param)).declaration), (*this))); } return ret; } - //get_statements: (this) - // -> std::vector - //= { - // ret: std::vector = (); - // for n*.get_initializer_statements() do (stmt) { - // _ = ret.emplace_back( stmt, this ); - // } - // return ret; - //} - // Modifying operations // -#line 381 "reflect.h2" +#line 371 "reflect.h2" [[nodiscard]] auto function_declaration::default_to_virtual() & -> decltype(auto) { return static_cast(CPP2_UFCS(make_function_virtual)((*cpp2::impl::assert_not_null(n)))); } -#line 383 "reflect.h2" +#line 373 "reflect.h2" [[nodiscard]] auto function_declaration::make_virtual() & -> bool { return CPP2_UFCS(make_function_virtual)((*cpp2::impl::assert_not_null(n))); } -#line 385 "reflect.h2" +#line 375 "reflect.h2" auto function_declaration::add_initializer(cpp2::impl::in source) & -> void -#line 388 "reflect.h2" +#line 378 "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")); } -#line 389 "reflect.h2" +#line 379 "reflect.h2" auto stmt {parse_statement(source)}; if (!((cpp2::impl::as_(stmt)))) { error("cannot add an initializer that is not a valid statement"); @@ -1925,30 +1974,30 @@ declaration::declaration(declaration const& that) function_declaration::function_declaration(function_declaration const& that) : declaration{ static_cast(that) }{} -#line 400 "reflect.h2" +#line 390 "reflect.h2" //----------------------------------------------------------------------- // Object declarations // -#line 407 "reflect.h2" +#line 397 "reflect.h2" object_declaration::object_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 412 "reflect.h2" +#line 402 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_object)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } } -#line 417 "reflect.h2" +#line 407 "reflect.h2" [[nodiscard]] auto object_declaration::is_const() const& -> bool { return CPP2_UFCS(is_const)((*cpp2::impl::assert_not_null(n))); } -#line 418 "reflect.h2" +#line 408 "reflect.h2" [[nodiscard]] auto object_declaration::has_wildcard_type() const& -> bool { return CPP2_UFCS(has_wildcard_type)((*cpp2::impl::assert_not_null(n))); } -#line 420 "reflect.h2" +#line 410 "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*)")), @@ -1956,7 +2005,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 427 "reflect.h2" +#line 417 "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*)")), @@ -1967,25 +2016,25 @@ declaration::declaration(declaration const& that) object_declaration::object_declaration(object_declaration const& that) : declaration{ static_cast(that) }{} -#line 436 "reflect.h2" +#line 426 "reflect.h2" //----------------------------------------------------------------------- // Type declarations // -#line 443 "reflect.h2" +#line 433 "reflect.h2" type_declaration::type_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 448 "reflect.h2" +#line 438 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_type)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } } -#line 453 "reflect.h2" +#line 443 "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 ( @@ -2000,14 +2049,14 @@ declaration::declaration(declaration const& that) } } -#line 467 "reflect.h2" +#line 457 "reflect.h2" [[nodiscard]] auto type_declaration::is_polymorphic() const& -> bool { return CPP2_UFCS(is_polymorphic)((*cpp2::impl::assert_not_null(n))); } -#line 468 "reflect.h2" +#line 458 "reflect.h2" [[nodiscard]] auto type_declaration::is_final() const& -> bool { return CPP2_UFCS(is_type_final)((*cpp2::impl::assert_not_null(n))); } -#line 469 "reflect.h2" +#line 459 "reflect.h2" [[nodiscard]] auto type_declaration::make_final() & -> bool { return CPP2_UFCS(make_type_final)((*cpp2::impl::assert_not_null(n))); } -#line 471 "reflect.h2" +#line 461 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_functions() const& -> std::vector { @@ -2019,7 +2068,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 482 "reflect.h2" +#line 472 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_functions_needing_initializer() const& -> std::vector { @@ -2035,7 +2084,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 497 "reflect.h2" +#line 487 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_objects() const& -> std::vector { @@ -2046,7 +2095,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 507 "reflect.h2" +#line 497 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_types() const& -> std::vector { @@ -2057,7 +2106,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 517 "reflect.h2" +#line 507 "reflect.h2" [[nodiscard]] auto type_declaration::get_member_aliases() const& -> std::vector { @@ -2068,7 +2117,7 @@ declaration::declaration(declaration const& that) return ret; } -#line 527 "reflect.h2" +#line 517 "reflect.h2" [[nodiscard]] auto type_declaration::get_members() const& -> std::vector { @@ -2079,16 +2128,16 @@ declaration::declaration(declaration const& that) return ret; } -#line 537 "reflect.h2" +#line 527 "reflect.h2" [[nodiscard]] auto type_declaration::query_declared_value_set_functions() const& -> query_declared_value_set_functions_ret -#line 544 "reflect.h2" +#line 534 "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 545 "reflect.h2" +#line 535 "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); @@ -2097,7 +2146,7 @@ declaration::declaration(declaration const& that) return { std::move(out_this_in_that.value()), std::move(out_this_move_that.value()), std::move(inout_this_in_that.value()), std::move(inout_this_move_that.value()) }; // NOLINT(performance-move-const-arg) } -#line 553 "reflect.h2" +#line 543 "reflect.h2" auto type_declaration::add_member(cpp2::impl::in source) & -> void { auto decl {parse_statement(source)}; @@ -2112,30 +2161,30 @@ declaration::declaration(declaration const& that) std::string("unexpected error while attempting to add member:\n") + source); } -#line 567 "reflect.h2" +#line 557 "reflect.h2" [[nodiscard]] auto type_declaration::remove_marked_members() & -> decltype(auto) { return CPP2_UFCS(type_remove_marked_members)((*cpp2::impl::assert_not_null(n))); } -#line 568 "reflect.h2" +#line 558 "reflect.h2" [[nodiscard]] auto type_declaration::remove_all_members() & -> decltype(auto) { return CPP2_UFCS(type_remove_all_members)((*cpp2::impl::assert_not_null(n))); } -#line 570 "reflect.h2" +#line 560 "reflect.h2" [[nodiscard]] auto type_declaration::disable_member_function_generation() & -> decltype(auto) { return 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 574 "reflect.h2" +#line 564 "reflect.h2" //----------------------------------------------------------------------- // Alias declarations // -#line 581 "reflect.h2" +#line 571 "reflect.h2" alias_declaration::alias_declaration( declaration_node* n_, cpp2::impl::in s ) : declaration{ n_, s } -#line 586 "reflect.h2" +#line 576 "reflect.h2" { if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(is_alias)((*cpp2::impl::assert_not_null(n)))) ) { cpp2::cpp2_default.report_violation(""); } @@ -2144,12 +2193,102 @@ declaration::declaration(declaration const& that) alias_declaration::alias_declaration(alias_declaration const& that) : declaration{ static_cast(that) }{} -#line 593 "reflect.h2" +#line 583 "reflect.h2" //----------------------------------------------------------------------- +// // Statements // +//----------------------------------------------------------------------- +// + +//----------------------------------------------------------------------- +// General statement +// + +#line 597 "reflect.h2" + statement::statement( + + statement_node* n_, + cpp2::impl::in s + ) + : reflection_base{ n_, s } +#line 602 "reflect.h2" + { + + } -#line 598 "reflect.h2" +#line 606 "reflect.h2" + [[nodiscard]] auto statement::is_expression_statement() const& -> bool { return CPP2_UFCS(is_expression)((*cpp2::impl::assert_not_null(n))); } +#line 607 "reflect.h2" + [[nodiscard]] auto statement::is_compound_statement() const& -> bool { return CPP2_UFCS(is_compound)((*cpp2::impl::assert_not_null(n))); } +#line 608 "reflect.h2" + [[nodiscard]] auto statement::is_selection_statement() const& -> bool { return CPP2_UFCS(is_selection)((*cpp2::impl::assert_not_null(n))); } +#line 609 "reflect.h2" + [[nodiscard]] auto statement::is_declaration_statement() const& -> bool { return CPP2_UFCS(is_declaration)((*cpp2::impl::assert_not_null(n))); } +#line 610 "reflect.h2" + [[nodiscard]] auto statement::is_return_statement() const& -> bool { return CPP2_UFCS(is_return)((*cpp2::impl::assert_not_null(n))); } +#line 611 "reflect.h2" + [[nodiscard]] auto statement::is_iteration_statement() const& -> bool { return CPP2_UFCS(is_iteration)((*cpp2::impl::assert_not_null(n))); } +#line 612 "reflect.h2" + [[nodiscard]] auto statement::is_using_statement() const& -> bool { return CPP2_UFCS(is_using)((*cpp2::impl::assert_not_null(n))); } +#line 613 "reflect.h2" + [[nodiscard]] auto statement::is_contract() const& -> bool { return CPP2_UFCS(is_contract)((*cpp2::impl::assert_not_null(n))); } +#line 614 "reflect.h2" + [[nodiscard]] auto statement::is_inspect_expression() const& -> bool { return CPP2_UFCS(is_inspect)((*cpp2::impl::assert_not_null(n))); } +#line 615 "reflect.h2" + [[nodiscard]] auto statement::is_jump_statement() const& -> bool { return CPP2_UFCS(is_jump)((*cpp2::impl::assert_not_null(n))); } + + //as_expression_statement : (this) -> expression_statement = expression_statement (n*.get_if(), this); +#line 618 "reflect.h2" + [[nodiscard]] auto statement::as_compound_statement() const& -> compound_statement { return { CPP2_UFCS_TEMPLATE(get_if)((*cpp2::impl::assert_not_null(n))), (*this) }; } + //as_selection_statement : (this) -> selection_statement = selection_statement (n*.get_if(), this); + //as_declaration_statement: (this) -> declaration_statement = declaration_statement(n*.get_if(), this); + //as_return_statement : (this) -> return_statement = return_statement (n*.get_if(), this); + //as_iteration_statement : (this) -> iteration_statement = iteration_statement (n*.get_if(), this); + //as_using_statement : (this) -> using_statement = using_statement (n*.get_if(), this); + //as_contract : (this) -> contract = contract (n*.get_if(), this); + //as_inspect_expression : (this) -> inspect_expression = inspect_expression (n*.get_if(), this); + //as_jump_statement : (this) -> jump_statement = jump_statement (n*.get_if(), this); + +#line 628 "reflect.h2" + [[nodiscard]] auto statement::to_string() const& -> std::string { return CPP2_UFCS(to_string)((*cpp2::impl::assert_not_null(n))); } + + statement::~statement() noexcept{} +statement::statement(statement const& that) + : reflection_base{ static_cast const&>(that) }{} + +#line 632 "reflect.h2" +//----------------------------------------------------------------------- +// Compound statements +// + +#line 639 "reflect.h2" + compound_statement::compound_statement( + + compound_statement_node* n_, + cpp2::impl::in s + ) + : reflection_base{ n_, s } +#line 644 "reflect.h2" + { + + } + +#line 648 "reflect.h2" + [[nodiscard]] auto compound_statement::get_statements() const& -> std::vector + + { + std::vector ret {}; + for ( auto const& stmt : CPP2_UFCS(get_statements)((*cpp2::impl::assert_not_null(n))) ) { + static_cast(CPP2_UFCS(emplace_back)(ret, stmt, (*this))); + } + return ret; + } + + compound_statement::compound_statement(compound_statement const& that) + : reflection_base{ static_cast const&>(that) }{} + +#line 660 "reflect.h2" //----------------------------------------------------------------------- // // Metafunctions - these are hardwired for now until we get to the @@ -2162,13 +2301,13 @@ declaration::declaration(declaration const& that) // Some common metafunction helpers (metafunctions are just functions, // so they can be factored as usual) // -#line 610 "reflect.h2" +#line 672 "reflect.h2" auto add_virtual_destructor(meta::type_declaration& t) -> void { CPP2_UFCS(add_member)(t, "operator=: (virtual move this) = { }"); } -#line 616 "reflect.h2" +#line 678 "reflect.h2" //----------------------------------------------------------------------- // // "... an abstract base class defines an interface ..." @@ -2181,7 +2320,7 @@ auto add_virtual_destructor(meta::type_declaration& t) -> void // // an abstract base class having only pure virtual functions // -#line 628 "reflect.h2" +#line 690 "reflect.h2" auto interface(meta::type_declaration& t) -> void { auto has_dtor {false}; @@ -2208,7 +2347,7 @@ auto interface(meta::type_declaration& t) -> void } } -#line 655 "reflect.h2" +#line 717 "reflect.h2" //----------------------------------------------------------------------- // // "C.35: A base class destructor should be either public and @@ -2228,7 +2367,7 @@ auto interface(meta::type_declaration& t) -> void // // Unlike an interface, it can have nonpublic and nonvirtual functions. // -#line 674 "reflect.h2" +#line 736 "reflect.h2" auto polymorphic_base(meta::type_declaration& t) -> void { auto has_dtor {false}; @@ -2253,7 +2392,7 @@ auto polymorphic_base(meta::type_declaration& t) -> void } } -#line 699 "reflect.h2" +#line 761 "reflect.h2" //----------------------------------------------------------------------- // // "... A totally ordered type ... requires operator<=> that @@ -2274,7 +2413,7 @@ auto polymorphic_base(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // -#line 719 "reflect.h2" +#line 781 "reflect.h2" auto ordered_impl( meta::type_declaration& t, cpp2::impl::in ordering// must be "strong_ordering" etc. @@ -2304,7 +2443,7 @@ auto ordered_impl( // // Note: the ordering that should be encouraged as default gets the nice name // -#line 748 "reflect.h2" +#line 810 "reflect.h2" auto ordered(meta::type_declaration& t) -> void { ordered_impl(t, "strong_ordering"); @@ -2313,7 +2452,7 @@ auto ordered(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // weakly_ordered - a weakly ordered type // -#line 756 "reflect.h2" +#line 818 "reflect.h2" auto weakly_ordered(meta::type_declaration& t) -> void { ordered_impl(t, "weak_ordering"); @@ -2322,13 +2461,13 @@ auto weakly_ordered(meta::type_declaration& t) -> void //----------------------------------------------------------------------- // partially_ordered - a partially ordered type // -#line 764 "reflect.h2" +#line 826 "reflect.h2" auto partially_ordered(meta::type_declaration& t) -> void { ordered_impl(t, "partial_ordering"); } -#line 770 "reflect.h2" +#line 832 "reflect.h2" //----------------------------------------------------------------------- // // "A value is ... a regular type. It must have all public @@ -2345,7 +2484,7 @@ auto partially_ordered(meta::type_declaration& t) -> void // // A type with (copy and move) x (construction and assignment) // -#line 786 "reflect.h2" +#line 848 "reflect.h2" auto copyable(meta::type_declaration& t) -> void { // If the user explicitly wrote any of the copy/move functions, @@ -2379,7 +2518,7 @@ auto copyable(meta::type_declaration& t) -> void // // A memberwise hashable type // -#line 819 "reflect.h2" +#line 881 "reflect.h2" auto hashable(meta::type_declaration& t) -> void { CPP2_UFCS(require)(t, !(CPP2_UFCS(empty)(CPP2_UFCS(get_member_objects)(t))), @@ -2405,7 +2544,7 @@ auto hashable(meta::type_declaration& t) -> void CPP2_UFCS(add_member)(t, cpp2::move(hash) + "\n return ret;\n }"); } -#line 845 "reflect.h2" +#line 907 "reflect.h2" //----------------------------------------------------------------------- // // basic_value @@ -2413,7 +2552,7 @@ auto hashable(meta::type_declaration& t) -> void // A regular type: copyable, plus has public default construction // and no protected or virtual functions // -#line 852 "reflect.h2" +#line 914 "reflect.h2" auto basic_value(meta::type_declaration& t) -> void { CPP2_UFCS(copyable)(t); @@ -2442,28 +2581,28 @@ auto basic_value(meta::type_declaration& t) -> void // // Note: the ordering that should be encouraged as default gets the nice name // -#line 880 "reflect.h2" +#line 942 "reflect.h2" auto value(meta::type_declaration& t) -> void { CPP2_UFCS(ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 886 "reflect.h2" +#line 948 "reflect.h2" auto weakly_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(weakly_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 892 "reflect.h2" +#line 954 "reflect.h2" auto partially_ordered_value(meta::type_declaration& t) -> void { CPP2_UFCS(partially_ordered)(t); CPP2_UFCS(basic_value)(t); } -#line 899 "reflect.h2" +#line 961 "reflect.h2" //----------------------------------------------------------------------- // // C.20: If you can avoid defining default operations, do @@ -2486,7 +2625,7 @@ auto partially_ordered_value(meta::type_declaration& t) -> void // // a type without declared copy/move/destructor functions // -#line 921 "reflect.h2" +#line 983 "reflect.h2" auto cpp1_rule_of_zero(meta::type_declaration& t) -> void { for ( auto& mf : CPP2_UFCS(get_member_functions)(t) ) @@ -2529,7 +2668,7 @@ auto cpp1_rule_of_zero(meta::type_declaration& t) -> void // parameters instead of concrete forwarding parameters (mainly used // for cppfront internal use, so cppfront builds under GCC 10) // -#line 963 "reflect.h2" +#line 1025 "reflect.h2" auto cpp2_struct(meta::type_declaration& t) -> void { std::string ctor_params {}; @@ -2586,7 +2725,7 @@ value_member_info::value_member_info(auto const& name_, auto const& type_, auto , type{ type_ } , value{ value_ }{} -#line 1015 "reflect.h2" +#line 1077 "reflect.h2" //----------------------------------------------------------------------- // // "C enumerations constitute a curiously half-baked concept. ... @@ -2605,7 +2744,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 1038 "reflect.h2" +#line 1100 "reflect.h2" auto basic_enum( meta::type_declaration& t, auto const& nextval, @@ -2630,7 +2769,7 @@ auto basic_enum( { std::string value{"-1"}; -#line 1061 "reflect.h2" +#line 1123 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) if ( CPP2_UFCS(is_member_object)(m)) @@ -2672,7 +2811,7 @@ std::string value{"-1"}; } } -#line 1101 "reflect.h2" +#line 1163 "reflect.h2" if ((CPP2_UFCS(empty)(enumerators))) { CPP2_UFCS(error)(t, "an enumeration must contain at least one enumerator value"); return ; @@ -2723,7 +2862,7 @@ std::string value{"-1"}; } } -#line 1152 "reflect.h2" +#line 1214 "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' @@ -2773,7 +2912,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 1199 "reflect.h2" +#line 1261 "reflect.h2" { if (bitwise) { to_string_impl += ", separator: std::string_view ) -> std::string = { \n" @@ -2814,7 +2953,7 @@ std::string to_string_impl{" to_string_impl: (this, prefix: std::string_view" } } -#line 1238 "reflect.h2" +#line 1300 "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)) + "::\", \" | \" );"); @@ -2828,7 +2967,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ // Provide a 'from_string' function to parse strings into enumerators -#line 1249 "reflect.h2" +#line 1311 "reflect.h2" { std::string_view prefix {""}; std::string_view combine_op {"return"}; @@ -2850,7 +2989,7 @@ std::string from_string{" from_string: (s: std::string_view) -> " + cpp2::to_ { std::string_view else_{""}; -#line 1269 "reflect.h2" +#line 1331 "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"; @@ -2858,7 +2997,7 @@ std::string_view else_{""}; } } -#line 1275 "reflect.h2" +#line 1337 "reflect.h2" if (bitwise) { from_string += " else { break outer; }\n" " }\n" @@ -2874,11 +3013,11 @@ std::string_view else_{""}; } } -#line 1289 "reflect.h2" +#line 1351 "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 1293 "reflect.h2" +#line 1355 "reflect.h2" //----------------------------------------------------------------------- // // "An enum[...] is a totally ordered value type that stores a @@ -2888,7 +3027,7 @@ std::string_view else_{""}; // // -- P0707R4, section 3 // -#line 1302 "reflect.h2" +#line 1364 "reflect.h2" auto cpp2_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with an incrementing value generator @@ -2905,7 +3044,7 @@ auto cpp2_enum(meta::type_declaration& t) -> void ); } -#line 1319 "reflect.h2" +#line 1381 "reflect.h2" //----------------------------------------------------------------------- // // "flag_enum expresses an enumeration that stores values @@ -2916,7 +3055,7 @@ auto cpp2_enum(meta::type_declaration& t) -> void // // -- P0707R4, section 3 // -#line 1329 "reflect.h2" +#line 1391 "reflect.h2" auto flag_enum(meta::type_declaration& t) -> void { // Let basic_enum do its thing, with a power-of-two value generator @@ -2938,7 +3077,7 @@ auto flag_enum(meta::type_declaration& t) -> void ); } -#line 1351 "reflect.h2" +#line 1413 "reflect.h2" //----------------------------------------------------------------------- // // "As with void*, programmers should know that unions [...] are @@ -2963,7 +3102,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 1375 "reflect.h2" +#line 1437 "reflect.h2" auto cpp2_union(meta::type_declaration& t) -> void { std::vector alternatives {}; @@ -2972,7 +3111,7 @@ auto value{0}; // 1. Gather: All the user-written members, and find/compute the max size -#line 1382 "reflect.h2" +#line 1444 "reflect.h2" for ( auto const& m : CPP2_UFCS(get_members)(t) ) { do @@ -3002,7 +3141,7 @@ auto value{0}; } while (false); ++value; } } -#line 1410 "reflect.h2" +#line 1472 "reflect.h2" std::string discriminator_type {}; if (cpp2::impl::cmp_less(CPP2_UFCS(ssize)(alternatives),std::numeric_limits::max())) { discriminator_type = "i8"; @@ -3017,7 +3156,7 @@ auto value{0}; discriminator_type = "i64"; }}} -#line 1425 "reflect.h2" +#line 1487 "reflect.h2" // 2. Replace: Erase the contents and replace with modified contents CPP2_UFCS(remove_marked_members)(t); @@ -3026,7 +3165,7 @@ std::string storage{" _storage: cpp2::aligned_storage t) -> void { std::cout << CPP2_UFCS(print)(t) << "\n"; @@ -3231,7 +3370,7 @@ return none; [[nodiscard]] auto expression_flags::from_code(cpp2::impl::in s) -> expression_flags{ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::move(str), "expression_flags::", "")); } -#line 1532 "reflect.h2" +#line 1594 "reflect.h2" //----------------------------------------------------------------------- // // regex - creates regular expressions from members @@ -3247,11 +3386,11 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov // ``` // -#line 1548 "reflect.h2" +#line 1610 "reflect.h2" // Possible modifiers for a regular expression. // -#line 1552 "reflect.h2" +#line 1614 "reflect.h2" // mod: i // mod: m // mod: s @@ -3259,106 +3398,106 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov // mod: x // mod: xx -#line 1561 "reflect.h2" +#line 1623 "reflect.h2" // Tokens for regular expressions. // // Basic class for a regex token. // -#line 1570 "reflect.h2" +#line 1632 "reflect.h2" regex_token::regex_token(cpp2::impl::in str) : string_rep{ str }{ -#line 1572 "reflect.h2" +#line 1634 "reflect.h2" } -#line 1574 "reflect.h2" +#line 1636 "reflect.h2" regex_token::regex_token() : string_rep{ "" }{ -#line 1576 "reflect.h2" +#line 1638 "reflect.h2" } //parse: (inout ctx: parse_context) -> token_ptr; // Generate the matching code. -#line 1581 "reflect.h2" +#line 1643 "reflect.h2" auto regex_token::add_groups([[maybe_unused]] std::set& unnamed_param_2) const -> void{}// Adds all group indices to the set. -#line 1582 "reflect.h2" +#line 1644 "reflect.h2" [[nodiscard]] auto regex_token::to_string() const& -> std::string{return string_rep; }// Create a string representation. -#line 1583 "reflect.h2" +#line 1645 "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 1598 "reflect.h2" +#line 1660 "reflect.h2" regex_token_check::regex_token_check(cpp2::impl::in str, cpp2::impl::in check_) : regex_token{ str } , check{ check_ }{ -#line 1601 "reflect.h2" +#line 1663 "reflect.h2" } -#line 1603 "reflect.h2" +#line 1665 "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 1617 "reflect.h2" +#line 1679 "reflect.h2" regex_token_code::regex_token_code(cpp2::impl::in str, cpp2::impl::in code_) : regex_token{ str } , code{ code_ }{ -#line 1620 "reflect.h2" +#line 1682 "reflect.h2" } -#line 1622 "reflect.h2" +#line 1684 "reflect.h2" auto regex_token_code::generate_code(generation_context& ctx) const -> void{ ctx.add(code); } regex_token_code::~regex_token_code() noexcept{} -#line 1634 "reflect.h2" +#line 1696 "reflect.h2" regex_token_empty::regex_token_empty(cpp2::impl::in str) : regex_token{ str }{ -#line 1636 "reflect.h2" +#line 1698 "reflect.h2" } -#line 1638 "reflect.h2" +#line 1700 "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 1652 "reflect.h2" +#line 1714 "reflect.h2" regex_token_list::regex_token_list(cpp2::impl::in t) : regex_token{ gen_string(t) } , tokens{ t }{ -#line 1655 "reflect.h2" +#line 1717 "reflect.h2" } -#line 1657 "reflect.h2" +#line 1719 "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 1663 "reflect.h2" +#line 1725 "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 1669 "reflect.h2" +#line 1731 "reflect.h2" [[nodiscard]] auto regex_token_list::gen_string(cpp2::impl::in vec) -> std::string{ std::string r {""}; for ( auto const& token : vec ) { @@ -3369,7 +3508,7 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov regex_token_list::~regex_token_list() noexcept{} -#line 1692 "reflect.h2" +#line 1754 "reflect.h2" auto parse_context_group_state::next_alternative() & -> void{ token_vec new_list {}; std::swap(new_list, cur_match_list); @@ -3377,14 +3516,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 1700 "reflect.h2" +#line 1762 "reflect.h2" auto parse_context_group_state::swap(parse_context_group_state& t) & -> void{// NOLINT(performance-noexcept-swap) std::swap(cur_match_list, t.cur_match_list); std::swap(alternate_match_lists, t.alternate_match_lists); std::swap(modifiers, t.modifiers); } -#line 1707 "reflect.h2" +#line 1769 "reflect.h2" [[nodiscard]] auto parse_context_group_state::get_as_token() & -> token_ptr{ if (alternate_match_lists.empty()) { post_process_list(cur_match_list); @@ -3396,15 +3535,15 @@ std::string str {s}; return from_string(cpp2::string_util::replace_all(cpp2::mov } } -#line 1719 "reflect.h2" +#line 1781 "reflect.h2" auto parse_context_group_state::add(cpp2::impl::in token) & -> void{ cur_match_list.push_back(token); } -#line 1724 "reflect.h2" +#line 1786 "reflect.h2" [[nodiscard]] auto parse_context_group_state::empty() const& -> bool { return cur_match_list.empty(); } -#line 1728 "reflect.h2" +#line 1790 "reflect.h2" auto parse_context_group_state::post_process_list(token_vec& list) -> void{ // Merge all characters auto merge_pos {list.begin()}; @@ -3425,7 +3564,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 1754 "reflect.h2" +#line 1816 "reflect.h2" [[nodiscard]] auto parse_context_branch_reset_state::next() & -> int{ auto g {cur_group}; cur_group += 1; @@ -3434,20 +3573,20 @@ parse_context_group_state::parse_context_group_state(){} return g; } -#line 1763 "reflect.h2" +#line 1825 "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 1769 "reflect.h2" +#line 1831 "reflect.h2" auto parse_context_branch_reset_state::next_alternative() & -> void{ if (is_active) { cur_group = from; } } -#line 1776 "reflect.h2" +#line 1838 "reflect.h2" auto parse_context_branch_reset_state::set_active_reset(cpp2::impl::in restart) & -> void{ is_active = true; cur_group = restart; @@ -3462,16 +3601,16 @@ parse_context_group_state::parse_context_group_state(){} , from{ from_ }{} parse_context_branch_reset_state::parse_context_branch_reset_state(){} -#line 1804 "reflect.h2" +#line 1866 "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 1808 "reflect.h2" +#line 1870 "reflect.h2" } -#line 1814 "reflect.h2" +#line 1876 "reflect.h2" [[nodiscard]] auto parse_context::start_group() & -> parse_context_group_state { parse_context_group_state old_state {}; @@ -3481,7 +3620,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 1824 "reflect.h2" +#line 1886 "reflect.h2" [[nodiscard]] auto parse_context::end_group(cpp2::impl::in old_state) & -> token_ptr { auto inner {cur_group_state.get_as_token()}; @@ -3489,17 +3628,17 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return inner; } -#line 1831 "reflect.h2" +#line 1893 "reflect.h2" [[nodiscard]] auto parse_context::get_modifiers() const& -> expression_flags{ return cur_group_state.modifiers; } -#line 1835 "reflect.h2" +#line 1897 "reflect.h2" auto parse_context::set_modifiers(cpp2::impl::in mod) & -> void{ cur_group_state.modifiers = mod; } -#line 1842 "reflect.h2" +#line 1904 "reflect.h2" [[nodiscard]] auto parse_context::branch_reset_new_state() & -> parse_context_branch_reset_state { parse_context_branch_reset_state old_state {}; @@ -3509,7 +3648,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return old_state; } -#line 1851 "reflect.h2" +#line 1913 "reflect.h2" auto parse_context::branch_reset_restore_state(cpp2::impl::in old_state) & -> void { auto max_group {cur_branch_reset_state.max_group}; @@ -3517,24 +3656,24 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} cur_branch_reset_state.set_next(cpp2::move(max_group)); } -#line 1858 "reflect.h2" +#line 1920 "reflect.h2" auto parse_context::next_alternative() & -> void { cur_group_state.next_alternative(); cur_branch_reset_state.next_alternative(); } -#line 1866 "reflect.h2" +#line 1928 "reflect.h2" auto parse_context::add_token(cpp2::impl::in token) & -> void{ cur_group_state.add(token); } -#line 1870 "reflect.h2" +#line 1932 "reflect.h2" [[nodiscard]] auto parse_context::has_token() const& -> bool{ return !(cur_group_state.empty()); } -#line 1874 "reflect.h2" +#line 1936 "reflect.h2" [[nodiscard]] auto parse_context::pop_token() & -> token_ptr { token_ptr r {nullptr}; @@ -3546,22 +3685,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 1885 "reflect.h2" +#line 1947 "reflect.h2" [[nodiscard]] auto parse_context::get_as_token() & -> token_ptr{ return root; } -#line 1891 "reflect.h2" +#line 1953 "reflect.h2" [[nodiscard]] auto parse_context::get_cur_group() const& -> int{ return cur_branch_reset_state.cur_group; } -#line 1895 "reflect.h2" +#line 1957 "reflect.h2" [[nodiscard]] auto parse_context::next_group() & -> int{ return cur_branch_reset_state.next(); } -#line 1899 "reflect.h2" +#line 1961 "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. @@ -3569,7 +3708,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1906 "reflect.h2" +#line 1968 "reflect.h2" [[nodiscard]] auto parse_context::get_named_group(cpp2::impl::in name) const& -> int { auto iter {named_groups.find(name)}; @@ -3581,10 +3720,10 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1919 "reflect.h2" +#line 1981 "reflect.h2" [[nodiscard]] auto parse_context::current() const& -> char{return CPP2_ASSERT_IN_BOUNDS(regex, pos); } -#line 1922 "reflect.h2" +#line 1984 "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}; @@ -3624,7 +3763,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cur; } -#line 1962 "reflect.h2" +#line 2024 "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); @@ -3636,14 +3775,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 1973 "reflect.h2" +#line 2035 "reflect.h2" [[nodiscard]] auto parse_context::next() & -> decltype(auto) { return next_impl(false, false); } -#line 1974 "reflect.h2" +#line 2036 "reflect.h2" [[nodiscard]] auto parse_context::next_in_class() & -> decltype(auto) { return next_impl(true, false); } -#line 1975 "reflect.h2" +#line 2037 "reflect.h2" [[nodiscard]] auto parse_context::next_no_skip() & -> decltype(auto) { return next_impl(false, true); } -#line 1977 "reflect.h2" +#line 2039 "reflect.h2" [[nodiscard]] auto parse_context::next_n(cpp2::impl::in n) & -> bool{ auto r {true}; auto cur {0}; @@ -3653,10 +3792,10 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 1986 "reflect.h2" +#line 2048 "reflect.h2" [[nodiscard]] auto parse_context::has_next() const& -> bool{return cpp2::impl::cmp_less(pos,regex.size()); } -#line 1988 "reflect.h2" +#line 2050 "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}; // NOLINT(clang-analyzer-deadcode.DeadStores) @@ -3678,14 +3817,14 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2009 "reflect.h2" +#line 2071 "reflect.h2" [[nodiscard]] auto parse_context::grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto) { return grab_until_impl(e, cpp2::impl::out(&r), false); } -#line 2010 "reflect.h2" +#line 2072 "reflect.h2" [[nodiscard]] auto parse_context::grab_until(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto) { return grab_until_impl(std::string(1, e), cpp2::impl::out(&r), false); } -#line 2011 "reflect.h2" +#line 2073 "reflect.h2" [[nodiscard]] auto parse_context::grab_until_one_of(cpp2::impl::in e, cpp2::impl::out r) & -> decltype(auto) { return grab_until_impl(e, cpp2::impl::out(&r), true); } -#line 2013 "reflect.h2" +#line 2075 "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())) { @@ -3699,7 +3838,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2026 "reflect.h2" +#line 2088 "reflect.h2" [[nodiscard]] auto parse_context::grab_number() & -> std::string { auto start {pos}; @@ -3721,7 +3860,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return cpp2::move(r.value()); } -#line 2047 "reflect.h2" +#line 2109 "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())) { @@ -3732,12 +3871,12 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2057 "reflect.h2" +#line 2119 "reflect.h2" [[nodiscard]] auto parse_context::peek() const& -> decltype(auto) { return peek_impl(false); } -#line 2058 "reflect.h2" +#line 2120 "reflect.h2" [[nodiscard]] auto parse_context::peek_in_class() const& -> decltype(auto) { return peek_impl(true); } -#line 2063 "reflect.h2" +#line 2125 "reflect.h2" [[nodiscard]] auto parse_context::parser_group_modifiers(cpp2::impl::in change_str, expression_flags& parser_modifiers) & -> bool { auto is_negative {false}; @@ -3792,7 +3931,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 2117 "reflect.h2" +#line 2179 "reflect.h2" [[nodiscard]] auto parse_context::parse_until(cpp2::impl::in term) & -> bool{ token_ptr cur_token {}; @@ -3831,7 +3970,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return true; } -#line 2155 "reflect.h2" +#line 2217 "reflect.h2" [[nodiscard]] auto parse_context::parse(cpp2::impl::in modifiers) & -> bool { @@ -3847,21 +3986,21 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} return r; } -#line 2172 "reflect.h2" +#line 2234 "reflect.h2" [[nodiscard]] auto parse_context::get_pos() const& -> decltype(auto) { return pos; } -#line 2173 "reflect.h2" +#line 2235 "reflect.h2" [[nodiscard]] auto parse_context::get_range(cpp2::impl::in start, cpp2::impl::in end) const& -> decltype(auto) { return std::string(regex.substr(start, end - start + 1)); } -#line 2174 "reflect.h2" +#line 2236 "reflect.h2" [[nodiscard]] auto parse_context::valid() const& -> bool{return has_next() && !(has_error); } -#line 2176 "reflect.h2" +#line 2238 "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 2191 "reflect.h2" +#line 2253 "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 ) { @@ -3869,7 +4008,7 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} } } -#line 2198 "reflect.h2" +#line 2260 "reflect.h2" auto generation_function_context::remove_tabs(cpp2::impl::in c) & -> void{ tabs = tabs.substr(0, (cpp2::impl::as_(c)) * 2); } @@ -3879,22 +4018,22 @@ parse_context_branch_reset_state::parse_context_branch_reset_state(){} , tabs{ tabs_ }{} generation_function_context::generation_function_context(){} -#line 2216 "reflect.h2" +#line 2278 "reflect.h2" [[nodiscard]] auto generation_context::match_parameters() const& -> std::string{return "r.pos, ctx"; } -#line 2221 "reflect.h2" +#line 2283 "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 2227 "reflect.h2" +#line 2289 "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 2233 "reflect.h2" +#line 2295 "reflect.h2" auto generation_context::add_statefull(cpp2::impl::in next_func, cpp2::impl::in check) & -> void { end_func_statefull(check); @@ -3903,7 +4042,7 @@ generation_function_context::generation_function_context(){} start_func_named(cpp2::move(name)); } -#line 2241 "reflect.h2" +#line 2303 "reflect.h2" auto generation_context::start_func_named(cpp2::impl::in name) & -> void { auto cur {new_context()}; @@ -3915,7 +4054,7 @@ generation_function_context::generation_function_context(){} (*cpp2::impl::assert_not_null(cpp2::move(cur))).add_tabs(3); } -#line 2252 "reflect.h2" +#line 2314 "reflect.h2" [[nodiscard]] auto generation_context::start_func() & -> std::string { auto name {gen_func_name()}; @@ -3923,7 +4062,7 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 2259 "reflect.h2" +#line 2321 "reflect.h2" auto generation_context::end_func_statefull(cpp2::impl::in s) & -> void { auto cur {get_current()}; @@ -3943,7 +4082,7 @@ generation_function_context::generation_function_context(){} finish_context(); } -#line 2279 "reflect.h2" +#line 2341 "reflect.h2" [[nodiscard]] auto generation_context::generate_func(cpp2::impl::in token) & -> std::string { auto name {start_func()}; @@ -3953,7 +4092,7 @@ generation_function_context::generation_function_context(){} return name; } -#line 2289 "reflect.h2" +#line 2351 "reflect.h2" [[nodiscard]] auto generation_context::generate_reset(cpp2::impl::in> groups) & -> std::string { if (groups.empty()) { @@ -3976,33 +4115,33 @@ generation_function_context::generation_function_context(){} return cpp2::move(name) + "()"; } -#line 2313 "reflect.h2" +#line 2375 "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 2319 "reflect.h2" +#line 2381 "reflect.h2" [[nodiscard]] auto generation_context::next_func_name() & -> std::string{ return gen_func_name() + "()"; } -#line 2323 "reflect.h2" +#line 2385 "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 2329 "reflect.h2" +#line 2391 "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 2337 "reflect.h2" +#line 2399 "reflect.h2" [[nodiscard]] auto generation_context::new_context() & -> generation_function_context*{ gen_stack.push_back(generation_function_context()); auto cur {get_current()}; @@ -4011,7 +4150,7 @@ generation_function_context::generation_function_context(){} return cur; } -#line 2345 "reflect.h2" +#line 2407 "reflect.h2" auto generation_context::finish_context() & -> void{ auto cur {get_current()}; auto base {get_base()}; @@ -4020,22 +4159,22 @@ generation_function_context::generation_function_context(){} gen_stack.pop_back(); } -#line 2355 "reflect.h2" +#line 2417 "reflect.h2" [[nodiscard]] auto generation_context::get_current() & -> generation_function_context*{ return &gen_stack.back(); } -#line 2359 "reflect.h2" +#line 2421 "reflect.h2" [[nodiscard]] auto generation_context::get_base() & -> generation_function_context*{ return &CPP2_ASSERT_IN_BOUNDS_LITERAL(gen_stack, 0); } -#line 2363 "reflect.h2" +#line 2425 "reflect.h2" [[nodiscard]] auto generation_context::get_entry_func() const& -> std::string{ return entry_func; } -#line 2367 "reflect.h2" +#line 2429 "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"}; @@ -4059,18 +4198,18 @@ generation_function_context::generation_function_context(){} return res; } -#line 2392 "reflect.h2" +#line 2454 "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 2407 "reflect.h2" +#line 2469 "reflect.h2" alternative_token::alternative_token() : regex_token_empty{ "" }{} -#line 2409 "reflect.h2" +#line 2471 "reflect.h2" [[nodiscard]] auto alternative_token::parse(parse_context& ctx) -> token_ptr{ if (ctx.current() != '|') {return nullptr; } @@ -4081,15 +4220,15 @@ generation_function_context::generation_function_context(){} alternative_token::~alternative_token() noexcept{} -#line 2424 "reflect.h2" +#line 2486 "reflect.h2" alternative_token_gen::alternative_token_gen(cpp2::impl::in a) : regex_token{ gen_string(a) } , alternatives{ a }{ -#line 2427 "reflect.h2" +#line 2489 "reflect.h2" } -#line 2429 "reflect.h2" +#line 2491 "reflect.h2" auto alternative_token_gen::generate_code(generation_context& ctx) const -> void { std::string functions {""}; @@ -4107,7 +4246,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 2446 "reflect.h2" +#line 2508 "reflect.h2" auto alternative_token_gen::add_groups(std::set& groups) const -> void { for ( auto const& cur : alternatives ) { @@ -4115,7 +4254,7 @@ generation_function_context::generation_function_context(){} } } -#line 2453 "reflect.h2" +#line 2515 "reflect.h2" [[nodiscard]] auto alternative_token_gen::gen_string(cpp2::impl::in a) -> std::string { std::string r {""}; @@ -4131,14 +4270,14 @@ generation_function_context::generation_function_context(){} alternative_token_gen::~alternative_token_gen() noexcept{} -#line 2474 "reflect.h2" +#line 2536 "reflect.h2" any_token::any_token(cpp2::impl::in single_line) : regex_token_check{ ".", "any_token_matcher" }{ -#line 2476 "reflect.h2" +#line 2538 "reflect.h2" } -#line 2478 "reflect.h2" +#line 2540 "reflect.h2" [[nodiscard]] auto any_token::parse(parse_context& ctx) -> token_ptr{ if ('.' != ctx.current()) {return nullptr; } @@ -4147,21 +4286,21 @@ generation_function_context::generation_function_context(){} any_token::~any_token() noexcept{} -#line 2495 "reflect.h2" +#line 2557 "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 2499 "reflect.h2" +#line 2561 "reflect.h2" } -#line 2501 "reflect.h2" +#line 2563 "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 2505 "reflect.h2" +#line 2567 "reflect.h2" auto char_token::generate_code(generation_context& ctx) const -> void { if (ignore_case) { @@ -4170,14 +4309,14 @@ generation_function_context::generation_function_context(){} { size_t i{0}; -#line 2511 "reflect.h2" +#line 2573 "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 2516 "reflect.h2" +#line 2578 "reflect.h2" if (upper != lower) { gen_case_insensitive(cpp2::move(lower), cpp2::move(upper), ctx); } @@ -4190,7 +4329,7 @@ size_t i{0}; } } -#line 2528 "reflect.h2" +#line 2590 "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()) + ""}; @@ -4212,7 +4351,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 2549 "reflect.h2" +#line 2611 "reflect.h2" auto char_token::gen_case_sensitive(generation_context& ctx) const& -> void { std::string name {"str_" + cpp2::to_string(ctx.gen_temp()) + ""}; @@ -4231,7 +4370,7 @@ size_t i{0}; ctx.add("else { break; }"); } -#line 2567 "reflect.h2" +#line 2629 "reflect.h2" [[nodiscard]] auto char_token::add_escapes(std::string str) const& -> std::string { str = string_util::replace_all(str, "\\", "\\\\"); @@ -4247,7 +4386,7 @@ size_t i{0}; return cpp2::move(str); } -#line 2582 "reflect.h2" +#line 2644 "reflect.h2" auto char_token::append(char_token const& that) & -> void{ (*this).token += that.token; (*this).string_rep += that.string_rep; @@ -4255,19 +4394,19 @@ size_t i{0}; char_token::~char_token() noexcept{} -#line 2599 "reflect.h2" +#line 2661 "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 2600 "reflect.h2" +#line 2662 "reflect.h2" { -#line 2605 "reflect.h2" +#line 2667 "reflect.h2" } -#line 2608 "reflect.h2" +#line 2670 "reflect.h2" [[nodiscard]] auto class_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '[') {return nullptr; } @@ -4393,13 +4532,13 @@ size_t i{0}; ); } -#line 2733 "reflect.h2" +#line 2795 "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 2738 "reflect.h2" +#line 2800 "reflect.h2" [[nodiscard]] auto class_token::create_matcher(cpp2::impl::in name, cpp2::impl::in template_arguments) -> std::string { auto sep {", "}; @@ -4410,12 +4549,12 @@ size_t i{0}; class_token::~class_token() noexcept{} -#line 2750 "reflect.h2" +#line 2812 "reflect.h2" [[nodiscard]] auto escape_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } -#line 2755 "reflect.h2" +#line 2817 "reflect.h2" if (std::string::npos == std::string("afenrt^.[]()*{}?+|\\").find(ctx.peek())) { return nullptr; } @@ -4449,7 +4588,7 @@ size_t i{0}; } -#line 2791 "reflect.h2" +#line 2853 "reflect.h2" [[nodiscard]] auto global_group_reset_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'K'))) {return nullptr; } @@ -4458,18 +4597,18 @@ size_t i{0}; return CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared, "\\K", "ctx..set_group_start(0, r.pos);"); } -#line 2813 "reflect.h2" +#line 2875 "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 2814 "reflect.h2" +#line 2876 "reflect.h2" { -#line 2818 "reflect.h2" +#line 2880 "reflect.h2" } -#line 2820 "reflect.h2" +#line 2882 "reflect.h2" [[nodiscard]] auto group_ref_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -4571,14 +4710,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 2921 "reflect.h2" +#line 2983 "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 2944 "reflect.h2" +#line 3006 "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 @@ -4593,7 +4732,7 @@ size_t i{0}; return r; } -#line 2958 "reflect.h2" +#line 3020 "reflect.h2" [[nodiscard]] auto group_token::parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '(') {return nullptr; } @@ -4731,7 +4870,7 @@ size_t i{0}; } } -#line 3095 "reflect.h2" +#line 3157 "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 {"("}; @@ -4750,7 +4889,7 @@ size_t i{0}; return cpp2::move(start) + (*cpp2::impl::assert_not_null(inner_)).to_string() + ")"; } -#line 3113 "reflect.h2" +#line 3175 "reflect.h2" auto group_token::generate_code(generation_context& ctx) const -> void { if (-1 != number) { @@ -4771,7 +4910,7 @@ size_t i{0}; } } -#line 3133 "reflect.h2" +#line 3195 "reflect.h2" auto group_token::add_groups(std::set& groups) const -> void { (*cpp2::impl::assert_not_null(inner)).add_groups(groups); @@ -4782,7 +4921,7 @@ size_t i{0}; group_token::~group_token() noexcept{} -#line 3145 "reflect.h2" +#line 3207 "reflect.h2" [[nodiscard]] auto hexadecimal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'x'))) {return nullptr; } @@ -4821,7 +4960,7 @@ size_t i{0}; return r; } -#line 3186 "reflect.h2" +#line 3248 "reflect.h2" [[nodiscard]] auto line_end_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() == '$' || (ctx.current() == '\\' && ctx.peek() == '$')) { @@ -4839,7 +4978,7 @@ size_t i{0}; }} } -#line 3206 "reflect.h2" +#line 3268 "reflect.h2" [[nodiscard]] auto line_start_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '^' && !((ctx.current() == '\\' && ctx.peek() == 'A'))) {return nullptr; } @@ -4853,29 +4992,29 @@ size_t i{0}; } } -#line 3231 "reflect.h2" +#line 3293 "reflect.h2" lookahead_token::lookahead_token(cpp2::impl::in positive_) : regex_token{ "" } , positive{ positive_ }{ -#line 3233 "reflect.h2" +#line 3295 "reflect.h2" } -#line 3235 "reflect.h2" +#line 3297 "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 3241 "reflect.h2" +#line 3303 "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 3249 "reflect.h2" +#line 3311 "reflect.h2" [[nodiscard]] auto named_class_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -4901,7 +5040,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 3277 "reflect.h2" +#line 3339 "reflect.h2" [[nodiscard]] auto octal_token_parse(parse_context& ctx) -> token_ptr { if (!((ctx.current() == '\\' && ctx.peek() == 'o'))) {return nullptr; } @@ -4927,11 +5066,11 @@ size_t i{0}; return r; } -#line 3314 "reflect.h2" +#line 3376 "reflect.h2" range_token::range_token() : regex_token{ "" }{} -#line 3316 "reflect.h2" +#line 3378 "reflect.h2" [[nodiscard]] auto range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -5005,7 +5144,7 @@ size_t i{0}; return nullptr; } -#line 3389 "reflect.h2" +#line 3451 "reflect.h2" auto range_token::parse_modifier(parse_context& ctx) & -> void { if (ctx.peek() == '?') { @@ -5018,7 +5157,7 @@ size_t i{0}; }} } -#line 3401 "reflect.h2" +#line 3463 "reflect.h2" [[nodiscard]] auto range_token::gen_mod_string() const& -> std::string { if (kind == range_flags::not_greedy) { @@ -5032,7 +5171,7 @@ size_t i{0}; }} } -#line 3414 "reflect.h2" +#line 3476 "reflect.h2" [[nodiscard]] auto range_token::gen_range_string() const& -> std::string { std::string r {""}; @@ -5052,7 +5191,7 @@ size_t i{0}; return r; } -#line 3433 "reflect.h2" +#line 3495 "reflect.h2" auto range_token::generate_code(generation_context& ctx) const -> void { auto inner_name {ctx.generate_func(inner_token)}; @@ -5064,14 +5203,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 3444 "reflect.h2" +#line 3506 "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 3457 "reflect.h2" +#line 3519 "reflect.h2" [[nodiscard]] auto special_range_token::parse(parse_context& ctx) -> token_ptr { auto r {CPP2_UFCS_TEMPLATE(cpp2_new)(cpp2::shared)}; @@ -5095,7 +5234,7 @@ size_t i{0}; if (!(ctx.has_token())) {return ctx.error("'" + cpp2::to_string(ctx.current()) + "' without previous element."); } -#line 3481 "reflect.h2" +#line 3543 "reflect.h2" (*cpp2::impl::assert_not_null(r)).parse_modifier(ctx); (*cpp2::impl::assert_not_null(r)).inner_token = ctx.pop_token(); @@ -5105,7 +5244,7 @@ size_t i{0}; special_range_token::~special_range_token() noexcept{} -#line 3494 "reflect.h2" +#line 3556 "reflect.h2" [[nodiscard]] auto word_boundary_token_parse(parse_context& ctx) -> token_ptr { if (ctx.current() != '\\') {return nullptr; } @@ -5123,15 +5262,15 @@ size_t i{0}; }} } -#line 3530 "reflect.h2" +#line 3592 "reflect.h2" template regex_generator::regex_generator(cpp2::impl::in r, Error_out const& e) : regex{ r } , error_out{ e }{ -#line 3533 "reflect.h2" +#line 3595 "reflect.h2" } -#line 3535 "reflect.h2" +#line 3597 "reflect.h2" template [[nodiscard]] auto regex_generator::parse() & -> std::string { // Extract modifiers and adapt regex. @@ -5167,7 +5306,7 @@ size_t i{0}; return source; } -#line 3570 "reflect.h2" +#line 3632 "reflect.h2" template auto regex_generator::extract_modifiers() & -> void { if (regex.find_first_of("'/") == 0) { @@ -5183,7 +5322,7 @@ size_t i{0}; } } -#line 3586 "reflect.h2" +#line 3648 "reflect.h2" template [[nodiscard]] auto generate_regex(cpp2::impl::in regex, Err const& err) -> std::string { regex_generator parser {regex, err}; @@ -5192,7 +5331,7 @@ template [[nodiscard]] auto generate_regex(cpp2::impl::in void { auto has_default {false}; @@ -5247,7 +5386,7 @@ auto regex_gen(meta::type_declaration& t) -> void CPP2_UFCS(add_runtime_support_include)(t, "cpp2regex.h"); } -#line 3655 "reflect.h2" +#line 3717 "reflect.h2" [[nodiscard]] auto apply_metafunctions( declaration_node& n, type_declaration& rtype, @@ -5359,7 +5498,7 @@ auto regex_gen(meta::type_declaration& t) -> void return true; } -#line 3767 "reflect.h2" +#line 3829 "reflect.h2" } } diff --git a/source/reflect.h2 b/source/reflect.h2 index 11c2fc83cd..ecb6f5db12 100644 --- a/source/reflect.h2 +++ b/source/reflect.h2 @@ -270,10 +270,10 @@ declaration: @polymorphic_base @copyable type = is_function_expression : (this) -> bool = n*.is_function_expression(); - as_function : (this) -> function_declaration = function_declaration(n, this); - as_object : (this) -> object_declaration = object_declaration(n, this); - as_type : (this) -> type_declaration = type_declaration(n, this); - as_alias : (this) -> alias_declaration = alias_declaration(n, this); + as_function : (this) -> function_declaration = (n, this); + as_object : (this) -> object_declaration = (n, this); + as_type : (this) -> type_declaration = (n, this); + as_alias : (this) -> alias_declaration = (n, this); get_parent : (this) -> declaration = declaration(n*.parent_declaration, this); @@ -361,21 +361,11 @@ function_declaration: @copyable type = = { ret: std::vector = (); for n*.get_function_parameters() do (param) { - _ = ret.emplace_back( param*.declaration*&, this ); + _ = ret.emplace_back( param*.declaration.get(), this ); } return ret; } - //get_statements: (this) - // -> std::vector - //= { - // ret: std::vector = (); - // for n*.get_initializer_statements() do (stmt) { - // _ = ret.emplace_back( stmt, this ); - // } - // return ret; - //} - // Modifying operations // default_to_virtual : (inout this) = _ = n*.make_function_virtual(); @@ -591,8 +581,80 @@ alias_declaration: @copyable type = //----------------------------------------------------------------------- +// // Statements // +//----------------------------------------------------------------------- +// + +//----------------------------------------------------------------------- +// General statement +// +statement: @polymorphic_base @copyable type = +{ + this: reflection_base = (); + + operator=: ( + out this, + n_: *statement_node, + s : compiler_services + ) + = { + reflection_base = (n_, s); + } + + is_expression_statement : (this) -> bool = n*.is_expression(); + is_compound_statement : (this) -> bool = n*.is_compound(); + is_selection_statement : (this) -> bool = n*.is_selection(); + is_declaration_statement: (this) -> bool = n*.is_declaration(); + is_return_statement : (this) -> bool = n*.is_return(); + is_iteration_statement : (this) -> bool = n*.is_iteration(); + is_using_statement : (this) -> bool = n*.is_using(); + is_contract : (this) -> bool = n*.is_contract(); + is_inspect_expression : (this) -> bool = n*.is_inspect(); + is_jump_statement : (this) -> bool = n*.is_jump(); + + //as_expression_statement : (this) -> expression_statement = expression_statement (n*.get_if(), this); + as_compound_statement : (this) -> compound_statement = (n*.get_if(), this); + //as_selection_statement : (this) -> selection_statement = selection_statement (n*.get_if(), this); + //as_declaration_statement: (this) -> declaration_statement = declaration_statement(n*.get_if(), this); + //as_return_statement : (this) -> return_statement = return_statement (n*.get_if(), this); + //as_iteration_statement : (this) -> iteration_statement = iteration_statement (n*.get_if(), this); + //as_using_statement : (this) -> using_statement = using_statement (n*.get_if(), this); + //as_contract : (this) -> contract = contract (n*.get_if(), this); + //as_inspect_expression : (this) -> inspect_expression = inspect_expression (n*.get_if(), this); + //as_jump_statement : (this) -> jump_statement = jump_statement (n*.get_if(), this); + + to_string : (this) -> std::string = n*.to_string(); +} + + +//----------------------------------------------------------------------- +// Compound statements +// +compound_statement: @copyable type = +{ + this: reflection_base = (); + + operator=: ( + out this, + n_: *compound_statement_node, + s : compiler_services + ) + = { + reflection_base = (n_, s); + } + + get_statements: (this) + -> std::vector + = { + ret: std::vector = (); + for n*.get_statements() do (stmt) { + _ = ret.emplace_back( stmt, this ); + } + return ret; + } +} //----------------------------------------------------------------------- diff --git a/source/to_cpp1.h b/source/to_cpp1.h index bbf359f29b..2c2ffeece6 100644 --- a/source/to_cpp1.h +++ b/source/to_cpp1.h @@ -6544,6 +6544,7 @@ class cppfront func->is_constructor() && !func->is_constructor_with_that() && generating_assignment_from != &n + && func->parameter_count() < 2 ) { prefix += "explicit ";