/// <summary> /// Detects operation /// </summary> /// <param name="i">variable number</param> /// <param name="symbol">Symbol</param> /// <returns>True if operation is decected and false otherwise</returns> public bool Detect(int i, MathSymbol symbol) { return(detector.Detect(i, symbol)); }
/// <summary> /// Processes multi operation /// </summary> /// <param name="formula">Formula</param> /// <param name="creator">Formula creator</param> /// <returns>True if operation exists and false otherwise</returns> protected bool processMultiOperation(MathFormula formula, IFormulaObjectCreator creator) { for (int n = 0; n < creator.MultiOperationCount; n++) { IMultiOperationDetector detector = creator.GetMultiOperationDetector(n); int j = 0; int m = 0; int i = 0; //int opened = 0; int k = 0; List <ObjectFormulaTree> list = null; for (; i < formula.Count; i++) { MathSymbol symbol = formula[i]; if (creator.IsBra(symbol)) { ++m; continue; } if (creator.IsKet(symbol)) { --m; continue; } if (m != 0) { continue; } if (!detector.Detect(k, symbol)) { continue; } if (list == null) { list = new List <ObjectFormulaTree>(); } MathFormula f = new MathFormula(formula, j, i - 1); list.Add(CreateTree(f, creator)); ++k; j = i + 1; if (k == detector.Count) { f = new MathFormula(formula, j, formula.Count - 1); list.Add(CreateTree(f, creator)); object[] types = new object[list.Count]; int nOp = 0; foreach (ObjectFormulaTree tree in list) { types[nOp] = tree.ReturnType; ++nOp; } IObjectOperation op = detector.Accept(types); if (op != null) { operation = op; children = list; y = new object[list.Count]; return(true); } } } } return(false); }