I'd like to create a few routines for manipulating function arguments in buffers, which of course requires me to first locate the arguments. Suppose that I'm operating on a buffer with a programming language with a C-like syntax, then I could search for the commas to delimit arguments. The difficulty arises when you have arguments that are calls to other functions, because those can also include commas that I wouldn't want to consider, as in the following example (the carrots point to the commas that I want to find).
somefun(w, f(x1, g(y1, y2)), h(z1, z2)) ^ ^
Assuming that I've already located the start of the arguments list, my current plan is to repeatedly use
forward-sexp to advance past the nested elements in the syntax tree and then check if the next non-whitespace character is a comma. But is there a more robust or idiomatic way to approach this?