What are RBPattern* classes in the AST?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

What are RBPattern* classes in the AST?

Steven Costiou-2

Hi,

i was browsing the classes of the AST and i am curious about the RBPattern* classes.

What are they used for?

The RBPatternParser's comment says that it is used "to search and transform source code".

After looking a bit in the senders and class refs, it seems it is used for refactorings and other stuff.

But is that used at some point in code compilation?

 

Steven.

Reply | Threaded
Open this post in threaded view
|

Re: What are RBPattern* classes in the AST?

Thierry Goubier
Hi Steven,

Le 31/03/2018 à 20:36, Steven Costiou a écrit :
> Hi,
>
> i was browsing the classes of the AST and i am curious about the
> RBPattern* classes.

> What are they used for?

They represent metavariables in pattern trees when you use refactorings.
Each pattern node specify a type of AST subtree that may be in that
place when you match some smalltalk source code against a refactoring
pattern. Once matched, an unification is done so that you can refer to
that metavariable content by name (for example, retrieve the top node of
that variable subtree).

> The RBPatternParser's comment says that it is used "to search and
> transform source code".

Exactly.

> After looking a bit in the senders and class refs, it seems it is used
> for refactorings and other stuff.

Refactorings and searches.

> But is that used at some point in code compilation?

No. But they could be used... if you do source to source transformations
when compiling, for example, you could use such patterns to rewrite the
code before compiling it; SmaCC for one uses that (create generic
methods, then scan all methods with a set of refactorings to rewrite an
optimised version of the code, such as merging contiguous character
equality tests).

For reference, have a look at:

https://www.slideshare.net/pharoproject/smack-behind-the-refactorings

Slide 31 describes the RB specifics, and the rest of the slides describe
more in detail where those pattern nodes are found and used.

Regards,

Thierry



> Steven.
>