Thanks. I will look into this. In the meantime, I have another question: is there a way to specify that a certain pattern can appear multiple times and that I am interested in all occurrences? For example, I can have multiple appearances of "browser xyz" inside the following block: browser showOn: #xxx; from: #yyy; using: [ browser list ... browser tree ... browser text ] If I try to match it like: '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' It seems to only get those appearances which contain a single appearance of browser inside the block. Cheers, Doru On 3 Nov 2010, at 16:55, Lukas Renggli wrote:
However, the problem here is that I do not know how to replace all the "browser" appearances with "a" inside the andShow: block. I tried multiple variations like the one below, but I could not seem to get it to work as I want.
replace: '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' with: '`@browser transmit to: `@target; from: `@origin; andShow: [:a | a ``@.statements]';
Can anyone point me into the right direction?
Yes, you can put in the replacement code some code snippets like
`{ :context | ... }
Replace the "..." with some Smalltalk code that returns a parse tree node (or a collection of parse-tree nodes). The context-variable is a dictionary containing the current bindings of the matched nodes. So you can perform a sub-rewrite on ``@.statements to replace all accesses to `@browser with the variable a; and you return the transformed tree.
Lukas
-- Lukas Renggli www.lukas-renggli.ch
-- www.tudorgirba.com "Be rather willing to give than demanding to get."