Inheritance: IFormulaTokenizer, IStringBuilderSerializable, IFormulaInterpreter, IFormulaEvaluation
Exemple #1
0
 public static FormulaNodeRound CreateRoundNode(FormulaTree child)
 {
     return(new FormulaNodeRound
     {
         Child = child
     });
 }
 public static FormulaNodeNegativeSign CreateNegativeSignNode(FormulaTree child)
 {
     return new FormulaNodeNegativeSign
     {
         Child = child
     };
 }
Exemple #3
0
 public static FormulaNodeLog CreateLogNode(FormulaTree child)
 {
     return(new FormulaNodeLog
     {
         Child = child
     });
 }
 internal void CloneMember(ref FormulaTree member, CloneSpriteContext context)
 {
     if (member != null)
     {
         member = member.Clone(context);
     }
 }
 internal void CloneMember(ref FormulaTree member)
 {
     if (member != null)
     {
         member = member.Clone();
     }
 }
 private void ViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs arg)
 {
     if (arg.PropertyName == "Formula")
     {
         Formula = ((FormulaEditorViewModel)sender).Formula;
     }
 }
Exemple #7
0
 public static FormulaNodeNegativeSign CreateNegativeSignNode(FormulaTree child)
 {
     return(new FormulaNodeNegativeSign
     {
         Child = child
     });
 }
Exemple #8
0
 public static FormulaNodeParentheses CreateParenthesesNode(FormulaTree child)
 {
     return(new FormulaNodeParentheses
     {
         Child = child
     });
 }
Exemple #9
0
 public static FormulaNodeExp CreateExpNode(FormulaTree child)
 {
     return(new FormulaNodeExp
     {
         Child = child
     });
 }
Exemple #10
0
 public static FormulaNodeAbs CreateAbsNode(FormulaTree child)
 {
     return(new FormulaNodeAbs
     {
         Child = child
     });
 }
Exemple #11
0
 public static FormulaNodeSqrt CreateSqrtNode(FormulaTree child)
 {
     return(new FormulaNodeSqrt
     {
         Child = child
     });
 }
Exemple #12
0
 public static FormulaNodeArctan CreateArctanNode(FormulaTree child)
 {
     return(new FormulaNodeArctan
     {
         Child = child
     });
 }
Exemple #13
0
 public static FormulaNodeSin CreateSinNode(FormulaTree child)
 {
     return(new FormulaNodeSin
     {
         Child = child
     });
 }
Exemple #14
0
 public static FormulaNodeModulo CreateModuloNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeModulo
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemple #15
0
 public static FormulaNodeEquals CreateEqualsNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeEquals
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemple #16
0
 public static FormulaNodePower CreatePowerNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodePower
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemple #17
0
 public static FormulaNodeDivide CreateDivideNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeDivide
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemple #18
0
 public static FormulaNodeMultiply CreateMultiplyNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeMultiply
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemple #19
0
 public static FormulaNodeSubtract CreateSubtractNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeSubtract
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemple #20
0
 public static FormulaNodeAdd CreateAddNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeAdd
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemple #21
0
 public static FormulaNodeMax CreateMaxNode(FormulaTree firstChild, FormulaTree secondChild)
 {
     return(new FormulaNodeMax
     {
         FirstChild = firstChild,
         SecondChild = secondChild
     });
 }
Exemple #22
0
 public static FormulaNodeRandom CreateRandomNode(FormulaTree firstChild, FormulaTree secondChild)
 {
     return(new FormulaNodeRandom
     {
         FirstChild = firstChild,
         SecondChild = secondChild
     });
 }
 public static FormulaNodePower CreatePowerNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodePower
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
        public static string Serialize(FormulaTree formula)
        {
            if (formula == null) return string.Empty;

            var sb = new StringBuilder();
            formula.Append(sb);
            return sb.ToString();
        }
 public static FormulaNodeAdd CreateAddNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeAdd
     {
         LeftChild = leftChild, 
         RightChild = rightChild
     };
 }
Exemple #26
0
 public static FormulaNodeGreaterEqual CreateGreaterEqualNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeGreaterEqual
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
 public static FormulaNodeDivide CreateDivideNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeDivide
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
 public static FormulaNodeSubtract CreateSubtractNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeSubtract
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
 public static FormulaNodeMultiply CreateMultiplyNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeMultiply
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
 private void InterpretTokens()
 {
     var interpretedFormula = FormulaInterpreter.Interpret(Tokens, out _parsingError);
     if (interpretedFormula != null)
     {
         _formula = interpretedFormula;
         RaisePropertyChanged(() => Formula);
     }
     RaisePropertyChanged(() => ParsingError);
     RaisePropertyChanged(() => HasError);
 }
 protected abstract bool TestEquals(FormulaTree other);
 public static FormulaNodeParentheses CreateParenthesesNode(FormulaTree child)
 {
     return new FormulaNodeParentheses
     {
         Child = child
     };
 }
        public static object Evaluate(FormulaTree formula)
        {
            if (formula == null) return null;

            return formula.IsNumber() ? (object)formula.EvaluateNumber() : formula.EvaluateLogic();
        }
 public static FormulaNodeRound CreateRoundNode(FormulaTree child)
 {
     return new FormulaNodeRound
     {
         Child = child
     };
 }
 public static FormulaNodeRandom CreateRandomNode(FormulaTree firstChild, FormulaTree secondChild)
 {
     return new FormulaNodeRandom
     {
         FirstChild = firstChild,
         SecondChild = secondChild
     };
 }
 public static FormulaNodeLess CreateLessNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeLess
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
 public static FormulaNodeAbs CreateAbsNode(FormulaTree child)
 {
     return new FormulaNodeAbs
     {
         Child = child
     };
 }
 public static FormulaNodeNotEquals CreateNotEqualsNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeNotEquals
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
 public static FormulaNodeArctan CreateArctanNode(FormulaTree child)
 {
     return new FormulaNodeArctan
     {
         Child = child
     };
 }
 public static FormulaNodeLog CreateLogNode(FormulaTree child)
 {
     return new FormulaNodeLog
     {
         Child = child
     };
 }
 public static double EvaluateNumber(FormulaTree formula)
 {
     return formula == null ? 0 : formula.EvaluateNumber();
 }
 public static FormulaNodeExp CreateExpNode(FormulaTree child)
 {
     return new FormulaNodeExp
     {
         Child = child
     };
 }
 public static FormulaNodeModulo CreateModuloNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeModulo
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
 public static FormulaNodeGreaterEqual CreateGreaterEqualNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return new FormulaNodeGreaterEqual
     {
         LeftChild = leftChild,
         RightChild = rightChild
     };
 }
 protected override bool TestEquals(FormulaTree other)
 {
     return TestEquals((UnaryFormulaTree) other);
 }
 public static FormulaNodeSqrt CreateSqrtNode(FormulaTree child)
 {
     return new FormulaNodeSqrt
     {
         Child = child
     };
 }
 public static FormulaNodeMax CreateMaxNode(FormulaTree firstChild, FormulaTree secondChild)
 {
     return new FormulaNodeMax
     {
         FirstChild = firstChild,
         SecondChild = secondChild
     };
 }
Exemple #48
0
 protected override bool TestEquals(FormulaTree other)
 {
     return(TestEquals((BinaryFormulaTree)other));
 }
 public SemanticsErrorException(FormulaTree node, string message) : base(message)
 {
     Node = node;
 }
 public static FormulaNodeSin CreateSinNode(FormulaTree child)
 {
     return new FormulaNodeSin
     {
         Child = child
     };
 }
 private static FormulaTree RemoveParentheses(FormulaTree node)
 {
     while (true)
     {
         var parenthesesNode = node as FormulaNodeParentheses;
         if (parenthesesNode == null) return node;
         node = parenthesesNode.Child;
     }
 }
 protected override bool TestEquals(FormulaTree other)
 {
     return(TestEquals((ConstantFormulaTree)other));
 }
     public static IEnumerable<IFormulaToken> Tokenize(FormulaTree formula)
     {
         if (formula == null) return null;
 
         return formula.Tokenize();
     }
 public static bool EvaluateLogic(FormulaTree formula)
 {
     return formula != null && formula.EvaluateLogic();
 }