public new Expression Clone() { var expression = new Expression(); expression.Text = Text; if (Loc != null) { expression.Loc = Loc.Clone(); } expression.Leng = Leng; expression.LineNo = LineNo; expression.ValueSet = ValueSet; expression.Type = Type; expression.ValueSet = ValueSet; expression.BoolValue = BoolValue; if (Children != null) { expression.Children = new JList<Expression>(); foreach (var child in Children) { if (this != child) { expression.Children.Add(child.Clone()); } } } expression.DoubleValue = DoubleValue; return expression; }
public void Add(Expression value) { value.ToDouble(); DoubleValue += value.DoubleValue; Type = "double"; Text = DoubleValue.ToString(); }
public Expression(Expression value) { Text = value.Text; Leng = value.Leng; Loc = value.Loc; LineNo = value.LineNo; ValueSet = value.ValueSet; BoolValue = value.BoolValue; Children = value.Children; DoubleValue = value.DoubleValue; }
public static Expression Call(string fnName, Expression value) { Expression result = null; switch (fnName.ToUpper()) { case "SUM": result = Sum(value); break; } return result; }
public static Expression CellValue(Location locStart, Location locEnd) { var range = new Expression(); for (var row = locStart.Row; row <= locEnd.Row; row++) { for (var col = locStart.Col; col <= locEnd.Col; col++) { range.Push(Spreadsheets[locStart.Sheet][row][col].UpdateValue()); } } return range; }
public static Expression Sum(Expression value) { if (value.Children != null) { double sum = 0; foreach (Expression child in value.Children) { sum += child.ToDouble(); } var firstChild = value.Children[0]; firstChild.Set(sum); return firstChild; } value.ToDouble(); return value; }
public Expression UpdateValue() { if (HasFormula && State.Count < 1) { State.Push ("Parsing"); CalcCount++; var formula = new Formula (); var value = formula.Parse (Formula); State.Pop (); return value; } else { var exp = new Expression(); double num; if (double.TryParse(Value, out num)) { exp.Set(num); } else { exp.Set(Value); } return exp; } }
public void Add(Expression value) { value.ToDouble(); DoubleValue += value.DoubleValue; Type = "double"; }
public void Push(Expression value) { if (Children == null) { Children = new List<Expression>() { this }; } Children.Add (value); }
public void Concat(Expression value) { Text += value.Text; Type = "string"; }