static void Parser(string Formula, ref ParserObject p, List <object> charInput) { int begin = 0, end = 0; Formula = Formula.Trim(); if (Formula != null && Formula.Length > 0) { for (int pos = 0; pos < Formula.Length; pos++) { if (p.inSepcialScope || CommonTool.IsFuncPrix(Formula[pos])) { CommonTool.ParenthesesComplete(Formula[pos], ref p.leftCount, ref p.rightCount); CommonTool.FuncConstScopeJudger(Formula[pos], p.leftCount, p.rightCount, ref p.inFuncScope, ref p.inConstScope); if (p.inConstScope) { ParserHelper.ConstsParser(Formula, ref begin, ref end, ref pos, p, charInput); continue; } if (p.inFuncScope) { if (p.leftCount == p.rightCount) { ParserHelper.FuncParser(Formula, ref begin, ref end, ref pos, p, charInput); continue; } } end++; p.inSepcialScope = true; } else if (!CommonTool.IsNumber(Formula[pos])) { if (OperandManager.isOperand(CommonTool.GetSymbol(Formula[pos]))) { OperandManager.ParseOperand(CommonTool.GetSymbol(Formula[pos]), ref Formula, ref pos, ref begin, ref end); } else { if (begin != end) { charInput.Add(CommonTool.StringToFloat(Formula.Substring(begin, end - begin))); } charInput.Add(CommonTool.GetSymbol(Formula[pos])); begin = end = pos + 1; } } else//数字 { end++; } } //after read all the symbols //The last word is numeric the algorithm above is not correct. if (p.inSepcialScope)//const { string constExpression = Formula.Substring(begin, end - begin).ToLower(); if (ConstNumbers.Consts.ContainsKey(constExpression)) { charInput.Add(ConstNumbers.Consts[constExpression]); } } else if (CommonTool.IsNumber(Formula[Formula.Length - 1])) { charInput.Add(CommonTool.StringToFloat(Formula.Substring(begin, end - begin))); } } else { throw new Exception("Formula must contain a word!"); } }