问题
I want to parse the following string (using Javascript):
color(alias(sumSeries(sys.mem.free.*),"memory (free)"),"#00AA88")
into an array of function names and arguments:
[["color", "#00AA88"],
["alias", "memory (free)"],
["sumSeries", ""]]
plus extract the innermost string
sys.mem.free.*
The string is actually the target parameter from graphite. I don't want to write a parser myself (dealing with things like double quotes and brackets is hard to get right). Is there a library which helps with basic parsing?
Since it's not JSON I cannot go for a JSON parser.
来源:https://stackoverflow.com/questions/18772948/parse-nested-function-call-string-in-javascript