On Mon, Nov 9, 2015 at 4:07 AM, stepharo <[email protected]> wrote: > mariano did you try the tool developed by mark rizun? > because I always fail to get the expression correct. >
I wasn't aware of this tool. I am checking it right now. Unfortunately, the smalltalk hub page has no documentation. So I must search a bit first. > We spent some times trying to document the pattern language but to us it > is not really coherent. > Jean-Christophe was expert in parse tree rewriting and he got lost. > > There is a chapter in PharoInProgress. > > I could not find it. Could you please send me the link? Thanks! > We are prototyping alternatives because we need better tools. > > Stef > > Le 9/11/15 06:38, Thierry Goubier a écrit : > > Hi Mariano, >> >> Le 09/11/2015 01:13, Mariano Martinez Peck a écrit : >> >>> >>> >>> On Fri, Nov 6, 2015 at 1:59 PM, Mariano Martinez Peck >>> <[email protected] <mailto:[email protected]>> wrote: >>> >>> ... >> >>> >>> Hi Thierry, >>> >>> I am trying to achieve a similar case like the one I commented in this >>> post but I am unable to find the way. >>> Previously I wanted to replace say the literal #oldSelector to >>> #newSelector. Now, I need to use regular expressions. I mean, I would >>> need to find matches of '*oldSelector*' and do the replace with >>> 'newSelector'. For example, the search may find >>> '*pre*oldSelector*post*' and I want it to be replaced by >>> '*pre*newSelector*post'. *And of course, I don't know in advance what >>> pre and post strings there could be. >>> >> >> What you need to do there is to use a match block after the @selector >> >> `{:node | node selector matches: '.*oldSelector.*'} >> >> Which would mean that your patterns become: >> >> rewriter >> replace: '``@object `oldSelector {:node | node selector matches: >> '.*oldSelector.*'}' >> with: '``@object `newSelector {:node | node selector }'. >> >> Wait, not entirely sure. I think you need to add a dictionary in the >> block to give the with: argument the pre and post string. And I'm not sure >> about the regular expression above as well. >> >> I need to have access to the SmaCC code source, so I'll answer to you a >> bit later. >> >> >>> Also..do you know where can I find some more info about RB? For example, >>> if I read this: >>> >>> rewriter >>> replace: '``@object ' , oldSeletor >>> with: '``@object ' , newSelector. >>> >>> Where can I read that ``@object means XXX .. ? >>> >> >> There is a first level of explanation in the Pharo for the Enterprise >> book; but, yes the pattern language is fairly complex. >> >> Are you going to Smalltalks? John Brant is there and will give a talk on >> RB and SmaCC (two talks, I believe). >> >> Thierry >> >> Thanks in advance! >>> >>> >>> >>> Or a cascade: a RBParseTreeSearcher which matches blocks; on >>> each block node you activate a rewriter. >>> >>> However, there is an issue in rewriting blocks contents, because >>> it supposes that the method defining the block is recompiled; >>> it's significantly harder to make changes to the code of live >>> blocks (change the bytescode itself? What if the block has >>> multiples instances?). >>> >>> Thierry >>> >>> >>> If not, I think my easiest path is to automatically compile >>> dummy/temporal classes/methods from the rules, perform the >>> refactor, then move source from methods to block closures, >>> and finally remove created classes. >>> >>> Any pointer is appreciated. >>> >>> best, >>> >>> -- >>> Mariano >>> http://marianopeck.wordpress.com >>> >>> >>> >>> >>> >>> -- >>> Mariano >>> http://marianopeck.wordpress.com >>> >>> >>> >>> >>> -- >>> Mariano >>> http://marianopeck.wordpress.com >>> >> >> >> >> > > -- Mariano http://marianopeck.wordpress.com
