A hard challenge anyone?
Jim Ault
JimAultWins at yahoo.com
Sat Feb 3 17:37:04 EST 2007
On 2/3/07 12:11 PM, "David Bovill" <david at openpartnership.net> wrote:
> Yes - I have separate handlers to deal with commands, messages and custom
> property calls. They are not causing a problem (yet) - nested function calls
> are - so i am only dealing with real user defined function calls. At the
> moment I extract the function call and then filter out Rev, External and
> user defined function calls. Once I've got the user defined function calls I
> search the script hierarchy for the matching handler if it exists - the
> final result is a graph.
>
> The hard bit is to be able to match the function call - and extract whatever
> is between the brackets - then I can recurse the bit between the brackets if
> it in turn contains a (user defined) function call.
>
> My guess is that this is something that a regexp could deal with or do I
> have to go back to the techique of counting opening and closing brackets?
Depending on how you extracted the functions you should end up with
get funcA(param1, param2, funcB(param1, param2), funcC(param))
get ....
put ... into bestAnswer
assuming you handle both kinds of comments (-- and #)
there should be no commented-out lines(?)
but one side note.. .I frequently use the following divider
--------------------- rect math fcns() -------------
which may not have an even number of dashes
Now back to the list of functions..
Try the following to see if it makes sense
replace cr with "--"&cr in fcnListing => dividers
replace "(" with cr & "(" in fcnListing
replace ")" with ")"&cr in fcnListing
Now each open paren starts a line
you could use some line-scanning technique
Or perhaps a cleaner implementation would be
get line x of fcnListing
replace "(" with cr & "(" in it
replace ")" with ")"&cr in it
--no need for dividers
Jim Ault
Las Vegas
More information about the use-livecode
mailing list