private object Evaluate(IExpression expression) { return(expression switch { UnaryExpression unary => Evaluate(unary), BinaryExpression binary => Evaluate(binary), Variable variable => Evaluate(variable), Number number => Evaluate(number), Boolean boolean => Evaluate(boolean), _ => null });
private FormulaType GetType(IExpression expression) { return(expression switch { Boolean b => FormulaType.Bool, Number n => FormulaType.Number, UnaryExpression u => GetType(u.Expression), BinaryExpression b => GetBinaryOperationType(b), Variable v => VariableTypes.ContainsKey(v.Name) ? VariableTypes[v.Name] : FormulaType.Error, _ => FormulaType.Error });
private object Evaluate(Boolean boolean) { return(boolean.Value); }