class REXML::Parsers::XPathParser

def parse_args( string )

def parse_args( string )
  arguments = []
  ind = 0
  inquot = false
  inapos = false
  depth = 1
  begin
    case string[ind]
    when ?"
      inquot = !inquot unless inapos
    when ?'
      inapos = !inapos unless inquot
    else
      unless inquot or inapos
        case string[ind]
        when ?(
          depth += 1
          if depth == 1
            string = string[1..-1]
            ind -= 1
          end
        when ?)
          depth -= 1
          if depth == 0
            s = string[0,ind].strip
            arguments << s unless s == ""
            string = string[ind+1..-1]
          end
        when ?,
          if depth == 1
            s = string[0,ind].strip
            arguments << s unless s == ""
            string = string[ind+1..-1]
            ind = -1
          end
        end
      end
    end
    ind += 1
  end while depth > 0 and ind < string.length
  return nil unless depth==0
  [string,arguments]
end