private INode Parse(List <string> wordTree, ref int pos) { var assist = new ParseAssist(); //计算中间结果 Action priority_compute = () => { //判断是否达到3数字,2操作符 if (assist.CanCompute) { assist.Combinate(); } }; for (; pos < wordTree.Count; ++pos, priority_compute()) { var word = wordTree[pos]; //遇到左边的小括号进入递归 if (word == LEFT_BRACKET) { ++pos; assist.AddNum(Parse(wordTree, ref pos)); continue; } //遇到右边的小括号推出递归 if (word == RIGHT_BRACKET) { break; } if (this.IsOp(word)) { assist.AddOp(word); } else { assist.AddNum(word); } } return(assist.Combinate()); }
private INode Parse(List<string> wordTree, ref int pos) { var assist = new ParseAssist(); //计算中间结果 Action priority_compute = () => { //判断是否达到3数字,2操作符 if (assist.CanCompute) assist.Combinate(); }; for (; pos < wordTree.Count; ++pos, priority_compute()) { var word = wordTree[pos]; //遇到左边的小括号进入递归 if (word == LEFT_BRACKET) { ++pos; assist.AddNum(Parse(wordTree, ref pos)); continue; } //遇到右边的小括号推出递归 if (word == RIGHT_BRACKET) break; if (this.IsOp(word)) assist.AddOp(word); else assist.AddNum(word); } return assist.Combinate(); }