Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need for "RHS" transform_attribute #780

Open
cppljevans opened this issue Dec 8, 2023 · 0 comments
Open

need for "RHS" transform_attribute #780

cppljevans opened this issue Dec 8, 2023 · 0 comments

Comments

@cppljevans
Copy link
Contributor

cppljevans commented Dec 8, 2023

<title>Need for "RHS" transform_attribute</title>

Existing use of "external" transform_attribute

The transform_attribute class is used in 2 places

  1. within rule::parse function
  2. The purpose here is to transform the passed-in, or external, attribute type, Attribute_, to the rule's attribute, attribute_type.

  3. within call_rule_definition function
  4. 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); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant