The purpose here is the very same as the purpose above. The only
difference is the name of the types. Here, instead of the
passed-in attribute type being named Attribute_, the name
is ActualAttribute, and instead of the rule's attribute
being named attribute_type, the
name is simply Attribute.
Proposed use of "RHS" transform_attribute
Currently, the x3 docs require that the rule attribute is
"compatible" with the RHS
attribute (page
96).
The propsed RHS transform would relieve the end-user of this
compatibility constraint by transforming a possibly incompatible
rule attribute to the RHS's attribute.
If such a RHS transform_attribute's post returns
a bool value, then it could be used to replace some
semantic actions and changes to the context, as
shown here.
This RHS transform_attribute use could be placed somewhere after
the external transform attribute use, possibly in
the call_rule_defintion body just
before parse_rhs call here.
using rhs_attr=
typename traits::attribute_of<RHS,Context>::type
;
using transform=
traits::transform_attribute_tagged
< ActualAttribute
, rhs_attr
, rule_internal_id<ID>
>;
using transform_type=typename transform::type;
transform_type rhs_actual=
transform::pre
( attr_
);
ok_parse = parse_rhs
( rhs
, first
, last
, context
, attr_//RContext&
//Rule Context, to allow actions to access rule attribute.
//see val_context in core/call.hpp.
, rhs_actual
, has_action_and_not_explicit_propagation_t()
);
if(ok_parse)
{
ok_parse=transform::post(attr_,rhs_actual);
}
<!DOCTYPE html>
Existing use of "external" transform_attribute
The transform_attribute class is used in 2 places
rule::parse function
The purpose here is to transform the passed-in, or external, attribute type,
Attribute_
, to the rule's attribute,attribute_type
.call_rule_definition function
The purpose here is the very same as the purpose above. The only difference is the name of the types. Here, instead of the passed-in attribute type being named
Attribute_
, the name isActualAttribute
, and instead of the rule's attribute being namedattribute_type
, the name is simplyAttribute
.Proposed use of "RHS" transform_attribute
Currently, the x3 docs require that the rule attribute is "compatible" with the RHS attribute (page 96).
The propsed RHS transform would relieve the end-user of this compatibility constraint by transforming a possibly incompatible rule attribute to the RHS's attribute.
If such a RHS transform_attribute's
post
returns abool
value, then it could be used to replace some semantic actions and changes to thecontext
, as shown here.This RHS transform_attribute use could be placed somewhere after the external transform attribute use, possibly in the
call_rule_defintion
body just beforeparse_rhs
call here.using rhs_attr= typename traits::attribute_of<RHS,Context>::type ; using transform= traits::transform_attribute_tagged < ActualAttribute , rhs_attr , rule_internal_id<ID> >; using transform_type=typename transform::type; transform_type rhs_actual= transform::pre ( attr_ ); ok_parse = parse_rhs ( rhs , first , last , context , attr_//RContext& //Rule Context, to allow actions to access rule attribute. //see val_context in core/call.hpp. , rhs_actual , has_action_and_not_explicit_propagation_t() ); if(ok_parse) { ok_parse=transform::post(attr_,rhs_actual); }