Пример #1
0
 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
     });
Пример #2
0
 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
     });
Пример #3
0
 private object Evaluate(Boolean boolean)
 {
     return(boolean.Value);
 }