Re: [Pharo-users] AST tokens question

2014-10-30 Thread stepharo
this one is in SmaCC. I'll see if I can switch to your solution. I had a look at Nautilus add protocol for fun. 2303 entries for a subclass of MorphTreeModel :( I reduce that to 11 entries in AltBrowser add protocol for the same use case. :( Same feeling here but we will live with it for now.

Re: [Pharo-users] AST tokens question

2014-10-30 Thread Thierry Goubier
Hi Stef, this one is in SmaCC. I'll see if I can switch to your solution. I had a look at Nautilus add protocol for fun. 2303 entries for a subclass of MorphTreeModel :( I reduce that to 11 entries in AltBrowser add protocol for the same use case. Thierry

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Marcus Denker
> On 29 Oct 2014, at 16:27, Thierry Goubier wrote: > > > > 2014-10-29 16:17 GMT+01:00 Mark Rizun >: > You mean the changes tool in Monticello ? > > No I mean, that before your rule is applied you will see the same window, > when you choose refactoring. > I mean Chan

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 16:17 GMT+01:00 Mark Rizun : > You mean the changes tool in Monticello ? >> > > No I mean, that before your rule is applied you will see the same window, > when you choose refactoring. > I mean Changes Browser. Here it is: > > [image: Вбудоване зображення 1] > > Ok, thanks. this is a g

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
> > You mean the changes tool in Monticello ? > No I mean, that before your rule is applied you will see the same window, when you choose refactoring. I mean Changes Browser. Here it is: [image: Вбудоване зображення 1]

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 15:54 GMT+01:00 Mark Rizun : > This is the one which sounds difficult for me. Patterns are fairly global >> in nature, and they may match synonyms (i.e. methods of the same name but >> with different meanings), so I'm worried about the mastery of my changes. >> >> For an isNil ifTrue: t

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
> > This is the one which sounds difficult for me. Patterns are fairly global > in nature, and they may match synonyms (i.e. methods of the same name but > with different meanings), so I'm worried about the mastery of my changes. > > For an isNil ifTrue: to ifNil:, it's easy. But for an indexAt: to

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 11:41 GMT+01:00 Mark Rizun : > I had a look at the video, and it looks great. Certainly the way to go. >> > Well, it's not that great. And it shows pretty old version of what I have > now. I should make a new better one:) > > >> I had some ideas along those, but I never have time to try

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
> > I had a look at the video, and it looks great. Certainly the way to go. > Well, it's not that great. And it shows pretty old version of what I have now. I should make a new better one:) > I had some ideas along those, but I never have time to try them. My > interest would have been to show ho

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 11:16 GMT+01:00 Mark Rizun : > I misunderstood you, of course I can find the node in old ast which was > replaced, using operator =. > Sure it works, but the problem is I have to pass oldNodes each time from > old node to new one. > I think you can work recreating the ast. I'm not sure

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 11:11 GMT+01:00 Mark Rizun : > This is well how I understood it. >> >> Are you implementing something around the use of refactoring? >> > > I'm implementing tool for creating rewrite rules. Here is a blog about > it: http://myfuncoding.blogspot.com/ > Also I write chapter for PharoForE

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
P.S. Moreover, it's not only that I have to pass oldNodes each time from old node to new one. Each time I replace node I reparse tree and I lose oldNodes from each node of ast:) So, I have to pass oldNodes from each node of ast to each coresponding node of new ast. And it's a real problem. 2014-1

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
I misunderstood you, of course I can find the node in old ast which was replaced, using operator =. Sure it works, but the problem is I have to pass oldNodes each time from old node to new one.

Re: [Pharo-users] AST tokens question

2014-10-29 Thread stepharo
Thanks thierry and mark for this interesting discussion! Stef On 27/10/14 13:36, Mark Rizun wrote: Hi all, Trying to understand here how tokens are used in AST. So far I can not see any order in usage of tokens. For instance, why RBValueNode doesn't have token? Is it haow it's supposed to be?

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
> > This is well how I understood it. > > Are you implementing something around the use of refactoring? > I'm implementing tool for creating rewrite rules. Here is a blog about it: http://myfuncoding.blogspot.com/ Also I write chapter for PharoForEnterprise: https://github.com/SquareBracketAssoci

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 10:44 GMT+01:00 Mark Rizun : > > > 2014-10-29 11:40 GMT+02:00 Thierry Goubier : > >> >> >> 2014-10-29 10:22 GMT+01:00 Mark Rizun : >> >>> Second one, I do replace node all the time. >>> >> >> You insert new code inside the text view? >> > > Yes > > >> >> For me, if you replace nodes and

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
2014-10-29 11:40 GMT+02:00 Thierry Goubier : > > > 2014-10-29 10:22 GMT+01:00 Mark Rizun : > >> Second one, I do replace node all the time. >> > > You insert new code inside the text view? > Yes > > For me, if you replace nodes and display that, then you are "slowly" > replacing nodes. Anything

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 10:22 GMT+01:00 Mark Rizun : > Second one, I do replace node all the time. > You insert new code inside the text view? For me, if you replace nodes and display that, then you are "slowly" replacing nodes. Anything which has some display to a user in the loop is "slow". > Thinking a

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 10:09 GMT+01:00 Mark Rizun : > P.S. I have a solution, but don't know if it's appropriate: I remove > updating of source interval from replaceWith: method, but my tool will do > all the calculations of interval on it's own. > This is a possibility: have a transform; when you get select

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
Second one, I do replace node all the time. Thinking a bit about it, I'd try reparse, get node from selection index, > find equal old node in old (modified) ast, or replace old (modified) ast > with new one. > Can you explain this, sorry I didn't get the point

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 9:59 GMT+01:00 Mark Rizun : > > I use source intervals to detect which node is selected and than in the > right-click menu user can see only options that are relevanto to selected > node, as it is also made in SmartSuggestions. > I know that use case ;) Ok, then this means you are reg

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
P.S. I have a solution, but don't know if it's appropriate: I remove updating of source interval from replaceWith: method, but my tool will do all the calculations of interval on it's own. 2014-10-29 10:59 GMT+02:00 Mark Rizun : > That is way I'd like to have automatically updated source interval

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
> > That is way I'd like to have automatically updated source interval. >> > > I'm still not entirely sure why. Source intervals are only there to help > relating the ast to the source, not much else, really. > I use source intervals to detect which node is selected and than in the right-click men

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Thierry Goubier
2014-10-29 8:32 GMT+01:00 Mark Rizun : > > Which ones? > > > In my tool each node has property oldNodes, which holds collection of > obviously AST nodes:) > When I replace one of node I have to update source interval in some way. > > 1)If I update it with reparsing, I loose all data about oldNod

Re: [Pharo-users] AST tokens question

2014-10-29 Thread Mark Rizun
> Which ones? In my tool each node has property oldNodes, which holds collection of obviously AST nodes:) When I replace one of node I have to update source interval in some way. 1)If I update it with reparsing, I loose all data about oldNodes for each node of my AST. So I have to save old AST wi

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Thierry Goubier
Le 28/10/2014 14:33, Mark Rizun a écrit : In the first place why I'm doing this. I work on Rewrite Tool and it's main functionality bases on replacing nodes in AST. Plus it works with sourceIntervals of nodes. Untill now my solution was: if I replace node, I reparse tree to get intervals updated

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Mark Rizun
In the first place why I'm doing this. I work on Rewrite Tool and it's main functionality bases on replacing nodes in AST. Plus it works with sourceIntervals of nodes. Untill now my solution was: if I replace node, I reparse tree to get intervals updated However this solution brought new problems.

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Thierry Goubier
Le 28/10/2014 12:45, Mark Rizun a écrit : Yes, because they are wrong. Here is an issue: https://pharo.fogbugz.com/f/cases/14254/AST-method-replaceWith-does-not-change-source-interval I would say that they are correct. When I write source to source compilers, I admit that anything that I chan

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Mark Rizun
Yes, because they are wrong. Here is an issue: https://pharo.fogbugz.com/f/cases/14254/AST-method-replaceWith-does-not-change-source-interval 2014-10-28 13:32 GMT+02:00 Thierry Goubier : > Le 28/10/2014 12:12, Mark Rizun a écrit : > >> Well, not really. >> >> Technically, tokens are used

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Thierry Goubier
Le 28/10/2014 12:12, Mark Rizun a écrit : Well, not really. Technically, tokens are used to drive a parser from a scanner. If an AST node knows how to relate itself to its original source code chunk and is able to print itself correctly, then tokens are redundant. In sh

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Mark Rizun
> > Well, not really. > > Technically, tokens are used to drive a parser from a scanner. > > If an AST node knows how to relate itself to its original source code > chunk and is able to print itself correctly, then tokens are redundant. > > In short, if you work with parsers, you'd better know what

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Thierry Goubier
Le 28/10/2014 11:23, Mark Rizun a écrit : Thanks. I see that, however RBBlockNode or RBArrayNode doesn't have tokens. These classes have only methods in accessing-token protocol. I think it would be better if we have token object for those classes, because it makes more sense to hold such informa

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Marcus Denker
> On 28 Oct 2014, at 11:23, Mark Rizun wrote: > > Thanks. I see that, however RBBlockNode or RBArrayNode doesn't have tokens. > These classes have only methods in accessing-token protocol. > I think it would be better if we have token object for those classes, because > it makes more sense to h

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Mark Rizun
Thanks. I see that, however RBBlockNode or RBArrayNode doesn't have tokens. These classes have only methods in accessing-token protocol. I think it would be better if we have token object for those classes, because it makes more sense to hold such information in token object. Mark 2014-10-28 11

Re: [Pharo-users] AST tokens question

2014-10-28 Thread Nicolai Hess
2014-10-27 19:36 GMT+01:00 Mark Rizun : > Hi all, > > Trying to understand here how tokens are used in AST. > So far I can not see any order in usage of tokens. > For instance, why RBValueNode doesn't have token? Is it haow it's supposed > to be? > RBValueNode is an abstract class. > > Cheers,

[Pharo-users] AST tokens question

2014-10-27 Thread Mark Rizun
Hi all, Trying to understand here how tokens are used in AST. So far I can not see any order in usage of tokens. For instance, why RBValueNode doesn't have token? Is it haow it's supposed to be? Cheers, Mark