Assuming that every function is wrapped in "{}", you can search for curly brackets, count "{"'s and "}"'s and print the needed string when numbers of "{" and "}" are equal (i.e. this is the most outer loop i.e. this is a function).
Sorry if my advice was wrong.