------art_46364_30815498.1202509243454
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I modified slightly to avoid parenthesis within quotes or double quotes

  def get_fns(string, count
     m  (?<fn>
             fn:[\w\-]+
             \s*\(\s*
                 (\g<fn>|(".+")*('.+')*[^)]*)
             \s*\)
         )\s*/xi.match(string)
     if m
         n  ^(fn:[\w\-]+)(\s*)\((.*?)\)$/.match(m['fn'])
         puts "FN #{count}: #{n[1]} with args #{n[3]}"
         get_fns(n[3], count + 1)
     end
  end


On Feb 8, 2008 7:39 AM, jOhn <netcam / gmail.com> wrote:

> wow good job thomas.
>
> On Feb 8, 2008 1:19 AM, tho_mica_l <micathom / gmail.com> wrote:
>
> > > To parse a logic statement like this:
> > >
> > > fn:function3(fn:function2(fn:function1(xargs)))
> >
> > Are you looking for something like this (ruby19):
> >
> > def get_fns(string, count
> >    m  (?<fn>
> >            fn:[\w\-]+
> >            \s*\(\s*
> >                (\g<fn>|[^)]*)
> >            \s*\)
> >        )\s*/xi.match(string)
> >    if m
> >        n  ^(fn:[\w\-]+)(\s*)\((.*?)\)$/.match(m['fn'])
> >        puts "FN #{count}: #{n[1]} with args #{n[3]}"
> >        get_fns(n[3], count + 1)
> >    end
> > end
> > a  foo fn:function3(fn:function2(fn:function1(xargs))) foo(bar) bar"
> > get_fns(a)
> >
> > > a  foo fn:function3(fn:function2(fn:function1(xargs))) foo(bar) bar"
> > > get_fns(a)
> > FN 0: fn:function3 with args fn:function2(fn:function1(xargs))
> > FN 1: fn:function2 with args fn:function1(xargs)
> > FN 2: fn:function1 with args xargs
> > nil
> >
> > Regards,
> > Thomas.
> >
> >
> >
>

------art_46364_30815498.1202509243454--