Inheritance: IFormulaTokenizer, IStringBuilderSerializable, IFormulaInterpreter, IFormulaEvaluation
Exemplo n.º 1
0
 public static FormulaNodeRound CreateRoundNode(FormulaTree child)
 {
     return(new FormulaNodeRound
     {
         Child = child
     });
 }
 public static FormulaNodeNegativeSign CreateNegativeSignNode(FormulaTree child)
 {
     return new FormulaNodeNegativeSign
     {
         Child = child
     };
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 7
0
 public static FormulaNodeNegativeSign CreateNegativeSignNode(FormulaTree child)
 {
     return(new FormulaNodeNegativeSign
     {
         Child = child
     });
 }
Exemplo n.º 8
0
 public static FormulaNodeParentheses CreateParenthesesNode(FormulaTree child)
 {
     return(new FormulaNodeParentheses
     {
         Child = child
     });
 }
Exemplo n.º 9
0
 public static FormulaNodeExp CreateExpNode(FormulaTree child)
 {
     return(new FormulaNodeExp
     {
         Child = child
     });
 }
Exemplo n.º 10
0
 public static FormulaNodeAbs CreateAbsNode(FormulaTree child)
 {
     return(new FormulaNodeAbs
     {
         Child = child
     });
 }
Exemplo n.º 11
0
 public static FormulaNodeSqrt CreateSqrtNode(FormulaTree child)
 {
     return(new FormulaNodeSqrt
     {
         Child = child
     });
 }
Exemplo n.º 12
0
 public static FormulaNodeArctan CreateArctanNode(FormulaTree child)
 {
     return(new FormulaNodeArctan
     {
         Child = child
     });
 }
Exemplo n.º 13
0
 public static FormulaNodeSin CreateSinNode(FormulaTree child)
 {
     return(new FormulaNodeSin
     {
         Child = child
     });
 }
Exemplo n.º 14
0
 public static FormulaNodeModulo CreateModuloNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeModulo
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemplo n.º 15
0
 public static FormulaNodeEquals CreateEqualsNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeEquals
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemplo n.º 16
0
 public static FormulaNodePower CreatePowerNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodePower
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemplo n.º 17
0
 public static FormulaNodeDivide CreateDivideNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeDivide
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemplo n.º 18
0
 public static FormulaNodeMultiply CreateMultiplyNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeMultiply
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemplo n.º 19
0
 public static FormulaNodeSubtract CreateSubtractNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeSubtract
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemplo n.º 20
0
 public static FormulaNodeAdd CreateAddNode(FormulaTree leftChild, FormulaTree rightChild)
 {
     return(new FormulaNodeAdd
     {
         LeftChild = leftChild,
         RightChild = rightChild
     });
 }
Exemplo n.º 21
0
 public static FormulaNodeMax CreateMaxNode(FormulaTree firstChild, FormulaTree secondChild)
 {
     return(new FormulaNodeMax
     {
         FirstChild = firstChild,
         SecondChild = secondChild
     });
 }
Exemplo n.º 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
     };
 }
Exemplo n.º 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
     };
 }
Exemplo n.º 30
0
 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
     };
 }
Exemplo n.º 33
0
        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
     };
 }
Exemplo n.º 41
0
 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
     };
 }
Exemplo n.º 45
0
 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
     };
 }
Exemplo n.º 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));
 }
Exemplo n.º 53
0
     public static IEnumerable<IFormulaToken> Tokenize(FormulaTree formula)
     {
         if (formula == null) return null;
 
         return formula.Tokenize();
     }
Exemplo n.º 54
0
 public static bool EvaluateLogic(FormulaTree formula)
 {
     return formula != null && formula.EvaluateLogic();
 }