public static OperatorExpressionPair Extract(this Expression source, IOperator op, params IToken[] terms) { if (!terms.Any()) { return(null); } IOperator oper = op; int tIndex = source.IndexOf(terms[0]); InsertOrientation orientation = InsertOrientation.Either; if (tIndex == 0) { if (op.Symbol != '+') { source.Remove(op); } orientation = InsertOrientation.Right; } else { source.Remove(op); orientation = InsertOrientation.Right; } oper = Operator.GetInverse(oper); foreach (IToken term in terms) { source.Remove(term); } return(new OperatorExpressionPair(oper, new SubExpression(terms), orientation)); }
public OperatorExpressionPair(IOperator oper, SubExpression expr, InsertOrientation orientation) { Expr = expr; Operator = oper; Orientation = orientation; }