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

Fix the trampoline functions of recurring labeled alternatives #243

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

akosthekiss
Copy link
Collaborator

These trampoline functions are normally only used in mutation scenarios when a subtree of a labeled alternative is re-generated by calling the function named as the labeled alternative. If the label is recurring, this function is an artificial trampoline that calls one of the functions that have the same name prefix but differ in a numbered suffix (e.g., rule_Label calls rule_Label_1 or rule_Label_2). The trampoline function is expected to be transparent, i.e., to create a tree structure as if one of the number-suffixed functions was called.

However, until now, the tree structures created by the trampolines and the way the trees were created were incorrect. The trampoline created two extra nodes in the tree: one UnparserRule node named as the labeled alternative (e.g., rule_Lable) and one UnparserRuleAlternative node.

  • Issue 1: Both nodes are superfluous in the end result.
  • Issue 2: Both nodes are necessary to help the decision model choose between the number-suffixed functions. But then, the UnparserRule should be named as the main rule that contains the labeled alternatives (e.g., rule).

This commit fixes both issues.

These trampoline functions are normally only used in mutation
scenarios when a subtree of a labeled alternative is re-generated
by calling the function named as the labeled alternative. If the
label is recurring, this function is an artificial trampoline that
calls one of the functions that have the same name prefix but
differ in a numbered suffix (e.g., `rule_Label` calls
`rule_Label_1` or `rule_Label_2`). The trampoline function is
expected to be transparent, i.e., to create a tree structure as if
one of the number-suffixed functions was called.

However, until now, the tree structures created by the trampolines
and the way the trees were created were incorrect. The trampoline
created two extra nodes in the tree: one UnparserRule node named as
the labeled alternative (e.g., `rule_Lable`) and one
UnparserRuleAlternative node.

- Issue 1: Both nodes are superfluous in the end result.
- Issue 2: Both nodes are necessary to help the decision model
  choose between the number-suffixed functions. But then, the
  UnparserRule should be named as the main rule that contains the
  labeled alternatives (e.g., `rule`).

This commit fixes both issues.
@coveralls
Copy link

Coverage Status

coverage: 85.627% (-0.4%) from 86.015%
when pulling 4190f73 on akosthekiss:recur-trampolines
into 35417bc on renatahodovan:master.

Copy link
Owner

@renatahodovan renatahodovan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

@renatahodovan renatahodovan merged commit bcd9526 into renatahodovan:master Oct 28, 2024
23 checks passed
@akosthekiss akosthekiss deleted the recur-trampolines branch October 28, 2024 10:09
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

Successfully merging this pull request may close these issues.

3 participants