def _split_arguments(span):
  """Splits span into list of spans based on commas."""
  argument_buffer = []
  arguments = []
  open_parens = 0
  for char in span:
    if char == "," and open_parens == 0:
      arguments.append("".join(argument_buffer))
      argument_buffer = []
    elif char == " " and not argument_buffer:
      continue
    else:
      if char == "(":
        open_parens += 1
      elif char == ")":
        open_parens -= 1
      argument_buffer.append(char)
  arguments.append("".join(argument_buffer))
  return arguments
Splits span into list of spans based on commas.
language/compgen/nqg/tasks/geoquery/funql_normalization.py