RewriteTool matching parts of an array

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

RewriteTool matching parts of an array

Peter Uhnak
Hi,

I wanted to use RewriteTool to rewrite dynamic arrays

Source AST:
| base |
base := {#Department
->
{710 @ 255.
Color lightMagenta}}

matching AST:
| base |
base := {#Department
->
{``@first.
``@second}}

transformation:
| base |
base := {#Department -> (Array with: ``@first with: ``@second)}

However when I tried to execute it I was met with DNU OrderedCollection>>parent:

It seems that the @first/@second part are not matched properly.

Any way to fix this? Or am I doing it wrong?

Thanks,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: RewriteTool matching parts of an array

Mark Rizun
Hi Peter,

I tried to perform this transformation with RewriteTool and got the same DNU. 
 
However when I tried to execute it I was met with DNU OrderedCollection>>parent:

It seems that the @first/@second part are not matched properly.

Actually they are matched properly, because if you try to put in transformation part, for example, {``@first.``@second} everything works fine. 
 
Any way to fix this? Or am I doing it wrong?

I believe you are doing everything just fine. However, it is definately the problem of RBParseTreeRewriter or something related to it. 
Try to execute following code in playground and you will get the same DNU:

| rewriter |
rewriter := RBParseTreeRewriter new replace: '| base |
base := {(#Department
->
{``@first.
``@second})}' with: '| base |
base := {#Department -> (Array with: ``@first with: ``@second)}'.

(rewriter executeTree: (RBParser parseRewriteExpression: '| base |
base := {(#Department
->
{(1 @ 255).
(Color lightMagenta)})}'))
ifTrue: [ rewriter tree asString inspect ].

This code does exactly the same that RewriteTool should do when you put all the parts into it. 
Thus, I think, it is not a problem with the tool.

Cheers,
Mark

Reply | Threaded
Open this post in threaded view
|

Re: RewriteTool matching parts of an array

Peter Uhnak
I get the exact same error when executing the script, I am running this on Pharo 5 (50760) btw.

On Thu, Aug 11, 2016 at 3:15 PM, Mark Rizun <[hidden email]> wrote:
Hi Peter,

I tried to perform this transformation with RewriteTool and got the same DNU. 
 
However when I tried to execute it I was met with DNU OrderedCollection>>parent:

It seems that the @first/@second part are not matched properly.

Actually they are matched properly, because if you try to put in transformation part, for example, {``@first.``@second} everything works fine. 
 
Any way to fix this? Or am I doing it wrong?

I believe you are doing everything just fine. However, it is definately the problem of RBParseTreeRewriter or something related to it. 
Try to execute following code in playground and you will get the same DNU:

| rewriter |
rewriter := RBParseTreeRewriter new replace: '| base |
base := {(#Department
->
{``@first.
``@second})}' with: '| base |
base := {#Department -> (Array with: ``@first with: ``@second)}'.

(rewriter executeTree: (RBParser parseRewriteExpression: '| base |
base := {(#Department
->
{(1 @ 255).
(Color lightMagenta)})}'))
ifTrue: [ rewriter tree asString inspect ].

This code does exactly the same that RewriteTool should do when you put all the parts into it. 
Thus, I think, it is not a problem with the tool.

Cheers,
Mark


Reply | Threaded
Open this post in threaded view
|

Re: RewriteTool matching parts of an array

Peter Uhnak
Nvm, I've misread it.

Ok, I will do it manually then, and submit a bug report. :)

Thanks,

Peter

On Thu, Aug 11, 2016 at 3:31 PM, Peter Uhnák <[hidden email]> wrote:
I get the exact same error when executing the script, I am running this on Pharo 5 (50760) btw.

On Thu, Aug 11, 2016 at 3:15 PM, Mark Rizun <[hidden email]> wrote:
Hi Peter,

I tried to perform this transformation with RewriteTool and got the same DNU. 
 
However when I tried to execute it I was met with DNU OrderedCollection>>parent:

It seems that the @first/@second part are not matched properly.

Actually they are matched properly, because if you try to put in transformation part, for example, {``@first.``@second} everything works fine. 
 
Any way to fix this? Or am I doing it wrong?

I believe you are doing everything just fine. However, it is definately the problem of RBParseTreeRewriter or something related to it. 
Try to execute following code in playground and you will get the same DNU:

| rewriter |
rewriter := RBParseTreeRewriter new replace: '| base |
base := {(#Department
->
{``@first.
``@second})}' with: '| base |
base := {#Department -> (Array with: ``@first with: ``@second)}'.

(rewriter executeTree: (RBParser parseRewriteExpression: '| base |
base := {(#Department
->
{(1 @ 255).
(Color lightMagenta)})}'))
ifTrue: [ rewriter tree asString inspect ].

This code does exactly the same that RewriteTool should do when you put all the parts into it. 
Thus, I think, it is not a problem with the tool.

Cheers,
Mark