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

Implement syntax for specifying a specific occurrence of a node in a transformation rule #71

Open
bugdea1er opened this issue Aug 4, 2022 · 9 comments

Comments

@bugdea1er
Copy link
Contributor

For more accurate mutations, it will be more convenient to replace not all occurrences of a node that fits the transformation rule, but to indicate the number of a specific occurrence of the node.
For example, if I give the tree transformer the rule

Binop(#1, #2)<\"+\"> -> Binop(#1, #2)<\"-\">

and the occurence number 1, I expect for the example 5 + 4 + 5 + 4 get form the tree trasnformer 5 - 4 + 5 + 4 up to the way the nodes in the tree are numbered.

@kniazkov
Copy link
Member

kniazkov commented Aug 5, 2022

Let's clarify. Let's say our code contains two such expressions:

a = 1 + 2 + 3 + 4
b = 5 + 6 + 7 + 8

Accordingly, the syntax tree will contain branches for two such expressions. You want the rule to be applied only once for each such expression, that is, like this:

a = 1 - 2 + 3 + 4
b = 5 - 6 + 7 + 8

?

@bugdea1er
Copy link
Contributor Author

With the proposed syntax, I would expect the tree transformer to change only one node for the entire given tree in the TreeProcessor::transform method, i.e. the rule is only applied once.

Also, I believe it would be convenient to have a method that returns the number of nodes that can be transformed by a given rule. So if I have this number in the possibleTransformations variable I could run

for (int i = 0; i < possibleTransformations; i++) {
  treeTransformer.transform(tree, i);
}

to get a list of all possible variants with the mutation applied only once to different nodes.

@pollyvolk
Copy link
Member

Working on the implementation of this feature in API.

@kniazkov
Copy link
Member

@rultor release, tag is 0.2.3

@rultor
Copy link
Collaborator

rultor commented Aug 19, 2022

@rultor release, tag is 0.2.3

@kniazkov OK, I will release it now. Please check the progress here

@rultor
Copy link
Collaborator

rultor commented Aug 19, 2022

@rultor release, tag is 0.2.3

@kniazkov Done! FYI, the full log is here (took me 8min)

@kniazkov
Copy link
Member

kniazkov commented Sep 1, 2022

@rultor release, tag is 0.2.4

@rultor
Copy link
Collaborator

rultor commented Sep 1, 2022

@rultor release, tag is 0.2.4

@kniazkov OK, I will release it now. Please check the progress here

@rultor
Copy link
Collaborator

rultor commented Sep 1, 2022

@rultor release, tag is 0.2.4

@kniazkov Done! FYI, the full log is here (took me 8min)

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

4 participants