rewriter := RBParseTreeRewriter new replace: 'attributes := OrderedCollection new.' with: 'attributes := Set new'. tree := ConfigurationTemplate parseTreeFor: #customProjectAttributes. rewriter executeTree: tree. returns true, but: rewriter := RBParseTreeRewriter new replace: 'attributes := OrderedCollection new.' with: 'attributes := Set new. self halt'. tree := ConfigurationTemplate parseTreeFor: #customProjectAttributes. rewriter executeTree: tree. returns false. Why does adding a statement cause this rewrite to fail and how should I bet doing it? Thanks, Sean -- View this message in context: http://forum.world.st/Adding-a-statement-when-rewriting-tp4668879.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
On Feb 9, 2013, at 9:19 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
rewriter := RBParseTreeRewriter new replace: 'attributes := OrderedCollection new.' with: 'attributes := Set new'. tree := ConfigurationTemplate parseTreeFor: #customProjectAttributes. rewriter executeTree: tree. returns true, but: rewriter := RBParseTreeRewriter new replace: 'attributes := OrderedCollection new.' with: 'attributes := Set new. self halt'. tree := ConfigurationTemplate parseTreeFor: #customProjectAttributes. rewriter executeTree: tree. returns false.
Why does adding a statement cause this rewrite to fail and how should I bet doing it?
I'm puzzle too. I started to write a chapter on the rewrtie engine to force me to look at it but I got distracted.
Thanks, Sean
-- View this message in context: http://forum.world.st/Adding-a-statement-when-rewriting-tp4668879.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
stephane ducasse wrote
I'm puzzle too.
Thanks for taking a look. I got it to work by matching the source of the whole method like this: '| `@Temps | attributes := OrderedCollection new. (condition) ifTrue: [ attributes add: #zinc ] "My new statement here". ``@.Statements.'. My naive guess is that if you try to modify more than a single node, you must operate on the next biggest node... -- View this message in context: http://forum.world.st/Adding-a-statement-when-rewriting-tp4668879p4668894.ht... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
stephane ducasse wrote
I started to write a chapter on the rewrtie engine to force me to look at it but I got distracted.
I found http://www.refactory.com/the-rewritetool which is a good starting point... -- View this message in context: http://forum.world.st/Adding-a-statement-when-rewriting-tp4668879p4668909.ht... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
participants (2)
-
Sean P. DeNigris -
stephane ducasse