Hi, I am trying to parse the following line:
retrieve svn "https://svnserver/trunk" But cannot get the compiler to recognise the expressions. The only way I can get it to work is to make svn a MethodInvocationExpression like this: retrieve svn("https://svnserver/trunk") and then get the name of the method and the StringLiteralExpression from the Arguments. Is there another way i can tackle this? Cheers Paul On 7 Nov, 14:21, "Ayende Rahien" <[EMAIL PROTECTED]> wrote: > protected void SetBuildTargets(string[] tasksAction) > { > foreach(var task in tasksAction) > BuildTasks.Add(task); > > } > > [Meta] > public static Expression tasks(params ReferenceExpression[] expressions) > { > > var arrayExpression = new ArrayLiteralExpression(); > > for (var i = 0; i < expressions.Length; i++) > arrayExpression.Items.Add(new > StringLiteralExpression(expressions[i].Name)); > return new MethodInvocationExpression( > new ReferenceExpression("SetBuildTargets"), > arrayExpression > ); > > > > } > On Fri, Nov 7, 2008 at 4:13 PM, Paul Cowan <[EMAIL PROTECTED]> wrote: > > but is there a reason you had to use the lambda? > > > How could I have done that? Meta methods are static. > > > I am interested because this is my first real stab at anything like this. > > > Cheers > > > 2008/11/7 Ayende Rahien <[EMAIL PROTECTED]> > > >> Also works but is there a reason you had to use the lambda? Why not just > >> pass the string array directly? > > >> On Fri, Nov 7, 2008 at 4:08 PM, Paul Cowan <[EMAIL PROTECTED]> wrote: > > >>> I ended up fixing it this way: > > >>> protected void SetBuildTargets(Func<string[]> tasksAction) > >>> { > >>> foreach(var task in tasksAction()) > >>> BuildTasks.Add(task); > >>> } > > >>> [Meta] > >>> public static Expression tasks(params ReferenceExpression[] expressions) > >>> { > >>> var blockExpression = new BlockExpression(); > > >>> var arrayExpression = new ArrayLiteralExpression(); > > >>> for (var i = 0; i < expressions.Length; i++) > >>> arrayExpression.Items.Add(new > >>> StringLiteralExpression(expressions[i].Name)); > > >>> blockExpression.Body.Add(new ReturnStatement(arrayExpression)); > > >>> return new MethodInvocationExpression( > >>> new ReferenceExpression("SetBuildTargets"), > >>> blockExpression > >>> ); > >>> } > > >>> 2008/11/7 Ayende Rahien <[EMAIL PROTECTED]> > > >>> As for documentation.The best resource for that are chapter 6 & chapter > >>>> 12. > > >>>> On Fri, Nov 7, 2008 at 1:55 PM, dagda1 <[EMAIL PROTECTED]> wrote: > > >>>>> >> You need to create a meta method that accepts a params of > >>>>> ReferenceExpression.this will allow you to skip the strings. > > >>>>> I can get this working for one task expression > > >>>>> Like this for the DSL: > > >>>>> install "horn": > >>>>> description "This is a description of horn" > >>>>> svn "https://svnserver/trunk" > >>>>> #buildfile default.build > >>>>> tasks one > > >>>>> And this for the meta method: > > >>>>> [Meta] > >>>>> public static Expression tasks(ReferenceExpression expression) > >>>>> { > >>>>> var condition = new BlockExpression(); > > >>>>> var taskExpression = new StringLiteralExpression(expression.Name); > > >>>>> condition.Body.Add(new ReturnStatement(taskExpression)); > > >>>>> return new MethodInvocationExpression( > >>>>> new ReferenceExpression("SetBuildTargets"), > >>>>> condition > >>>>> ); > >>>>> } > > >>>>> I cannot work out how to handle an array of ReferenceExpressions as I > >>>>> can only return 1 expression. > > >>>>> Do I need to use a ListExpression or something? > > >>>>> By the way the lack of documentation for this kind of thing is > >>>>> frightenning. Without Rhino.DSL I would have been lost. > > >>>>> Cheers > > >>>>> Paul > > >>>>> On 6 Nov, 16:31, "Ayende Rahien" <[EMAIL PROTECTED]> wrote: > >>>>> > LOL > > >>>>> > On Thu, Nov 6, 2008 at 6:06 PM, Paul Cowan <[EMAIL PROTECTED]> > >>>>> wrote: > >>>>> > > Excellent, > > >>>>> > > I'll resist the urge to say that you should write a BOOk about > >>>>> this, I'm > >>>>> > > guessing you may have heard it before!!! > > >>>>> > > 2008/11/6 Ayende Rahien <[EMAIL PROTECTED]> > > >>>>> > > You need to create a meta method that accepts a params of > >>>>> > >> ReferenceExpression.this will allow you to skip the strings. > >>>>> > >> The meta method will be responsible only for translating the call > >>>>> from RE > >>>>> > >> to strings, and generating a new method call to the real Tasks > >>>>> method > > >>>>> > >> On Thu, Nov 6, 2008 at 7:25 AM, dagda1 <[EMAIL PROTECTED]> > >>>>> wrote: > > >>>>> > >>> I have the following dsl with the help of rhino DSL > > >>>>> > >>> Install "component": > >>>>> > >>> Description "blah" > >>>>> > >>> Svn "https://server.com" > >>>>> > >>> Tasks "one", "two", "three" > > >>>>> > >>> I am unhappy with it because I think I am over using strings. > > >>>>> > >>> Can anyone suggest a better way? > > >>>>> > >>> Also can anyone tell me how to read in the multiple values for > >>>>> the > >>>>> > >>> tasks > >>>>> > >>> Section on the last line? > > >>>>> > >>> Cheers- Hide quoted text - > > >>>>> > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Rhino Tools Dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rhino-tools-dev?hl=en -~----------~----~----~----~------~----~------~--~---
