diff --git a/include/iris/x4/attribute/as.hpp b/include/iris/x4/attribute/as.hpp index eddde6d21..aec71d46e 100644 --- a/include/iris/x4/attribute/as.hpp +++ b/include/iris/x4/attribute/as.hpp @@ -9,12 +9,12 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ +#include + +#include +#include #include #include -#include -#include -#include -#include #include #include @@ -88,7 +88,7 @@ struct as_type_parser : unary_parser, Subject> } else { if (!this->subject.parse(first, last, ctx, attr_)) return false; } - planner::pass_declared_attribute(outer_attr, std::move(attr_)); + detail::pass_declared_attribute(outer_attr, std::move(attr_)); return true; } } @@ -140,7 +140,7 @@ struct as_type_parser : unary_parser, Subject> } else { if (!this->subject.parse(first, last, ctx, attr_)) return false; } - planner::pass_declared_attribute(outer_attr, iris::unwrap_recursive(std::move(attr_))); + detail::pass_declared_attribute(outer_attr, iris::unwrap_recursive(std::move(attr_))); return true; } } diff --git a/include/iris/x4/core/detail/strict_attribute_parser.hpp b/include/iris/x4/core/detail/strict_attribute_parser.hpp new file mode 100644 index 000000000..ef39d687b --- /dev/null +++ b/include/iris/x4/core/detail/strict_attribute_parser.hpp @@ -0,0 +1,47 @@ +#ifndef IRIS_ZZ_X4_CORE_DETAIL_STRICT_ATTRIBUTE_PARSER_HPP +#define IRIS_ZZ_X4_CORE_DETAIL_STRICT_ATTRIBUTE_PARSER_HPP + +/*============================================================================= + Copyright (c) 2026 The Iris Project Contributors + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#include // IWYU pragma: keep + +#include + +#include + +#include // IWYU pragma: keep +#include + +namespace iris::x4 { + +namespace detail { + +// Passes `v`, the attribute of the strict-attribute parser (e.g. `x4::rule` or `x4::as`), to the +// exposed attribute `s` by the ordinary assignment. A container which holds the preceding results +// keeps them, and the value assigned to a new container is appended to it. +// +// Caller must preliminarily check the validity of such operation by `X4StrictlyWritable`. +template +constexpr void pass_declared_attribute(S& s, V&& v) +{ + if constexpr (traits::X4Container) { + if (!std::ranges::empty(s)) { + S assigned{}; + assigned = std::forward(v); + iris::container::transfer_from(s, std::move(assigned)); + return; + } + } + s = std::forward(v); +} + +} // detail + +} // iris::x4 + +#endif diff --git a/include/iris/x4/core/write_attribute.hpp b/include/iris/x4/core/write_attribute.hpp index 58ef608a5..4e11de773 100644 --- a/include/iris/x4/core/write_attribute.hpp +++ b/include/iris/x4/core/write_attribute.hpp @@ -11,7 +11,6 @@ #include // IWYU pragma: keep #include -#include #include #include @@ -344,23 +343,6 @@ struct write_attribute_fn } // detail -// Passes `v`, the attribute of `x4::rule` or `x4::as`, to the exposed attribute `s` by the ordinary -// assignment, which the caller has checked by `X4StrictlyWritable`. A container which holds -// the preceding results keeps them: the value assigned to a new container is appended to it. -template -constexpr void pass_declared_attribute(S& s, V&& v) -{ - if constexpr (traits::X4Container) { - if (!std::ranges::empty(s)) { - S assigned{}; - assigned = std::forward(v); - iris::container::transfer_from(s, std::move(assigned)); - return; - } - } - s = std::forward(v); -} - // Writes `v`, a part of a sequence or the value of one parse of a repetition, into the container // `s`: as a new element, part by part, or a range appended (P(S, y)) template diff --git a/include/iris/x4/debug/annotate.hpp b/include/iris/x4/debug/annotate.hpp index f1b45f167..cccfbfa1d 100644 --- a/include/iris/x4/debug/annotate.hpp +++ b/include/iris/x4/debug/annotate.hpp @@ -13,8 +13,6 @@ #include #include -#include - #include #include diff --git a/include/iris/x4/rule.hpp b/include/iris/x4/rule.hpp index 2ea9ecae7..602c659c4 100644 --- a/include/iris/x4/rule.hpp +++ b/include/iris/x4/rule.hpp @@ -13,11 +13,10 @@ #include // IWYU pragma: keep -#include -#include -#include #include +#include +#include #include #include #include @@ -143,7 +142,7 @@ struct rule : parser> if (!detail::call_parse_rule(first, last, rule_agnostic_ctx, detail::rule_attr_ref{rule_attr})) { return false; } - planner::pass_declared_attribute(exposed_attr, std::move(rule_attr)); + detail::pass_declared_attribute(exposed_attr, std::move(rule_attr)); return true; } } @@ -160,7 +159,7 @@ struct rule : parser> if (!detail::call_parse_rule(first, last, rule_agnostic_ctx, detail::rule_attr_ref{rule_attr})) { return false; } - planner::pass_declared_attribute(exposed_attr, iris::unwrap_recursive(std::move(rule_attr))); + detail::pass_declared_attribute(exposed_attr, iris::unwrap_recursive(std::move(rule_attr))); return true; } } diff --git a/modules/iris b/modules/iris index dee4b4fe5..19e0126e6 160000 --- a/modules/iris +++ b/modules/iris @@ -1 +1 @@ -Subproject commit dee4b4fe52245f8c2c0ba3d14b4d257bbd0f2904 +Subproject commit 19e0126e685fa2506d34deae3b26d30b5cdde689