public override Task <string> Visit(NodeExprBinary e, CancellationToken t) { return(Task.Run ( () => { var lt = Visit(e.Left, t); var rt = Visit(e.Right, t); Task.WaitAll(new[] { lt, rt }, t); t.ThrowIfCancellationRequested(); var l = lt.Result; var r = rt.Result; var lp = e.Left.Priority > e.Priority; var rp = e.Priority < e.Right.Priority; if (e.IsNecesaryParenthesisLeft) { l = $"({l})"; } if (e.IsNecesaryParenthesisRight) { r = $"({r})"; } return (e.TypeBinary == ETypeBinary.Mult && !(e.Left.TypeExpr == ENodeTypeExpr.Constant && e.Right.TypeExpr == ENodeTypeExpr.Constant)) ? l + r : l + MathExpr.TypeBinariesStr[e.TypeBinary] + r; } )); }
public override Task <NodeExpr> Visit(NodeExprBinary e, CancellationToken t) { return(Task.Run ( () => { var lt = Visit(e.Left, t); var rt = Visit(e.Right, t); Task.WaitAll(new[] { lt, rt }, t); t.ThrowIfCancellationRequested(); var l = lt.Result; var r = rt.Result; return ((l is NodeExprNumber <N> ln) && (r is NodeExprNumber <N> rn)) ? (NodeExpr)NodeExpr.Number(mAlg.EvalBinaryOperator(e.TypeBinary, ln.Value, rn.Value)) : NodeExpr.Binary(e.TypeBinary, l, r); } )); }
public override Task <NodeExpr> Visit(NodeExprBinary e, CancellationToken t) => Task.FromResult <NodeExpr>(e);
public virtual Task <T> Visit(NodeExprBinary e, CancellationToken t) => Task.FromResult(default(T));
public virtual T Visit(NodeExprBinary e) => default(T);
public NodeExprBinary(NodeExprBinary e) : this(e.TypeBinary, e.Left, e.Right) { }