On 23 août 2013, at 05:16, Gisela Decuzzi wrote:

> Hi Camille! 
> Thanks for the details about using the dot.
> I know that for this case is better matching an expression but it sounded 
> strange at the begining the behavior inside the block despite of the ``@

As far as I understand, there is no difference between ` and `` when you try to 
match a method because there is no such thing as a submethod.
No matter where you recurse in a method, you'll never find another method that 
can potentially match.

> I will take a look in the matching.

Good luck. 
Stef suggested to see in visualworks if there is a new version.

> Because like that we cannot say that we don't care if we have that piece of 
> code and we should repeat the pattern with an or containing the block and 
> without it.

What you can do is still to try matching an expression but with an additional 
condition. 
By the way I forgot to mention the `{ :node | "some smalltalk code here" } 
syntax in my last mail: it permits to match only the nodes that satisfy the 
"wrapped block".

> But I don't understand if the actual behavior is really a bug or it's a 
> feature...

Its more a limitation.

> 
> 
> 2013/8/21 Camille Teruel <camille.ter...@gmail.com>
> Hello Gisela,
> 
> On 21 août 2013, at 15:43, Gisela Decuzzi wrote:
> 
>> Hello, I'm trying to understand how to define a correct pattern and I'm lost 
>> with the cases where I use a method pattern and the desired code is inside a 
>> block.
>> In the case where we search (methods) with metavariables and the code is 
>> inside a block.
>> 
>> An Example:
>> 
>> This pattern
>> `a: `aa `b: `bb
>> | `@temps |
>>   ``@.Stats.
>>  ``@.some size ``@.more. 
>>  ``@.Stats2.
> 
> Putting a dot after the @ means that you want to match statements.
> So '``@.some size'  cannot match:  'arg1 size'.
> 
>> Does not match with:
>> insideABlock: arg1 part2: arg2
>>      |temp1  temp3|
>>      [arg1 size].
>>      temp1 := arg2 + 3.
>>      ^arg2
> 
> Then even if you remove the extra dots, the rule won't match the method you 
> give.
> This is because this method has no statements matching '``@some size' (even 
> if it has a block that has a statement that can).
> So here is a rule that can match your method:
> `a: `aa `b: `bb
> | `@temps |
>   `@.stms1.
>  [ `@rcv size ]. 
>  `@.stms2.
> 
> 
>> After looking while I realize that is not matching with
>> part1: arg1 part2: arg2
>>      |temp1 temp2 temp3|
>>      arg1 size.
>>      temp1 := arg2 + 3.
>>      ^arg2
> 
> This one however can be matched by your rule (without the extra dots).
> I think that you should try to parse expressions instead of full methods 
> (RBParseTreeSearcher>>#matches:do: instead of 
> RBParseTreeSearcher>>#matchesMethod:do:). 
> You could just try to match '`@rcv size': it would succeed in both methods.
> 
>> 
>> Until I understand:
>>  ``@.some size ``@.more. 
>> This should mean: anything that sends the message size, doesn't matter if we 
>> have something before or after, I think that this expression should match 
>> both cases.
>> 
>> But maybe I'm missunderstanding the patterns (again).
> 
> It should work like that (modulo bugs)
> ` denotes a metavariable
> adding @ means you're looking for a list of elements 
> ex: `receiver `@msg: `@arg matches every message
> adding a . means you're looking for a statement (or a list of statement if 
> you combine it with @)
> adding # means you're looking for a literal
> adding another ` means that the pattern will be searched recursively in each 
> subexpressions even if the top one already matched 
> it sometimes leads to infinite loops, but I don't remember exactly when 
> ex: in 'foo bar bar' :
> if you search for '`rcv bar' you'll find one match ('foo bar bar')
> if you search for '``rcv bar' you'll find two matches ('foo bar' and 'foo bar 
> bar').
> and I think it's all
> 
>> 
>> Any help with this will be really welcome!
>> 
>> 
> 
> 

Reply via email to