[Pharo-project] learning rewrite rules

Tudor Girba tudor.girba at gmail.com
Wed Nov 3 15:17:29 CET 2010


Hi,

I am trying to write a rewrite rule to replace something like:

browser showOn: #xxx; from: #yyy; using: [
	browser list ...
	browser tree ... ]

to something like:  

browser transmit to: #xxx; from: #yyy; andShow: [:a | 
	a list ...
	a tree ... ]


I managed to do the following:

RBParseTreeRewriter new
	replace: '`@browser showOn: `@target; from: `@origin; using: [
		``@.statements ]' with: '`@browser transmit to: `@target; from: `@origin; andShow: [:a | ``@.statements]';
	yourself

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?

Cheers,
Doru

--
www.tudorgirba.com

"What we can governs what we wish."







More information about the Pharo-project mailing list