public ExpressionTree FindRootTree(ExpressionTree expressionTree_2) { if (expressionTree_2.Parent != null) { do { expressionTree_2 = expressionTree_2.Parent; } while (expressionTree_2.Parent != null); } return(expressionTree_2); }
public void Init(string string_0) { string_0 = string_0.Replace(" ", ""); ParamList.Clear(); expressionTree_1 = BulidTree(null, string_0); }
public ExpressionTree BulidTree(ExpressionTree expressionTree_2, string string_0) { int num2; int num3; ExpressionTree tree2; ExpressionTree tree5; string str2; int num = 0; if (!IsFuction(string_0, out num)) { if (string_0[0] != '(') { ExpressionTree tree7; int startIndex = 0; num3 = 0; while (num3 < string_0.Length) { ExpressionTree tree6; if (method_0(string_0[num3])) { tree6 = new ExpressionTree { Tag = string.Format("{0}", string_0[num3]) }; if (num3 == 0) { str2 = null; } else { str2 = string_0.Substring(startIndex, num3 - startIndex); } tree7 = new ExpressionTree { Tag = str2 }; foreach (string str3 in str2.Split(new char[] { ',' })) { if (method_3(str3) && !ParamList.ContainsKey(str3)) { ParamList.Add(str3, null); } } if (expressionTree_2 == null) { tree6.LeftTree = tree7; expressionTree_2 = tree6; } else if (method_2(tree6.Tag, expressionTree_2.Tag) == 1) { expressionTree_2.RightTree = tree6; tree6.LeftTree = tree7; expressionTree_2 = tree6; } else { expressionTree_2.RightTree = tree7; if (expressionTree_2.Parent != null) { expressionTree_2.Parent.RightTree = tree6; } tree6.LeftTree = expressionTree_2; expressionTree_2 = tree6; } break; } if (method_1(string_0[num3])) { char ch = string_0[num3]; string str4 = ch.ToString(); if (method_1(string_0[num3 + 1])) { ch = string_0[num3 + 1]; str4 = str4 + ch.ToString(); num3++; } tree6 = new ExpressionTree { Tag = str4 }; if (num3 == 0) { str2 = "0"; } else { str2 = string_0.Substring(startIndex, num3 - startIndex); } tree7 = new ExpressionTree { Tag = str2 }; foreach (string str3 in str2.Split(new char[] { ',' })) { if (method_3(str3) && !ParamList.ContainsKey(str3)) { ParamList.Add(str3, null); } } if (expressionTree_2 == null) { tree6.LeftTree = tree7; expressionTree_2 = tree6; } else if (method_2(tree6.Tag, expressionTree_2.Tag) == 1) { expressionTree_2.RightTree = tree6; tree6.LeftTree = tree7; expressionTree_2 = tree6; } else { expressionTree_2.RightTree = tree7; if (expressionTree_2.Parent != null) { expressionTree_2.Parent.RightTree = tree6; } tree6.LeftTree = expressionTree_2; expressionTree_2 = tree6; } break; } num3++; } if (num3 == string_0.Length) { tree7 = new ExpressionTree { Tag = string_0 }; if (expressionTree_2 == null) { expressionTree_2 = tree7; } else { expressionTree_2.RightTree = tree7; } foreach (string str3 in string_0.Split(new char[] { ',' })) { if (method_3(str3) && !ParamList.ContainsKey(str3)) { ParamList.Add(str3, null); } } return(FindRootTree(expressionTree_2)); } string str5 = string_0.Substring(num3 + 1); BulidTree(expressionTree_2, str5); goto Label_0695; } num2 = 1; num3 = 0; tree2 = null; for (num3 = 1; num3 < string_0.Length; num3++) { if (string_0[num3] == ')') { num2--; if (num2 != 0) { continue; } string str = string_0.Substring(1, num3 - num - 1); tree2 = BulidTree(null, str); break; } if (string_0[num3] == '(') { num2++; } } } else { ExpressionTree tree = new ExpressionTree { Tag = string_0.Substring(0, num) }; num2 = 1; num3 = 0; num3 = num + 1; while (num3 < string_0.Length) { if (string_0[num3] == ')') { num2--; if (num2 != 0) { goto Label_0064; } string[] strArray = string_0.Substring(num + 1, num3 - num - 1).Split(new char[] { ',' }); tree2 = BulidTree(null, strArray[0]); tree.RightTree = tree2; if (strArray.Length == 2) { ExpressionTree tree3 = BulidTree(null, strArray[1]); tree.SecondTree = tree3; } break; } if (string_0[num3] == '(') { num2++; } Label_0064: num3++; } if (num3 == string_0.Length - 1) { if (expressionTree_2 != null) { expressionTree_2.RightTree = tree; } else { expressionTree_2 = tree; } return(FindRootTree(expressionTree_2)); } tree5 = new ExpressionTree(); tree5.Tag = string_0[num3 + 1].ToString(); if (expressionTree_2 != null) { if (method_2(tree5.Tag, expressionTree_2.Tag) == 1) { expressionTree_2.RightTree = tree5; tree5.LeftTree = tree; expressionTree_2 = tree5; } else { expressionTree_2.RightTree = tree; if (expressionTree_2.Parent != null) { expressionTree_2.Parent.RightTree = tree5; } tree5.LeftTree = expressionTree_2; expressionTree_2 = tree5; } } else { tree5.LeftTree = tree; expressionTree_2 = tree5; } str2 = string_0.Substring(num3 + 2); BulidTree(expressionTree_2, str2); goto Label_0695; } if (num3 == string_0.Length - 1) { if (expressionTree_2 != null) { expressionTree_2.RightTree = tree2; } else { expressionTree_2 = tree2; } return(FindRootTree(expressionTree_2)); } tree5 = new ExpressionTree(); tree5.Tag = string_0[num3 + 1].ToString(); if (expressionTree_2 != null) { if (method_2(tree5.Tag, expressionTree_2.Tag) == 1) { expressionTree_2.RightTree = tree5; tree5.LeftTree = tree2; expressionTree_2 = tree5; } else { expressionTree_2.RightTree = tree2; if (expressionTree_2.Parent != null) { expressionTree_2.Parent.RightTree = tree5; } tree5.LeftTree = expressionTree_2; expressionTree_2 = tree5; } } else { tree5.LeftTree = tree2; expressionTree_2 = tree5; } str2 = string_0.Substring(num3 + 2); BulidTree(expressionTree_2, str2); Label_0695: return(FindRootTree(expressionTree_2)); }