private void Evaluate(Token e) { double? result = null; string info = string.Empty; try { result = evaluator.Evaluate(e); InputEntry.Text = result.ToString(); InputEntry.SelectionStart = InputEntry.Text.Length; InputEntry.SelectionLength = 0; } catch (EvaluationException ex) { info = ex.Message; } catch (Exception) { info = "Could not evaluate the expression due to an unknown problem"; } viewModel.History.Insert(0, new LogModel { Expression = e, RawExpression = e.ToString(), Result = result, Info = info, InfoColor = new SolidColorBrush(Windows.UI.Colors.LightGray) }); RefreshVariables(); }
public EvaluationException(string message, Token expression) : base(message) { Expression = expression; }
/// <summary> /// Evaluates the specified expression using this object's data. /// </summary> /// <param name='e'> /// The expression to evaluate. /// </param> /// <returns> /// The result of the evaluated expression. /// </returns> public double Evaluate(Token e) { double ans = e.Evaluate(this); Variables["ans"] = ans; return ans; }