//12(2(34,4(,5)),6(7,))
//没有测试太多
function treeNode(val) {
	this.val = parseInt(val)
	this.right = null
	this.left = null
}
function stringToTree(str) {
	var ary = [] //[1,2,3,4,null,5,6,7]
	var re = /\d+/g
	re.lastindex = 0
	var match
	for(var i = 0; i < str.length; i++) {
		if(str[i] == ',' && str[i - 1] == '('){
			ary.push(null)
		}else if(str[i] == ')') {
			if(str[i - 1] == ',') {
				ary.push(null)
			}
			var preNode = ary.slice(-3)
			ary = ary.slice(0, -3)
			preNode[0].left = preNode[1]
			preNode[0].right = preNode[2]
			ary.push(preNode[0])
		}else if(str[i] == '('){
			continue
		}else if(match = re.exec(str)) {
			ary.push(new treeNode(match[0]))
			i = match.index + match[0].length - 1
		}
	}
	return ary[0]
}