Hi,
I am trying to write a rewrite rule to replace something like: browser showOn: #xxx; from: #yyy; using: [ browser list ... browser tree ... ] to something like: browser transmit to: #xxx; from: #yyy; andShow: [:a | a list ... a tree ... ] I managed to do the following: RBParseTreeRewriter new replace: '`@browser showOn: `@target; from: `@origin; using: [ ``@.statements ]' with: '`@browser transmit to: `@target; from: `@origin; andShow: [:a | ``@.statements]'; yourself However, the problem here is that I do not know how to replace all the "browser" appearances with "a" inside the andShow: block. I tried multiple variations like the one below, but I could not seem to get it to work as I want. replace: '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' with: '`@browser transmit to: `@target; from: `@origin; andShow: [:a | a ``@.statements]'; Can anyone point me into the right direction? Cheers, Doru -- www.tudorgirba.com "What we can governs what we wish." |
> However, the problem here is that I do not know how to replace all the "browser" appearances with "a" inside the andShow: block. I tried multiple variations like the one below, but I could not seem to get it to work as I want.
> > replace: '`@browser showOn: `@target; from: `@origin; using: [ > `@browser ``@.statements]' with: '`@browser transmit to: `@target; from: `@origin; andShow: [:a | a ``@.statements]'; > > > Can anyone point me into the right direction? Yes, you can put in the replacement code some code snippets like `{ :context | ... } Replace the "..." with some Smalltalk code that returns a parse tree node (or a collection of parse-tree nodes). The context-variable is a dictionary containing the current bindings of the matched nodes. So you can perform a sub-rewrite on ``@.statements to replace all accesses to `@browser with the variable a; and you return the transformed tree. Lukas -- Lukas Renggli www.lukas-renggli.ch |
Thanks. I will look into this.
In the meantime, I have another question: is there a way to specify that a certain pattern can appear multiple times and that I am interested in all occurrences? For example, I can have multiple appearances of "browser xyz" inside the following block: browser showOn: #xxx; from: #yyy; using: [ browser list ... browser tree ... browser text ] If I try to match it like: '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' It seems to only get those appearances which contain a single appearance of browser inside the block. Cheers, Doru On 3 Nov 2010, at 16:55, Lukas Renggli wrote: >> However, the problem here is that I do not know how to replace all the "browser" appearances with "a" inside the andShow: block. I tried multiple variations like the one below, but I could not seem to get it to work as I want. >> >> replace: '`@browser showOn: `@target; from: `@origin; using: [ >> `@browser ``@.statements]' with: '`@browser transmit to: `@target; from: `@origin; andShow: [:a | a ``@.statements]'; >> >> >> Can anyone point me into the right direction? > > Yes, you can put in the replacement code some code snippets like > > `{ :context | ... } > > Replace the "..." with some Smalltalk code that returns a parse tree > node (or a collection of parse-tree nodes). The context-variable is a > dictionary containing the current bindings of the matched nodes. So > you can perform a sub-rewrite on ``@.statements to replace all > accesses to `@browser with the variable a; and you return the > transformed tree. > > Lukas > > -- > Lukas Renggli > www.lukas-renggli.ch > -- www.tudorgirba.com "Be rather willing to give than demanding to get." |
> If I try to match it like:
> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' The match expression `@browser ``@.statements doesn't make sense. Statements (.) cannot be a message selector that would be expected after a receiver. Also, you cannot have a selector list (@) if you don't give also an argument list to match. So the closest valid thing is `@browser `message which looks for unary message sends (recursive is not necessary here either, because there is nothing to recurse into), or `@browser `@message: ``@message which looks for arbitrary message sends and recursively into all arguments. > It seems to only get those appearances which contain a single appearance of browser inside the block. As I wrote in the previous mail you need to do it with nested rewrites. Inside the block you match for any sequence of statements: `@.statements And as replacement you use the `{ :context | ... } trick to perform a new rewrite somehow along the following untested lines: `{ :context | RBParseTreeRewriter new " replace whatever matched to `@browser with the variable a " replaceTree: (context at: '`@browser') with: (RBParser parseExpression: 'a'); " execute on the list of statements " executeTree: (context at: '`@.statements'); " return the rewritten tree " tree } Cheers, Lukas -- Lukas Renggli www.lukas-renggli.ch |
In reply to this post by Tudor Girba
lukas
I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book but it would be cool if you could add to it. Stef On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >> If I try to match it like: >> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' > > The match expression > > `@browser ``@.statements > > doesn't make sense. Statements (.) cannot be a message selector that > would be expected after a receiver. Also, you cannot have a selector > list (@) if you don't give also an argument list to match. So the > closest valid thing is > > `@browser `message > > which looks for unary message sends (recursive is not necessary here > either, because there is nothing to recurse into), or > > `@browser `@message: ``@message > > which looks for arbitrary message sends and recursively into all arguments. > >> It seems to only get those appearances which contain a single appearance of browser inside the block. > > As I wrote in the previous mail you need to do it with nested > rewrites. Inside the block you match for any sequence of statements: > > `@.statements > > And as replacement you use the `{ :context | ... } trick to perform a > new rewrite somehow along the following untested lines: > > `{ :context | > RBParseTreeRewriter new > " replace whatever matched to `@browser with the variable a " > replaceTree: (context at: '`@browser') with: (RBParser > parseExpression: 'a'); > " execute on the list of statements " > executeTree: (context at: '`@.statements'); > " return the rewritten tree " > tree } > > Cheers, > Lukas > > -- > Lukas Renggli > www.lukas-renggli.ch > |
Yeah, where do I find that chapter?
There is a section on the AST matching/search in my PhD as Helvetia builds on top of it. Not on the AST rewriting though, Helvetia uses a different mechanism there. Still it might be a good start. Lukas On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: > lukas > > I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book > but it would be cool if you could add to it. > > Stef > > On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: > >>> If I try to match it like: >>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >> >> The match expression >> >> `@browser ``@.statements >> >> doesn't make sense. Statements (.) cannot be a message selector that >> would be expected after a receiver. Also, you cannot have a selector >> list (@) if you don't give also an argument list to match. So the >> closest valid thing is >> >> `@browser `message >> >> which looks for unary message sends (recursive is not necessary here >> either, because there is nothing to recurse into), or >> >> `@browser `@message: ``@message >> >> which looks for arbitrary message sends and recursively into all arguments. >> >>> It seems to only get those appearances which contain a single appearance of browser inside the block. >> >> As I wrote in the previous mail you need to do it with nested >> rewrites. Inside the block you match for any sequence of statements: >> >> `@.statements >> >> And as replacement you use the `{ :context | ... } trick to perform a >> new rewrite somehow along the following untested lines: >> >> `{ :context | >> RBParseTreeRewriter new >> " replace whatever matched to `@browser with the variable a " >> replaceTree: (context at: '`@browser') with: (RBParser >> parseExpression: 'a'); >> " execute on the list of statements " >> executeTree: (context at: '`@.statements'); >> " return the rewritten tree " >> tree } >> >> Cheers, >> Lukas >> >> -- >> Lukas Renggli >> www.lukas-renggli.ch >> > > > -- Lukas Renggli www.lukas-renggli.ch |
In reply to this post by Stéphane Ducasse
in the pharo by example git hub repository now I check that there is only an emtpy doc and your paper :).
I hope that I did not throw away what I wrote :( Stef On Nov 4, 2010, at 9:56 AM, Lukas Renggli wrote: > Yeah, where do I find that chapter? > > There is a section on the AST matching/search in my PhD as Helvetia > builds on top of it. Not on the AST rewriting though, Helvetia uses a > different mechanism there. Still it might be a good start. > > Lukas > > On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >> lukas >> >> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >> but it would be cool if you could add to it. >> >> Stef >> >> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >> >>>> If I try to match it like: >>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>> >>> The match expression >>> >>> `@browser ``@.statements >>> >>> doesn't make sense. Statements (.) cannot be a message selector that >>> would be expected after a receiver. Also, you cannot have a selector >>> list (@) if you don't give also an argument list to match. So the >>> closest valid thing is >>> >>> `@browser `message >>> >>> which looks for unary message sends (recursive is not necessary here >>> either, because there is nothing to recurse into), or >>> >>> `@browser `@message: ``@message >>> >>> which looks for arbitrary message sends and recursively into all arguments. >>> >>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>> >>> As I wrote in the previous mail you need to do it with nested >>> rewrites. Inside the block you match for any sequence of statements: >>> >>> `@.statements >>> >>> And as replacement you use the `{ :context | ... } trick to perform a >>> new rewrite somehow along the following untested lines: >>> >>> `{ :context | >>> RBParseTreeRewriter new >>> " replace whatever matched to `@browser with the variable a " >>> replaceTree: (context at: '`@browser') with: (RBParser >>> parseExpression: 'a'); >>> " execute on the list of statements " >>> executeTree: (context at: '`@.statements'); >>> " return the rewritten tree " >>> tree } >>> >>> Cheers, >>> Lukas >>> >>> -- >>> Lukas Renggli >>> www.lukas-renggli.ch >>> >> >> >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > |
In reply to this post by Stéphane Ducasse
I'm adding some other files (in french) :(
but I'm stuck with git.... > Yeah, where do I find that chapter? > > There is a section on the AST matching/search in my PhD as Helvetia > builds on top of it. Not on the AST rewriting though, Helvetia uses a > different mechanism there. Still it might be a good start. > > Lukas > > On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >> lukas >> >> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >> but it would be cool if you could add to it. >> >> Stef >> >> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >> >>>> If I try to match it like: >>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>> >>> The match expression >>> >>> `@browser ``@.statements >>> >>> doesn't make sense. Statements (.) cannot be a message selector that >>> would be expected after a receiver. Also, you cannot have a selector >>> list (@) if you don't give also an argument list to match. So the >>> closest valid thing is >>> >>> `@browser `message >>> >>> which looks for unary message sends (recursive is not necessary here >>> either, because there is nothing to recurse into), or >>> >>> `@browser `@message: ``@message >>> >>> which looks for arbitrary message sends and recursively into all arguments. >>> >>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>> >>> As I wrote in the previous mail you need to do it with nested >>> rewrites. Inside the block you match for any sequence of statements: >>> >>> `@.statements >>> >>> And as replacement you use the `{ :context | ... } trick to perform a >>> new rewrite somehow along the following untested lines: >>> >>> `{ :context | >>> RBParseTreeRewriter new >>> " replace whatever matched to `@browser with the variable a " >>> replaceTree: (context at: '`@browser') with: (RBParser >>> parseExpression: 'a'); >>> " execute on the list of statements " >>> executeTree: (context at: '`@.statements'); >>> " return the rewritten tree " >>> tree } >>> >>> Cheers, >>> Lukas >>> >>> -- >>> Lukas Renggli >>> www.lukas-renggli.ch >>> >> >> >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > |
On 4 November 2010 10:09, Stéphane Ducasse <[hidden email]> wrote:
> I'm adding some other files (in french) :( > but I'm stuck with git.... git pull git add french-rewrite.tex git commit git push >> Yeah, where do I find that chapter? >> >> There is a section on the AST matching/search in my PhD as Helvetia >> builds on top of it. Not on the AST rewriting though, Helvetia uses a >> different mechanism there. Still it might be a good start. >> >> Lukas >> >> On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >>> lukas >>> >>> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >>> but it would be cool if you could add to it. >>> >>> Stef >>> >>> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >>> >>>>> If I try to match it like: >>>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>>> >>>> The match expression >>>> >>>> `@browser ``@.statements >>>> >>>> doesn't make sense. Statements (.) cannot be a message selector that >>>> would be expected after a receiver. Also, you cannot have a selector >>>> list (@) if you don't give also an argument list to match. So the >>>> closest valid thing is >>>> >>>> `@browser `message >>>> >>>> which looks for unary message sends (recursive is not necessary here >>>> either, because there is nothing to recurse into), or >>>> >>>> `@browser `@message: ``@message >>>> >>>> which looks for arbitrary message sends and recursively into all arguments. >>>> >>>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>>> >>>> As I wrote in the previous mail you need to do it with nested >>>> rewrites. Inside the block you match for any sequence of statements: >>>> >>>> `@.statements >>>> >>>> And as replacement you use the `{ :context | ... } trick to perform a >>>> new rewrite somehow along the following untested lines: >>>> >>>> `{ :context | >>>> RBParseTreeRewriter new >>>> " replace whatever matched to `@browser with the variable a " >>>> replaceTree: (context at: '`@browser') with: (RBParser >>>> parseExpression: 'a'); >>>> " execute on the list of statements " >>>> executeTree: (context at: '`@.statements'); >>>> " return the rewritten tree " >>>> tree } >>>> >>>> Cheers, >>>> Lukas >>>> >>>> -- >>>> Lukas Renggli >>>> www.lukas-renggli.ch >>>> >>> >>> >>> >> >> >> >> -- >> Lukas Renggli >> www.lukas-renggli.ch >> > > > -- Lukas Renggli www.lukas-renggli.ch |
In reply to this post by Stéphane Ducasse
Normally I added some text in french :(
do not pay attention too much on the style dump information and like that we can get material to work on I think that having examples is the key point to get started. > > On 4 November 2010 10:09, Stéphane Ducasse <[hidden email]> wrote: >> I'm adding some other files (in french) :( >> but I'm stuck with git.... > > git pull > git add french-rewrite.tex > git commit > git push > >>> Yeah, where do I find that chapter? >>> >>> There is a section on the AST matching/search in my PhD as Helvetia >>> builds on top of it. Not on the AST rewriting though, Helvetia uses a >>> different mechanism there. Still it might be a good start. >>> >>> Lukas >>> >>> On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >>>> lukas >>>> >>>> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >>>> but it would be cool if you could add to it. >>>> >>>> Stef >>>> >>>> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >>>> >>>>>> If I try to match it like: >>>>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>>>> >>>>> The match expression >>>>> >>>>> `@browser ``@.statements >>>>> >>>>> doesn't make sense. Statements (.) cannot be a message selector that >>>>> would be expected after a receiver. Also, you cannot have a selector >>>>> list (@) if you don't give also an argument list to match. So the >>>>> closest valid thing is >>>>> >>>>> `@browser `message >>>>> >>>>> which looks for unary message sends (recursive is not necessary here >>>>> either, because there is nothing to recurse into), or >>>>> >>>>> `@browser `@message: ``@message >>>>> >>>>> which looks for arbitrary message sends and recursively into all arguments. >>>>> >>>>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>>>> >>>>> As I wrote in the previous mail you need to do it with nested >>>>> rewrites. Inside the block you match for any sequence of statements: >>>>> >>>>> `@.statements >>>>> >>>>> And as replacement you use the `{ :context | ... } trick to perform a >>>>> new rewrite somehow along the following untested lines: >>>>> >>>>> `{ :context | >>>>> RBParseTreeRewriter new >>>>> " replace whatever matched to `@browser with the variable a " >>>>> replaceTree: (context at: '`@browser') with: (RBParser >>>>> parseExpression: 'a'); >>>>> " execute on the list of statements " >>>>> executeTree: (context at: '`@.statements'); >>>>> " return the rewritten tree " >>>>> tree } >>>>> >>>>> Cheers, >>>>> Lukas >>>>> >>>>> -- >>>>> Lukas Renggli >>>>> www.lukas-renggli.ch >>>>> >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Lukas Renggli >>> www.lukas-renggli.ch >>> >> >> >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > |
I don't see any french text. Just a PDF of a blog article I wrote, the
LaTeX source of the program-checking paper, and an empty LaTeX template. Lukas On 4 November 2010 13:30, Stéphane Ducasse <[hidden email]> wrote: > Normally I added some text in french :( > do not pay attention too much on the style > dump information and like that we can get material to work on > I think that having examples is the key point to get started. > > >> >> On 4 November 2010 10:09, Stéphane Ducasse <[hidden email]> wrote: >>> I'm adding some other files (in french) :( >>> but I'm stuck with git.... >> >> git pull >> git add french-rewrite.tex >> git commit >> git push >> >>>> Yeah, where do I find that chapter? >>>> >>>> There is a section on the AST matching/search in my PhD as Helvetia >>>> builds on top of it. Not on the AST rewriting though, Helvetia uses a >>>> different mechanism there. Still it might be a good start. >>>> >>>> Lukas >>>> >>>> On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >>>>> lukas >>>>> >>>>> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >>>>> but it would be cool if you could add to it. >>>>> >>>>> Stef >>>>> >>>>> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >>>>> >>>>>>> If I try to match it like: >>>>>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>>>>> >>>>>> The match expression >>>>>> >>>>>> `@browser ``@.statements >>>>>> >>>>>> doesn't make sense. Statements (.) cannot be a message selector that >>>>>> would be expected after a receiver. Also, you cannot have a selector >>>>>> list (@) if you don't give also an argument list to match. So the >>>>>> closest valid thing is >>>>>> >>>>>> `@browser `message >>>>>> >>>>>> which looks for unary message sends (recursive is not necessary here >>>>>> either, because there is nothing to recurse into), or >>>>>> >>>>>> `@browser `@message: ``@message >>>>>> >>>>>> which looks for arbitrary message sends and recursively into all arguments. >>>>>> >>>>>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>>>>> >>>>>> As I wrote in the previous mail you need to do it with nested >>>>>> rewrites. Inside the block you match for any sequence of statements: >>>>>> >>>>>> `@.statements >>>>>> >>>>>> And as replacement you use the `{ :context | ... } trick to perform a >>>>>> new rewrite somehow along the following untested lines: >>>>>> >>>>>> `{ :context | >>>>>> RBParseTreeRewriter new >>>>>> " replace whatever matched to `@browser with the variable a " >>>>>> replaceTree: (context at: '`@browser') with: (RBParser >>>>>> parseExpression: 'a'); >>>>>> " execute on the list of statements " >>>>>> executeTree: (context at: '`@.statements'); >>>>>> " return the rewritten tree " >>>>>> tree } >>>>>> >>>>>> Cheers, >>>>>> Lukas >>>>>> >>>>>> -- >>>>>> Lukas Renggli >>>>>> www.lukas-renggli.ch >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Lukas Renggli >>>> www.lukas-renggli.ch >>>> >>> >>> >>> >> >> >> >> -- >> Lukas Renggli >> www.lukas-renggli.ch >> > > > -- Lukas Renggli www.lukas-renggli.ch |
In reply to this post by Stéphane Ducasse
no data folder?
probably forgot the push RewriteRules ls Data/ RewriteRules.tex Lint.odt program-checking-paper.tex Lint.tex RewriteRules git push Everything up-to-date RewriteRules Stef On Nov 4, 2010, at 1:45 PM, Lukas Renggli wrote: > I don't see any french text. Just a PDF of a blog article I wrote, the > LaTeX source of the program-checking paper, and an empty LaTeX > template. > > Lukas > > On 4 November 2010 13:30, Stéphane Ducasse <[hidden email]> wrote: >> Normally I added some text in french :( >> do not pay attention too much on the style >> dump information and like that we can get material to work on >> I think that having examples is the key point to get started. >> >> >>> >>> On 4 November 2010 10:09, Stéphane Ducasse <[hidden email]> wrote: >>>> I'm adding some other files (in french) :( >>>> but I'm stuck with git.... >>> >>> git pull >>> git add french-rewrite.tex >>> git commit >>> git push >>> >>>>> Yeah, where do I find that chapter? >>>>> >>>>> There is a section on the AST matching/search in my PhD as Helvetia >>>>> builds on top of it. Not on the AST rewriting though, Helvetia uses a >>>>> different mechanism there. Still it might be a good start. >>>>> >>>>> Lukas >>>>> >>>>> On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >>>>>> lukas >>>>>> >>>>>> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >>>>>> but it would be cool if you could add to it. >>>>>> >>>>>> Stef >>>>>> >>>>>> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >>>>>> >>>>>>>> If I try to match it like: >>>>>>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>>>>>> >>>>>>> The match expression >>>>>>> >>>>>>> `@browser ``@.statements >>>>>>> >>>>>>> doesn't make sense. Statements (.) cannot be a message selector that >>>>>>> would be expected after a receiver. Also, you cannot have a selector >>>>>>> list (@) if you don't give also an argument list to match. So the >>>>>>> closest valid thing is >>>>>>> >>>>>>> `@browser `message >>>>>>> >>>>>>> which looks for unary message sends (recursive is not necessary here >>>>>>> either, because there is nothing to recurse into), or >>>>>>> >>>>>>> `@browser `@message: ``@message >>>>>>> >>>>>>> which looks for arbitrary message sends and recursively into all arguments. >>>>>>> >>>>>>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>>>>>> >>>>>>> As I wrote in the previous mail you need to do it with nested >>>>>>> rewrites. Inside the block you match for any sequence of statements: >>>>>>> >>>>>>> `@.statements >>>>>>> >>>>>>> And as replacement you use the `{ :context | ... } trick to perform a >>>>>>> new rewrite somehow along the following untested lines: >>>>>>> >>>>>>> `{ :context | >>>>>>> RBParseTreeRewriter new >>>>>>> " replace whatever matched to `@browser with the variable a " >>>>>>> replaceTree: (context at: '`@browser') with: (RBParser >>>>>>> parseExpression: 'a'); >>>>>>> " execute on the list of statements " >>>>>>> executeTree: (context at: '`@.statements'); >>>>>>> " return the rewritten tree " >>>>>>> tree } >>>>>>> >>>>>>> Cheers, >>>>>>> Lukas >>>>>>> >>>>>>> -- >>>>>>> Lukas Renggli >>>>>>> www.lukas-renggli.ch >>>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Lukas Renggli >>>>> www.lukas-renggli.ch >>>>> >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Lukas Renggli >>> www.lukas-renggli.ch >>> >> >> >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > |
There is a Data folder, but only the pdf of my blog is in there.
Lukas On 4 November 2010 14:04, Stéphane Ducasse <[hidden email]> wrote: > no data folder? > probably forgot the push > > RewriteRules ls > Data/ RewriteRules.tex > Lint.odt program-checking-paper.tex > Lint.tex > RewriteRules git push > Everything up-to-date > RewriteRules > > > > Stef > > On Nov 4, 2010, at 1:45 PM, Lukas Renggli wrote: > >> I don't see any french text. Just a PDF of a blog article I wrote, the >> LaTeX source of the program-checking paper, and an empty LaTeX >> template. >> >> Lukas >> >> On 4 November 2010 13:30, Stéphane Ducasse <[hidden email]> wrote: >>> Normally I added some text in french :( >>> do not pay attention too much on the style >>> dump information and like that we can get material to work on >>> I think that having examples is the key point to get started. >>> >>> >>>> >>>> On 4 November 2010 10:09, Stéphane Ducasse <[hidden email]> wrote: >>>>> I'm adding some other files (in french) :( >>>>> but I'm stuck with git.... >>>> >>>> git pull >>>> git add french-rewrite.tex >>>> git commit >>>> git push >>>> >>>>>> Yeah, where do I find that chapter? >>>>>> >>>>>> There is a section on the AST matching/search in my PhD as Helvetia >>>>>> builds on top of it. Not on the AST rewriting though, Helvetia uses a >>>>>> different mechanism there. Still it might be a good start. >>>>>> >>>>>> Lukas >>>>>> >>>>>> On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >>>>>>> lukas >>>>>>> >>>>>>> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >>>>>>> but it would be cool if you could add to it. >>>>>>> >>>>>>> Stef >>>>>>> >>>>>>> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >>>>>>> >>>>>>>>> If I try to match it like: >>>>>>>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>>>>>>> >>>>>>>> The match expression >>>>>>>> >>>>>>>> `@browser ``@.statements >>>>>>>> >>>>>>>> doesn't make sense. Statements (.) cannot be a message selector that >>>>>>>> would be expected after a receiver. Also, you cannot have a selector >>>>>>>> list (@) if you don't give also an argument list to match. So the >>>>>>>> closest valid thing is >>>>>>>> >>>>>>>> `@browser `message >>>>>>>> >>>>>>>> which looks for unary message sends (recursive is not necessary here >>>>>>>> either, because there is nothing to recurse into), or >>>>>>>> >>>>>>>> `@browser `@message: ``@message >>>>>>>> >>>>>>>> which looks for arbitrary message sends and recursively into all arguments. >>>>>>>> >>>>>>>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>>>>>>> >>>>>>>> As I wrote in the previous mail you need to do it with nested >>>>>>>> rewrites. Inside the block you match for any sequence of statements: >>>>>>>> >>>>>>>> `@.statements >>>>>>>> >>>>>>>> And as replacement you use the `{ :context | ... } trick to perform a >>>>>>>> new rewrite somehow along the following untested lines: >>>>>>>> >>>>>>>> `{ :context | >>>>>>>> RBParseTreeRewriter new >>>>>>>> " replace whatever matched to `@browser with the variable a " >>>>>>>> replaceTree: (context at: '`@browser') with: (RBParser >>>>>>>> parseExpression: 'a'); >>>>>>>> " execute on the list of statements " >>>>>>>> executeTree: (context at: '`@.statements'); >>>>>>>> " return the rewritten tree " >>>>>>>> tree } >>>>>>>> >>>>>>>> Cheers, >>>>>>>> Lukas >>>>>>>> >>>>>>>> -- >>>>>>>> Lukas Renggli >>>>>>>> www.lukas-renggli.ch >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Lukas Renggli >>>>>> www.lukas-renggli.ch >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Lukas Renggli >>>> www.lukas-renggli.ch >>>> >>> >>> >>> >> >> >> >> -- >> Lukas Renggli >> www.lukas-renggli.ch >> > > > -- Lukas Renggli www.lukas-renggli.ch |
In reply to this post by Stéphane Ducasse
git status
git add . git commit git push :) On 04/11/10 14:04, Stéphane Ducasse wrote: > no data folder? > probably forgot the push > > RewriteRules ls > Data/ RewriteRules.tex > Lint.odt program-checking-paper.tex > Lint.tex > RewriteRules git push > Everything up-to-date > RewriteRules -- [hidden email] http://www.agilitic.com +32 (0)484/580.322 |
In reply to this post by Stéphane Ducasse
ok I added the files this is better.
stef On Nov 4, 2010, at 2:07 PM, Lukas Renggli wrote: > There is a Data folder, but only the pdf of my blog is in there. > > Lukas > > On 4 November 2010 14:04, Stéphane Ducasse <[hidden email]> wrote: >> no data folder? >> probably forgot the push >> >> RewriteRules ls >> Data/ RewriteRules.tex >> Lint.odt program-checking-paper.tex >> Lint.tex >> RewriteRules git push >> Everything up-to-date >> RewriteRules >> >> >> >> Stef >> >> On Nov 4, 2010, at 1:45 PM, Lukas Renggli wrote: >> >>> I don't see any french text. Just a PDF of a blog article I wrote, the >>> LaTeX source of the program-checking paper, and an empty LaTeX >>> template. >>> >>> Lukas >>> >>> On 4 November 2010 13:30, Stéphane Ducasse <[hidden email]> wrote: >>>> Normally I added some text in french :( >>>> do not pay attention too much on the style >>>> dump information and like that we can get material to work on >>>> I think that having examples is the key point to get started. >>>> >>>> >>>>> >>>>> On 4 November 2010 10:09, Stéphane Ducasse <[hidden email]> wrote: >>>>>> I'm adding some other files (in french) :( >>>>>> but I'm stuck with git.... >>>>> >>>>> git pull >>>>> git add french-rewrite.tex >>>>> git commit >>>>> git push >>>>> >>>>>>> Yeah, where do I find that chapter? >>>>>>> >>>>>>> There is a section on the AST matching/search in my PhD as Helvetia >>>>>>> builds on top of it. Not on the AST rewriting though, Helvetia uses a >>>>>>> different mechanism there. Still it might be a good start. >>>>>>> >>>>>>> Lukas >>>>>>> >>>>>>> On 4 November 2010 09:49, Stéphane Ducasse <[hidden email]> wrote: >>>>>>>> lukas >>>>>>>> >>>>>>>> I would love to have a chapter on Rules. I have a starter that I wrote long time ago for the squeak french book >>>>>>>> but it would be cool if you could add to it. >>>>>>>> >>>>>>>> Stef >>>>>>>> >>>>>>>> On Nov 4, 2010, at 12:55 AM, Lukas Renggli wrote: >>>>>>>> >>>>>>>>>> If I try to match it like: >>>>>>>>>> '`@browser showOn: `@target; from: `@origin; using: [ `@browser ``@.statements]' >>>>>>>>> >>>>>>>>> The match expression >>>>>>>>> >>>>>>>>> `@browser ``@.statements >>>>>>>>> >>>>>>>>> doesn't make sense. Statements (.) cannot be a message selector that >>>>>>>>> would be expected after a receiver. Also, you cannot have a selector >>>>>>>>> list (@) if you don't give also an argument list to match. So the >>>>>>>>> closest valid thing is >>>>>>>>> >>>>>>>>> `@browser `message >>>>>>>>> >>>>>>>>> which looks for unary message sends (recursive is not necessary here >>>>>>>>> either, because there is nothing to recurse into), or >>>>>>>>> >>>>>>>>> `@browser `@message: ``@message >>>>>>>>> >>>>>>>>> which looks for arbitrary message sends and recursively into all arguments. >>>>>>>>> >>>>>>>>>> It seems to only get those appearances which contain a single appearance of browser inside the block. >>>>>>>>> >>>>>>>>> As I wrote in the previous mail you need to do it with nested >>>>>>>>> rewrites. Inside the block you match for any sequence of statements: >>>>>>>>> >>>>>>>>> `@.statements >>>>>>>>> >>>>>>>>> And as replacement you use the `{ :context | ... } trick to perform a >>>>>>>>> new rewrite somehow along the following untested lines: >>>>>>>>> >>>>>>>>> `{ :context | >>>>>>>>> RBParseTreeRewriter new >>>>>>>>> " replace whatever matched to `@browser with the variable a " >>>>>>>>> replaceTree: (context at: '`@browser') with: (RBParser >>>>>>>>> parseExpression: 'a'); >>>>>>>>> " execute on the list of statements " >>>>>>>>> executeTree: (context at: '`@.statements'); >>>>>>>>> " return the rewritten tree " >>>>>>>>> tree } >>>>>>>>> >>>>>>>>> Cheers, >>>>>>>>> Lukas >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Lukas Renggli >>>>>>>>> www.lukas-renggli.ch >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Lukas Renggli >>>>>>> www.lukas-renggli.ch >>>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Lukas Renggli >>>>> www.lukas-renggli.ch >>>>> >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Lukas Renggli >>> www.lukas-renggli.ch >>> >> >> >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > |
> ok I added the files this is better.
Yes, I could read the french article now. I am not quite convinced with the explanation of the back-tick though: "Un schéma peut contenir des variables en utilisant le backquote ou accent grave. Ainsi, `key représente n’importe quelle variable, mais pas une expression." "`key" is a *meta-variable*, not necessarily a variable in the matched tree. Depending on the context it can also be a selector, e.g. "foo `key" matches all unary selectors sent to a variable called 'foo'. Ok, my french might not be that good :-) Also check page 42--43 of my PhD (http://scg.unibe.ch/archive/phd/renggli-phd.pdf): 4.1.1 Tree Pattern Matching. It is a bit dense and doesn't explain everything, but the basic matching is described and was successfully tested on students. Lukas -- Lukas Renggli www.lukas-renggli.ch |
In reply to this post by Stéphane Ducasse
On Nov 4, 2010, at 5:51 PM, Lukas Renggli wrote: >> ok I added the files this is better. > > Yes, I could read the french article now. > > I am not quite convinced with the explanation of the back-tick though: > > "Un schéma peut contenir des variables en utilisant le backquote ou > accent grave. Ainsi, `key représente n’importe quelle variable, mais > pas une expression." > > "`key" is a *meta-variable*, not necessarily a variable in the matched > tree. Depending on the context it can also be a selector, e.g. "foo > `key" matches all unary selectors sent to a variable called 'foo'. I wrote that probably in 2000 so this is probably wrong. May be my english was confused too because I took that from john's slides. Indeed this is not correct, key is a meta variable that can contain an element > Ok, my french might not be that good :-) > > Also check page 42--43 of my PhD > (http://scg.unibe.ch/archive/phd/renggli-phd.pdf): 4.1.1 Tree Pattern > Matching. It is a bit dense and doesn't explain everything, but the > basic matching is described and was successfully tested on students. yes we should use that. what would be excellent is that we could get a nice set of examples that people can pick to help them. So I started to collect the answers so send to the list and for example the questions of doru are a good source I know that I often forgot to handle the other statements in a match. > > Lukas > > -- > Lukas Renggli > www.lukas-renggli.ch > |
Free forum by Nabble | Edit this page |