Hi,
Thanks for your interest in Kiama. We hope it will be useful for your work :-)
I am a bit confused by your question, however, since the output you are getting seems to be consistent with the everywheretd strategy that you are using. In a nutshell, everywheretd(r) will first apply r to the current node, then to all of that node's children. Thus you see the “oldTerm => newTerm” output for a node, before you see it for its children.
Perhaps you want a bottom-up version instead such as everywherebu?
However, it’s not clear you can get exactly the output that you target since the example you give seems to separate the output from the r1 rule, such as
* R1: KiamaTreeNode(KiamaTreeNode(KiamaLeaf(1),KiamaLeaf(2)), KiamaLeaf(3))
from the log printed by the “rewriting” method:
KiamaTreeNode(KiamaTreeNode(KiamaLeaf(1),KiamaLeaf(2)),KiamaLeaf(3)) => KiamaTreeNode(KiamaTreeNode(KiamaLeaf(11),KiamaLeaf(12)),KiamaLeaf(13))
but that won’t be possible using CallbackRewriter since it calls the rewriting method immediately after the rewrite rule has been applied.
Can you describe in more detail the effect you are trying to achieve in terms of tree rewrites? I presume the use of CallbackRewriter is just to get debugging output and isn’t crucial to the application.
regards,