[squeak-dev] [Pharo-dev] rewrite rule help

John Brant brant at refactoryworkers.com
Sat Jun 2 02:01:08 UTC 2018


On Jun 1, 2018, at 8:25 PM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 
> Hi All,
> 
>     can anyone tell me why the following rules
> 
> 	rules
> 		replace: '``@statements. interpreterProxy pop: ``@const. interpreterProxy pushInteger: ``@integer'
> 			with: '``@statements. interpreterProxy methodReturnInteger: ``@integer';
> 		replace: '``@statements. interpreterProxy pop: ``@const. ^interpreterProxy pushInteger: ``@integer'
> 			with: '``@statements. ^interpreterProxy methodReturnInteger: ``@integer'.
> 

You need a “.” in your ``@statements (i.e., ``@.statements). The ``@ prefix matches any node, but ``@. will match a list of statements (0 or more). Currently, you are only matching sequence nodes with exactly 3 statements. You also need to add some temps in case the sequence node has temps:

	| `@temps |
	``@.statements.
	 interpreterProxy pop: ``@const. 
	^interpreterProxy pushInteger: ``@integer
->
	| `@temps |
	``@.statements.
	^interpreterProxy methodReturnInteger: ``@integer


John Brant


More information about the Squeak-dev mailing list