Great! Thats what I was looking for.

On 12/09/15 18:12, Thierry Goubier wrote:
Hi Julien, Mark and Peter,

here is a RB approach:

| rewriter |
rewriter := RBParseTreeRewriter new
replace: ' `#aLiteral `{:node | node value isCharacter}'
    with: '`#aLiteral aMessage'; yourself.
rewriter executeTree: (RBParser parseExpression: 'Array with: $a asciiValue with: $b with: #c with: d').
rewriter tree formattedCode

And the result is:

 'Array
    with: $a aMessage asciiValue
    with: $b aMessage
    with: #c
    with: d'

Need to keep all those snipets somewhere. And I think the chapter in Pharo for the enterprise does not explain well the conditional stuff in { }.

Thierry


Le 12/09/2015 16:03, Mark Rizun a écrit :
Hi everyone,

I believe you should be able to do this transformation with Rewrite Tool. The only problem I see is that you want to do this only with single symbol.
Because, in my tool you can do:

transform: *`#literal* into: *`#literal aMessage*.
In this case `#literal**means any literal, not only symbols.
In other words it will transform

$a into $a aMessage

Also, this rule will transform, for instance
123 into 123 aMessage

If I understand right, you would like to do this programatically, so you
don't need RewriteTool in that case.

Mark

2015-09-12 16:46 GMT+03:00 Peter Uhnák <i.uh...@gmail.com
<mailto:i.uh...@gmail.com>>:

    If you don't want to manually operate on AST, you can use Mark's
    Rewrite Tool ( http://screencast.com/t/LCEl0hFl ,
https://medium.com/@peteruhnak/using-rewrite-tool-for-fixing-deprecated-code-12a595b291d8
    )

    As for ASTs I would be also curious about the answer, as this seems
    like it should be a simple task.

    Peter

    On Sat, Sep 12, 2015 at 2:24 PM, Julien Delplanque <jul...@tamere.eu
    <mailto:jul...@tamere.eu>> wrote:

        Hi everyone,

        I would like to modify the AST of a smalltalk expression
        compiled to automatically send a certain message
        when a node represents a Character (so the user does not have to
        write the message sending explicitly).
        I would of course add a special button in the menu you get when
        right clicking in a playground so the user
        knows it is a "special" do-it...

        For example:
             $a.
        would transform into an ast that the source code looks like
             $a aMessage

        How can I do this? :)

        Julien







Reply via email to