The old implementation created temporary container variable and
move-appended its elements to the exposed attribute. This commit adds
new core class `container_appender` that transparently handles insertion
in underlying parsers, without the need to creating a temporary variable.
This change simplifies the core behavior of how the attribute and
iterator is preserved (or not preserved) in failed parse attempts.
Since X4 does not allow error handlers to return anything except `void`,
X4's iterator rollback behavior is not dependent on the error handler
anymore. This commit further clarifies the iterator/attribute behavior
for all supported core parsers.
Due to the reasons described above, this commit not only acts as X4's
"companion" fix mentioned in boostorg/spirit#833, but essentially acts as
the strict superset of the corresponding work boostorg/spirit#836 in X4's
domain.
* Make `rcontext` only when required
X3 has had created `rcontext` unconditionally for any parser
invocations. That led X4 to do the same even after #37 was merged. This
commit further optimizes the implementation to create `rcontext` only
when it is required by the underlying parser. Conditions are:
- `RHS` utilizes semantic action, or
- `RuleID` has `RuleID::on_success(...)`, or
- `RuleID` has `RuleID::on_error(...)`.
This optimization resolves the last runtime overhead mentioned in #11,
where the additional reference bound to `_val` was materialized
regardless of whether it is actually used by the underlying parser.
Note that the `as<T>(...)` directive (#53) has a special case handling
that hides the existence of semantic action in the underlying parser.
This commit adds the new static bool trait `::need_rcontext` to detect
such cases.
* Assert actual type bound to `_val` in `on_error`/`on_success`
X3 has had created `rcontext` unconditionally for any parser
invocations. That led X4 to do the same even after #37 was merged. This
commit further optimizes the implementation to create `rcontext` only
when it is required by the underlying parser. Conditions are:
- `RHS` utilizes semantic action, or
- `RuleID` has `RuleID::on_success(...)`, or
- `RuleID` has `RuleID::on_error(...)`.
This optimization resolves the last runtime overhead mentioned in #11,
where the additional reference bound to `_val` was materialized
regardless of whether it is actually used by the underlying parser.
Note that the `as<T>(...)` directive (#53) has a special case handling
that hides the existence of semantic action in the underlying parser.
This commit adds the new static bool trait `::need_rcontext` to detect
such cases.